react-intlayer 2.0.8 → 2.0.10

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.
@@ -26,8 +26,8 @@ __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_client2 = require("intlayer-editor/client");
29
30
  var import_react = require("react");
30
- var import_ContentEditionLayout = require('./ContentEditionLayout.cjs');
31
31
  var import_useLocaleCookie = require('./useLocaleCookie.cjs');
32
32
  const IntlayerClientContext = (0, import_react.createContext)({
33
33
  locale: import_useLocaleCookie.localeCookie ?? (0, import_client.getConfiguration)().internationalization.defaultLocale,
@@ -62,7 +62,7 @@ const IntlayerProvider = ({
62
62
  [currentLocale, setLocale]
63
63
  );
64
64
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerClientContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
- import_ContentEditionLayout.ContentEditionLayout,
65
+ import_client2.ContentEditionLayout,
66
66
  {
67
67
  locale: currentLocale,
68
68
  setLocale,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { ContentEditionLayout } from './ContentEditionLayout';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n 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,mBAQO;AACP,kCAAqC;AACrC,6BAA8C;AAUvC,MAAM,4BAAwB,4BAA6B;AAAA,EAChE,QAAQ,2CAAgB,gCAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,UAAM,yBAAW,qBAAqB;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 { ContentEditionLayout } from 'intlayer-editor/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';\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,IAAAA,iBAAqC;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":["import_client"]}
@@ -33,14 +33,14 @@ __export(useIntlayerBase_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(useIntlayerBase_exports);
35
35
  var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
36
+ var import_client = require("intlayer-editor/client");
36
37
  var import_react = require("react");
37
38
  var import_processDictionary = require('./processDictionary/index.cjs');
38
- var import_renderIntlayerEditor = require('./renderIntlayerEditor.cjs');
39
39
  const recursiveTransformContent = (value) => {
40
40
  if (typeof value === "function") {
41
41
  return (props) => recursiveTransformContent(value(props));
42
42
  } else if (typeof value === "object" && typeof value.keyPath !== "undefined" && typeof value.dictionaryId !== "undefined" && typeof value.dictionaryPath !== "undefined") {
43
- return (0, import_renderIntlayerEditor.renderIntlayerEditor)(value);
43
+ return (0, import_client.renderIntlayerEditor)(value);
44
44
  } else if (typeof value === "object" && Array.isArray(value)) {
45
45
  return value.map(recursiveTransformContent);
46
46
  } else if (typeof value === "object" && (0, import_react.isValidElement)(value)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport type { Dictionary, NodeType } from '@intlayer/core';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\nimport { renderIntlayerEditor } from './renderIntlayerEditor';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\n */\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\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> // DeepTransformContent<T[L], L>\n : never\n : T;\n\ntype 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 * Excludes the 'id' and 'filePath' keys from the dictionary content,\n * as they are not part of the IntlayerDictionaryTypesConnector type.\n */\ntype ExcludeIntlayerUtilsKeys<T> = Omit<T, 'id' | 'filePath'>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\ntype Data<\n T extends DictionaryKeys,\n K extends Locales,\n> = ExcludeIntlayerUtilsKeys<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T], K>\n>;\n\n/**\n * Parcourt the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (value: any): object => {\n if (typeof value === 'function') {\n return (props: any) => recursiveTransformContent(value(props));\n } else if (\n typeof value === 'object' &&\n typeof value.keyPath !== 'undefined' &&\n typeof value.dictionaryId !== 'undefined' &&\n typeof value.dictionaryPath !== 'undefined'\n ) {\n return renderIntlayerEditor(value);\n } else if (typeof value === 'object' && Array.isArray(value)) {\n return value.map(recursiveTransformContent);\n } else if (typeof value === 'object' && isValidElement(value)) {\n return value;\n } else if (typeof value === 'object') {\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value),\n }),\n {} as object\n );\n }\n\n return value.value;\n};\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <T extends DictionaryKeys, L extends Locales>(\n id: T,\n locale?: L\n) => Data<T, L>;\n\n/**\n * Hook that picks one dictionary by its ID and returns the content,\n * deeply transformed according to the dictionary structure and metadata.\n */\nexport const useIntlayerBase: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n>(\n id: T,\n locale?: L\n) => {\n const dictionary: Dictionary = dictionaries[id as keyof typeof dictionaries];\n\n const result = processDictionary(\n dictionary,\n id,\n dictionary.filePath,\n [],\n locale\n ) as object;\n\n return recursiveTransformContent(result) as Data<T, L>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gCAAyB;AAEzB,mBAA+C;AAC/C,+BAAkC;AAClC,kCAAqC;AA4E9B,MAAM,4BAA4B,CAAC,UAAuB;AAC/D,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UAAe,0BAA0B,MAAM,KAAK,CAAC;AAAA,EAC/D,WACE,OAAO,UAAU,YACjB,OAAO,MAAM,YAAY,eACzB,OAAO,MAAM,iBAAiB,eAC9B,OAAO,MAAM,mBAAmB,aAChC;AACA,eAAO,kDAAqB,KAAK;AAAA,EACnC,WAAW,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;AAC5D,WAAO,MAAM,IAAI,yBAAyB;AAAA,EAC5C,WAAW,OAAO,UAAU,gBAAY,6BAAe,KAAK,GAAG;AAC7D,WAAO;AAAA,EACT,WAAW,OAAO,UAAU,UAAU;AACpC,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,MAAK;AAAA,MACxC;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,MAAM;AACf;AAgBO,MAAM,kBAA+B,CAI1C,IACA,WACG;AACH,QAAM,aAAyB,0BAAAC,QAAa,EAA+B;AAE3E,QAAM,aAAS;AAAA,IACb;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO,0BAA0B,MAAM;AACzC;","names":["value","dictionaries"]}
1
+ {"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport type { Dictionary, NodeType } from '@intlayer/core';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { renderIntlayerEditor } from 'intlayer-editor/client';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\n */\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\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> // DeepTransformContent<T[L], L>\n : never\n : T;\n\ntype 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 * Excludes the 'id' and 'filePath' keys from the dictionary content,\n * as they are not part of the IntlayerDictionaryTypesConnector type.\n */\ntype ExcludeIntlayerUtilsKeys<T> = Omit<T, 'id' | 'filePath'>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\ntype Data<\n T extends DictionaryKeys,\n K extends Locales,\n> = ExcludeIntlayerUtilsKeys<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T], K>\n>;\n\n/**\n * Parcourt the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (value: any): object => {\n if (typeof value === 'function') {\n return (props: any) => recursiveTransformContent(value(props));\n } else if (\n typeof value === 'object' &&\n typeof value.keyPath !== 'undefined' &&\n typeof value.dictionaryId !== 'undefined' &&\n typeof value.dictionaryPath !== 'undefined'\n ) {\n return renderIntlayerEditor(value);\n } else if (typeof value === 'object' && Array.isArray(value)) {\n return value.map(recursiveTransformContent);\n } else if (typeof value === 'object' && isValidElement(value)) {\n return value;\n } else if (typeof value === 'object') {\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value),\n }),\n {} as object\n );\n }\n\n return value.value;\n};\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <T extends DictionaryKeys, L extends Locales>(\n id: T,\n locale?: L\n) => Data<T, L>;\n\n/**\n * Hook that picks one dictionary by its ID and returns the content,\n * deeply transformed according to the dictionary structure and metadata.\n */\nexport const useIntlayerBase: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n>(\n id: T,\n locale?: L\n) => {\n const dictionary: Dictionary = dictionaries[id as keyof typeof dictionaries];\n\n const result = processDictionary(\n dictionary,\n id,\n dictionary.filePath,\n [],\n locale\n ) as object;\n\n return recursiveTransformContent(result) as Data<T, L>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gCAAyB;AAEzB,oBAAqC;AACrC,mBAA+C;AAC/C,+BAAkC;AA4E3B,MAAM,4BAA4B,CAAC,UAAuB;AAC/D,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UAAe,0BAA0B,MAAM,KAAK,CAAC;AAAA,EAC/D,WACE,OAAO,UAAU,YACjB,OAAO,MAAM,YAAY,eACzB,OAAO,MAAM,iBAAiB,eAC9B,OAAO,MAAM,mBAAmB,aAChC;AACA,eAAO,oCAAqB,KAAK;AAAA,EACnC,WAAW,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;AAC5D,WAAO,MAAM,IAAI,yBAAyB;AAAA,EAC5C,WAAW,OAAO,UAAU,gBAAY,6BAAe,KAAK,GAAG;AAC7D,WAAO;AAAA,EACT,WAAW,OAAO,UAAU,UAAU;AACpC,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,MAAK;AAAA,MACxC;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,MAAM;AACf;AAgBO,MAAM,kBAA+B,CAI1C,IACA,WACG;AACH,QAAM,aAAyB,0BAAAC,QAAa,EAA+B;AAE3E,QAAM,aAAS;AAAA,IACb;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO,0BAA0B,MAAM;AACzC;","names":["value","dictionaries"]}
@@ -2,6 +2,7 @@
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/client";
5
6
  import {
6
7
  createContext,
7
8
  useContext,
@@ -9,7 +10,6 @@ import {
9
10
  useState,
10
11
  useCallback
11
12
  } from "react";
12
- import { ContentEditionLayout } from './ContentEditionLayout.mjs';
13
13
  import { localeCookie, setLocaleCookie } from './useLocaleCookie.mjs';
14
14
  const IntlayerClientContext = createContext({
15
15
  locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { ContentEditionLayout } from './ContentEditionLayout';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n 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;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,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 { ContentEditionLayout } from 'intlayer-editor/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';\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,8 +1,8 @@
1
1
  import "./chunk-ZD7AOCMD.mjs";
2
2
  import dictionaries from "@intlayer/dictionaries-entry";
3
+ import { renderIntlayerEditor } from "intlayer-editor/client";
3
4
  import { isValidElement } from "react";
4
5
  import { processDictionary } from './processDictionary/index.mjs';
5
- import { renderIntlayerEditor } from './renderIntlayerEditor.mjs';
6
6
  const recursiveTransformContent = (value) => {
7
7
  if (typeof value === "function") {
8
8
  return (props) => recursiveTransformContent(value(props));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport type { Dictionary, NodeType } from '@intlayer/core';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\nimport { renderIntlayerEditor } from './renderIntlayerEditor';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\n */\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\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> // DeepTransformContent<T[L], L>\n : never\n : T;\n\ntype 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 * Excludes the 'id' and 'filePath' keys from the dictionary content,\n * as they are not part of the IntlayerDictionaryTypesConnector type.\n */\ntype ExcludeIntlayerUtilsKeys<T> = Omit<T, 'id' | 'filePath'>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\ntype Data<\n T extends DictionaryKeys,\n K extends Locales,\n> = ExcludeIntlayerUtilsKeys<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T], K>\n>;\n\n/**\n * Parcourt the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (value: any): object => {\n if (typeof value === 'function') {\n return (props: any) => recursiveTransformContent(value(props));\n } else if (\n typeof value === 'object' &&\n typeof value.keyPath !== 'undefined' &&\n typeof value.dictionaryId !== 'undefined' &&\n typeof value.dictionaryPath !== 'undefined'\n ) {\n return renderIntlayerEditor(value);\n } else if (typeof value === 'object' && Array.isArray(value)) {\n return value.map(recursiveTransformContent);\n } else if (typeof value === 'object' && isValidElement(value)) {\n return value;\n } else if (typeof value === 'object') {\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value),\n }),\n {} as object\n );\n }\n\n return value.value;\n};\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <T extends DictionaryKeys, L extends Locales>(\n id: T,\n locale?: L\n) => Data<T, L>;\n\n/**\n * Hook that picks one dictionary by its ID and returns the content,\n * deeply transformed according to the dictionary structure and metadata.\n */\nexport const useIntlayerBase: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n>(\n id: T,\n locale?: L\n) => {\n const dictionary: Dictionary = dictionaries[id as keyof typeof dictionaries];\n\n const result = processDictionary(\n dictionary,\n id,\n dictionary.filePath,\n [],\n locale\n ) as object;\n\n return recursiveTransformContent(result) as Data<T, L>;\n};\n"],"mappings":";AAQA,OAAO,kBAAkB;AAEzB,SAAS,sBAAsC;AAC/C,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AA4E9B,MAAM,4BAA4B,CAAC,UAAuB;AAC/D,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UAAe,0BAA0B,MAAM,KAAK,CAAC;AAAA,EAC/D,WACE,OAAO,UAAU,YACjB,OAAO,MAAM,YAAY,eACzB,OAAO,MAAM,iBAAiB,eAC9B,OAAO,MAAM,mBAAmB,aAChC;AACA,WAAO,qBAAqB,KAAK;AAAA,EACnC,WAAW,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;AAC5D,WAAO,MAAM,IAAI,yBAAyB;AAAA,EAC5C,WAAW,OAAO,UAAU,YAAY,eAAe,KAAK,GAAG;AAC7D,WAAO;AAAA,EACT,WAAW,OAAO,UAAU,UAAU;AACpC,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,MAAK;AAAA,MACxC;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,MAAM;AACf;AAgBO,MAAM,kBAA+B,CAI1C,IACA,WACG;AACH,QAAM,aAAyB,aAAa,EAA+B;AAE3E,QAAM,SAAS;AAAA,IACb;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO,0BAA0B,MAAM;AACzC;","names":["value"]}
1
+ {"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport type { Dictionary, NodeType } from '@intlayer/core';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { renderIntlayerEditor } from 'intlayer-editor/client';\nimport { isValidElement, type ReactNode } from 'react';\nimport { processDictionary } from './processDictionary/index';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\n */\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\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> // DeepTransformContent<T[L], L>\n : never\n : T;\n\ntype 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 * Excludes the 'id' and 'filePath' keys from the dictionary content,\n * as they are not part of the IntlayerDictionaryTypesConnector type.\n */\ntype ExcludeIntlayerUtilsKeys<T> = Omit<T, 'id' | 'filePath'>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\ntype Data<\n T extends DictionaryKeys,\n K extends Locales,\n> = ExcludeIntlayerUtilsKeys<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T], K>\n>;\n\n/**\n * Parcourt the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (value: any): object => {\n if (typeof value === 'function') {\n return (props: any) => recursiveTransformContent(value(props));\n } else if (\n typeof value === 'object' &&\n typeof value.keyPath !== 'undefined' &&\n typeof value.dictionaryId !== 'undefined' &&\n typeof value.dictionaryPath !== 'undefined'\n ) {\n return renderIntlayerEditor(value);\n } else if (typeof value === 'object' && Array.isArray(value)) {\n return value.map(recursiveTransformContent);\n } else if (typeof value === 'object' && isValidElement(value)) {\n return value;\n } else if (typeof value === 'object') {\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value),\n }),\n {} as object\n );\n }\n\n return value.value;\n};\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <T extends DictionaryKeys, L extends Locales>(\n id: T,\n locale?: L\n) => Data<T, L>;\n\n/**\n * Hook that picks one dictionary by its ID and returns the content,\n * deeply transformed according to the dictionary structure and metadata.\n */\nexport const useIntlayerBase: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n>(\n id: T,\n locale?: L\n) => {\n const dictionary: Dictionary = dictionaries[id as keyof typeof dictionaries];\n\n const result = processDictionary(\n dictionary,\n id,\n dictionary.filePath,\n [],\n locale\n ) as object;\n\n return recursiveTransformContent(result) as Data<T, L>;\n};\n"],"mappings":";AAQA,OAAO,kBAAkB;AAEzB,SAAS,4BAA4B;AACrC,SAAS,sBAAsC;AAC/C,SAAS,yBAAyB;AA4E3B,MAAM,4BAA4B,CAAC,UAAuB;AAC/D,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UAAe,0BAA0B,MAAM,KAAK,CAAC;AAAA,EAC/D,WACE,OAAO,UAAU,YACjB,OAAO,MAAM,YAAY,eACzB,OAAO,MAAM,iBAAiB,eAC9B,OAAO,MAAM,mBAAmB,aAChC;AACA,WAAO,qBAAqB,KAAK;AAAA,EACnC,WAAW,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;AAC5D,WAAO,MAAM,IAAI,yBAAyB;AAAA,EAC5C,WAAW,OAAO,UAAU,YAAY,eAAe,KAAK,GAAG;AAC7D,WAAO;AAAA,EACT,WAAW,OAAO,UAAU,UAAU;AACpC,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,MAAK;AAAA,MACxC;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,MAAM;AACf;AAgBO,MAAM,kBAA+B,CAI1C,IACA,WACG;AACH,QAAM,aAAyB,aAAa,EAA+B;AAE3E,QAAM,SAAS;AAAA,IACb;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO,0BAA0B,MAAM;AACzC;","names":["value"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "private": false,
5
5
  "description": "Internationalization layer for React applications - Layer of abstraction between the business logic and the data access layer. Manage internationalization in a simple way, through TypeScript, JavaScript or JSON declaration file.",
6
6
  "keywords": [
@@ -75,12 +75,13 @@
75
75
  "react-cookie": "^7.1.4",
76
76
  "vite": "^5.3.1",
77
77
  "webpack": "^5.92.1",
78
- "@intlayer/chokidar": "^2.0.8",
79
- "@intlayer/config": "^2.0.8",
80
- "@intlayer/core": "^2.0.8",
81
- "@intlayer/webpack": "^2.0.8",
82
- "@intlayer/dictionaries-entry": "^2.0.8",
83
- "intlayer": "^2.0.8"
78
+ "@intlayer/config": "^2.0.10",
79
+ "@intlayer/dictionaries-entry": "^2.0.10",
80
+ "@intlayer/core": "^2.0.10",
81
+ "@intlayer/webpack": "^2.0.10",
82
+ "intlayer": "^2.0.10",
83
+ "intlayer-editor": "^2.1.9",
84
+ "@intlayer/chokidar": "^2.0.10"
84
85
  },
85
86
  "devDependencies": {
86
87
  "@craco/types": "^7.1.0",
@@ -98,13 +99,7 @@
98
99
  },
99
100
  "peerDependencies": {
100
101
  "react": "^18.2.0",
101
- "react-dom": "^18.2.0",
102
- "intlayer-editor": "^2.1.7"
103
- },
104
- "peerDependenciesMeta": {
105
- "intlayer-editor": {
106
- "optional": true
107
- }
102
+ "react-dom": "^18.2.0"
108
103
  },
109
104
  "engines": {
110
105
  "node": ">=14.18"
@@ -1,39 +0,0 @@
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 ContentEditionLayout_exports = {};
20
- __export(ContentEditionLayout_exports, {
21
- ContentEditionLayout: () => ContentEditionLayout
22
- });
23
- module.exports = __toCommonJS(ContentEditionLayout_exports);
24
- var import_jsx_runtime = require("react/jsx-runtime");
25
- const import_meta = {};
26
- const BlankLayout = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
27
- const requireFunction = () => {
28
- try {
29
- return typeof import_meta.url === "undefined" ? require("intlayer-editor/client") : module.require("intlayer-editor/client");
30
- } catch (error) {
31
- return void 0;
32
- }
33
- };
34
- const ContentEditionLayout = typeof requireFunction()?.ContentEditionLayoutBase === "undefined" ? BlankLayout : requireFunction().ContentEditionLayoutBase;
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- ContentEditionLayout
38
- });
39
- //# sourceMappingURL=ContentEditionLayout.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import type { ContentEditionLayoutProps } from 'intlayer-editor/client';\nimport type { FC } from 'react';\n\nconst BlankLayout: FC<ContentEditionLayoutProps> = ({ children }) => (\n <>{children}</>\n);\n\nconst requireFunction = () => {\n try {\n return typeof import.meta.url === 'undefined'\n ? require('intlayer-editor/client')\n : module.require('intlayer-editor/client');\n } catch (error) {\n return undefined;\n }\n};\n// intlayer-editor is an optional dependency. If it's not installed, return the blank layout\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> =\n typeof requireFunction()?.ContentEditionLayoutBase === 'undefined'\n ? BlankLayout\n : requireFunction().ContentEditionLayoutBase;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIE;AAJF;AAGA,MAAM,cAA6C,CAAC,EAAE,SAAS,MAC7D,2EAAG,UAAS;AAGd,MAAM,kBAAkB,MAAM;AAC5B,MAAI;AACF,WAAO,OAAO,YAAY,QAAQ,cAC9B,QAAQ,wBAAwB,IAChC,OAAO,QAAQ,wBAAwB;AAAA,EAC7C,SAAS,OAAO;AACd,WAAO;AAAA,EACT;AACF;AAEO,MAAM,uBACX,OAAO,gBAAgB,GAAG,6BAA6B,cACnD,cACA,gBAAgB,EAAE;","names":[]}
@@ -1,6 +0,0 @@
1
- import { ContentEditionLayoutProps } from 'intlayer-editor/client';
2
- import { FC } from 'react';
3
-
4
- declare const ContentEditionLayout: FC<ContentEditionLayoutProps>;
5
-
6
- export { ContentEditionLayout };
@@ -1,49 +0,0 @@
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 renderIntlayerEditor_exports = {};
20
- __export(renderIntlayerEditor_exports, {
21
- renderIntlayerEditor: () => renderIntlayerEditor
22
- });
23
- module.exports = __toCommonJS(renderIntlayerEditor_exports);
24
- var import_jsx_runtime = require("react/jsx-runtime");
25
- const import_meta = {};
26
- const requireFunction = () => {
27
- try {
28
- return typeof import_meta.url === "undefined" ? require("intlayer-editor/client") : module.require("intlayer-editor/client");
29
- } catch (error) {
30
- return void 0;
31
- }
32
- };
33
- const IntlayerEditorElement = ({
34
- content,
35
- ..._props
36
- }) => content;
37
- const renderIntlayerEditor = (props) => {
38
- const _renderIntlayerEditor = requireFunction()?.renderIntlayerEditor;
39
- if (typeof _renderIntlayerEditor === "undefined") {
40
- const Result = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerEditorElement, { ...props });
41
- return { ...Result, value: props.content };
42
- }
43
- return _renderIntlayerEditor(props);
44
- };
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- renderIntlayerEditor
48
- });
49
- //# sourceMappingURL=renderIntlayerEditor.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/renderIntlayerEditor.tsx"],"sourcesContent":["import type {\n IntlayerEditorElementProps,\n RenderIntlayerEditorResult,\n} from 'intlayer-editor/client';\nimport type { FC } from 'react';\n\nconst requireFunction = () => {\n try {\n return typeof import.meta.url === 'undefined'\n ? require('intlayer-editor/client')\n : module.require('intlayer-editor/client');\n } catch (error) {\n return undefined;\n }\n};\n\nconst IntlayerEditorElement: FC<IntlayerEditorElementProps> = ({\n content,\n ..._props\n}) => content;\n\nexport const renderIntlayerEditor = (\n props: IntlayerEditorElementProps\n): RenderIntlayerEditorResult => {\n const _renderIntlayerEditor = requireFunction()?.renderIntlayerEditor;\n\n if (typeof _renderIntlayerEditor === 'undefined') {\n const Result = <IntlayerEditorElement {...props} />;\n\n return { ...Result, value: props.content };\n }\n\n return _renderIntlayerEditor(props);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BmB;AA3BnB;AAMA,MAAM,kBAAkB,MAAM;AAC5B,MAAI;AACF,WAAO,OAAO,YAAY,QAAQ,cAC9B,QAAQ,wBAAwB,IAChC,OAAO,QAAQ,wBAAwB;AAAA,EAC7C,SAAS,OAAO;AACd,WAAO;AAAA,EACT;AACF;AAEA,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA,GAAG;AACL,MAAM;AAEC,MAAM,uBAAuB,CAClC,UAC+B;AAC/B,QAAM,wBAAwB,gBAAgB,GAAG;AAEjD,MAAI,OAAO,0BAA0B,aAAa;AAChD,UAAM,SAAS,4CAAC,yBAAuB,GAAG,OAAO;AAEjD,WAAO,EAAE,GAAG,QAAQ,OAAO,MAAM,QAAQ;AAAA,EAC3C;AAEA,SAAO,sBAAsB,KAAK;AACpC;","names":[]}
@@ -1,5 +0,0 @@
1
- import { IntlayerEditorElementProps, RenderIntlayerEditorResult } from 'intlayer-editor/client';
2
-
3
- declare const renderIntlayerEditor: (props: IntlayerEditorElementProps) => RenderIntlayerEditorResult;
4
-
5
- export { renderIntlayerEditor };
@@ -1,6 +0,0 @@
1
- import { ContentEditionLayoutProps } from 'intlayer-editor/client';
2
- import { FC } from 'react';
3
-
4
- declare const ContentEditionLayout: FC<ContentEditionLayoutProps>;
5
-
6
- export { ContentEditionLayout };
@@ -1,15 +0,0 @@
1
- import "../chunk-ZD7AOCMD.mjs";
2
- import { Fragment, jsx } from "react/jsx-runtime";
3
- const BlankLayout = ({ children }) => /* @__PURE__ */ jsx(Fragment, { children });
4
- const requireFunction = () => {
5
- try {
6
- return typeof import.meta.url === "undefined" ? require("intlayer-editor/client") : module.require("intlayer-editor/client");
7
- } catch (error) {
8
- return void 0;
9
- }
10
- };
11
- const ContentEditionLayout = typeof requireFunction()?.ContentEditionLayoutBase === "undefined" ? BlankLayout : requireFunction().ContentEditionLayoutBase;
12
- export {
13
- ContentEditionLayout
14
- };
15
- //# sourceMappingURL=ContentEditionLayout.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import type { ContentEditionLayoutProps } from 'intlayer-editor/client';\nimport type { FC } from 'react';\n\nconst BlankLayout: FC<ContentEditionLayoutProps> = ({ children }) => (\n <>{children}</>\n);\n\nconst requireFunction = () => {\n try {\n return typeof import.meta.url === 'undefined'\n ? require('intlayer-editor/client')\n : module.require('intlayer-editor/client');\n } catch (error) {\n return undefined;\n }\n};\n// intlayer-editor is an optional dependency. If it's not installed, return the blank layout\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> =\n typeof requireFunction()?.ContentEditionLayoutBase === 'undefined'\n ? BlankLayout\n : requireFunction().ContentEditionLayoutBase;\n"],"mappings":";AAIE;AADF,MAAM,cAA6C,CAAC,EAAE,SAAS,MAC7D,gCAAG,UAAS;AAGd,MAAM,kBAAkB,MAAM;AAC5B,MAAI;AACF,WAAO,OAAO,YAAY,QAAQ,cAC9B,QAAQ,wBAAwB,IAChC,OAAO,QAAQ,wBAAwB;AAAA,EAC7C,SAAS,OAAO;AACd,WAAO;AAAA,EACT;AACF;AAEO,MAAM,uBACX,OAAO,gBAAgB,GAAG,6BAA6B,cACnD,cACA,gBAAgB,EAAE;","names":[]}
@@ -1,5 +0,0 @@
1
- import { IntlayerEditorElementProps, RenderIntlayerEditorResult } from 'intlayer-editor/client';
2
-
3
- declare const renderIntlayerEditor: (props: IntlayerEditorElementProps) => RenderIntlayerEditorResult;
4
-
5
- export { renderIntlayerEditor };
@@ -1,25 +0,0 @@
1
- import "./chunk-ZD7AOCMD.mjs";
2
- import { jsx } from "react/jsx-runtime";
3
- const requireFunction = () => {
4
- try {
5
- return typeof import.meta.url === "undefined" ? require("intlayer-editor/client") : module.require("intlayer-editor/client");
6
- } catch (error) {
7
- return void 0;
8
- }
9
- };
10
- const IntlayerEditorElement = ({
11
- content,
12
- ..._props
13
- }) => content;
14
- const renderIntlayerEditor = (props) => {
15
- const _renderIntlayerEditor = requireFunction()?.renderIntlayerEditor;
16
- if (typeof _renderIntlayerEditor === "undefined") {
17
- const Result = /* @__PURE__ */ jsx(IntlayerEditorElement, { ...props });
18
- return { ...Result, value: props.content };
19
- }
20
- return _renderIntlayerEditor(props);
21
- };
22
- export {
23
- renderIntlayerEditor
24
- };
25
- //# sourceMappingURL=renderIntlayerEditor.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/renderIntlayerEditor.tsx"],"sourcesContent":["import type {\n IntlayerEditorElementProps,\n RenderIntlayerEditorResult,\n} from 'intlayer-editor/client';\nimport type { FC } from 'react';\n\nconst requireFunction = () => {\n try {\n return typeof import.meta.url === 'undefined'\n ? require('intlayer-editor/client')\n : module.require('intlayer-editor/client');\n } catch (error) {\n return undefined;\n }\n};\n\nconst IntlayerEditorElement: FC<IntlayerEditorElementProps> = ({\n content,\n ..._props\n}) => content;\n\nexport const renderIntlayerEditor = (\n props: IntlayerEditorElementProps\n): RenderIntlayerEditorResult => {\n const _renderIntlayerEditor = requireFunction()?.renderIntlayerEditor;\n\n if (typeof _renderIntlayerEditor === 'undefined') {\n const Result = <IntlayerEditorElement {...props} />;\n\n return { ...Result, value: props.content };\n }\n\n return _renderIntlayerEditor(props);\n};\n"],"mappings":";AA2BmB;AArBnB,MAAM,kBAAkB,MAAM;AAC5B,MAAI;AACF,WAAO,OAAO,YAAY,QAAQ,cAC9B,QAAQ,wBAAwB,IAChC,OAAO,QAAQ,wBAAwB;AAAA,EAC7C,SAAS,OAAO;AACd,WAAO;AAAA,EACT;AACF;AAEA,MAAM,wBAAwD,CAAC;AAAA,EAC7D;AAAA,EACA,GAAG;AACL,MAAM;AAEC,MAAM,uBAAuB,CAClC,UAC+B;AAC/B,QAAM,wBAAwB,gBAAgB,GAAG;AAEjD,MAAI,OAAO,0BAA0B,aAAa;AAChD,UAAM,SAAS,oBAAC,yBAAuB,GAAG,OAAO;AAEjD,WAAO,EAAE,GAAG,QAAQ,OAAO,MAAM,QAAQ;AAAA,EAC3C;AAEA,SAAO,sBAAsB,KAAK;AACpC;","names":[]}