react-intlayer 4.0.3 → 4.0.4

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 (58) hide show
  1. package/dist/cjs/client/PoweredByMeta.cjs +9 -4
  2. package/dist/cjs/client/PoweredByMeta.cjs.map +1 -1
  3. package/dist/cjs/editor/ContentSelectorWrapper.cjs +15 -3
  4. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
  5. package/dist/cjs/editor/IntlayerEditorProvider.cjs +38 -8
  6. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
  7. package/dist/cjs/editor/renderContentEditor.cjs +3 -23
  8. package/dist/cjs/editor/renderContentEditor.cjs.map +1 -1
  9. package/dist/cjs/getDictionary.cjs +4 -31
  10. package/dist/cjs/getDictionary.cjs.map +1 -1
  11. package/dist/cjs/getIntlayer.cjs +2 -2
  12. package/dist/cjs/getIntlayer.cjs.map +1 -1
  13. package/dist/cjs/getIntlayerAsync.cjs +2 -2
  14. package/dist/cjs/getIntlayerAsync.cjs.map +1 -1
  15. package/dist/cjs/recursiveTransformContent.cjs +54 -0
  16. package/dist/cjs/recursiveTransformContent.cjs.map +1 -0
  17. package/dist/esm/client/PoweredByMeta.mjs +9 -4
  18. package/dist/esm/client/PoweredByMeta.mjs.map +1 -1
  19. package/dist/esm/editor/ContentSelectorWrapper.mjs +20 -7
  20. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
  21. package/dist/esm/editor/IntlayerEditorProvider.mjs +36 -10
  22. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
  23. package/dist/esm/editor/renderContentEditor.mjs +6 -24
  24. package/dist/esm/editor/renderContentEditor.mjs.map +1 -1
  25. package/dist/esm/getDictionary.mjs +4 -30
  26. package/dist/esm/getDictionary.mjs.map +1 -1
  27. package/dist/esm/getIntlayer.mjs +2 -2
  28. package/dist/esm/getIntlayer.mjs.map +1 -1
  29. package/dist/esm/getIntlayerAsync.mjs +1 -1
  30. package/dist/esm/getIntlayerAsync.mjs.map +1 -1
  31. package/dist/esm/recursiveTransformContent.mjs +32 -0
  32. package/dist/esm/recursiveTransformContent.mjs.map +1 -0
  33. package/dist/types/client/PoweredByMeta.d.ts.map +1 -1
  34. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
  35. package/dist/types/editor/IntlayerEditorProvider.d.ts +1 -1
  36. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
  37. package/dist/types/editor/renderContentEditor.d.ts +5 -9
  38. package/dist/types/editor/renderContentEditor.d.ts.map +1 -1
  39. package/dist/types/getDictionary.d.ts +3 -25
  40. package/dist/types/getDictionary.d.ts.map +1 -1
  41. package/dist/types/getIntlayer.d.ts +3 -3
  42. package/dist/types/getIntlayer.d.ts.map +1 -1
  43. package/dist/types/getIntlayerAsync.d.ts.map +1 -1
  44. package/dist/types/recursiveTransformContent.d.ts +27 -0
  45. package/dist/types/recursiveTransformContent.d.ts.map +1 -0
  46. package/package.json +15 -14
  47. package/dist/cjs/UI/PressableSpan/index.cjs +0 -23
  48. package/dist/cjs/UI/PressableSpan/index.cjs.map +0 -1
  49. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +0 -59
  50. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +0 -1
  51. package/dist/esm/UI/PressableSpan/index.mjs +0 -2
  52. package/dist/esm/UI/PressableSpan/index.mjs.map +0 -1
  53. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +0 -35
  54. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +0 -1
  55. package/dist/types/UI/PressableSpan/index.d.ts +0 -2
  56. package/dist/types/UI/PressableSpan/index.d.ts.map +0 -1
  57. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +0 -6
  58. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +0 -1
@@ -1,28 +1,10 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { getConfiguration } from "@intlayer/config/client";
3
- import { ContentSelectorWrapper } from './ContentSelectorWrapper.mjs';
4
- const {
5
- editor: { enabled }
6
- } = getConfiguration();
7
- const IntlayerEditorElement = ({
8
- content,
9
- isContentSelectable,
10
- ...props
11
- }) => {
12
- if (enabled && isContentSelectable) {
13
- return /* @__PURE__ */ jsx(ContentSelectorWrapper, { ...props, children: content });
14
- }
15
- return content;
16
- };
17
- const renderIntlayerEditor = (data, isContentSelectable = true) => {
18
- const Result = /* @__PURE__ */ jsx(
19
- IntlayerEditorElement,
20
- {
21
- ...data,
22
- isContentSelectable
23
- }
24
- );
25
- return { ...Result, value: data.content };
2
+ import {
3
+ ContentSelectorWrapper
4
+ } from './ContentSelectorWrapper.mjs';
5
+ const renderIntlayerEditor = (props) => {
6
+ const Result = /* @__PURE__ */ jsx(ContentSelectorWrapper, { ...props, children: props.content });
7
+ return { ...Result, value: props.content };
26
8
  };
27
9
  export {
28
10
  renderIntlayerEditor
@@ -1 +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 { ContentSelectorWrapper } from './ContentSelectorWrapper';\n\nconst {\n editor: { enabled },\n} = getConfiguration();\n\nexport type IntlayerEditorElementProps = {\n content: string;\n dictionaryKey: 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 <ContentSelectorWrapper {...props}>{content}</ContentSelectorWrapper>\n );\n }\n return content;\n};\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\nexport const renderIntlayerEditor = (\n data: IntlayerEditorElementProps,\n isContentSelectable = true\n): IntlayerNode => {\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,8BAA8B;AAEvC,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,0BAAwB,GAAG,OAAQ,mBAAQ;AAAA,EAEhD;AACA,SAAO;AACT;AAMO,MAAM,uBAAuB,CAClC,MACA,sBAAsB,SACL;AACjB,QAAM,SACJ;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA;AAAA,EACF;AAGF,SAAO,EAAE,GAAG,QAAQ,OAAO,KAAK,QAAQ;AAC1C;","names":[]}
1
+ {"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport {\n ContentSelectorWrapper,\n type ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\nexport type RenderIntlayerEditorProps = Omit<\n ContentSelectorWrapperProps,\n 'children'\n> & {\n content: string;\n};\n\nexport const renderIntlayerEditor = (\n props: RenderIntlayerEditorProps\n): IntlayerNode => {\n const Result = (\n <ContentSelectorWrapper {...props}>{props.content}</ContentSelectorWrapper>\n );\n\n return { ...Result, value: props.content };\n};\n"],"mappings":"AAqBI;AApBJ;AAAA,EACE;AAAA,OAEK;AAaA,MAAM,uBAAuB,CAClC,UACiB;AACjB,QAAM,SACJ,oBAAC,0BAAwB,GAAG,OAAQ,gBAAM,SAAQ;AAGpD,SAAO,EAAE,GAAG,QAAQ,OAAO,MAAM,QAAQ;AAC3C;","names":[]}
@@ -1,32 +1,7 @@
1
- import { isValidElement } from "react";
2
- import {
3
- renderIntlayerEditor
4
- } from './editor/renderContentEditor.mjs';
5
1
  import { processDictionary } from './processDictionary/index.mjs';
6
- const recursiveTransformContent = (value, isRenderEditor = false) => {
7
- if (typeof value === "function") {
8
- return (props) => recursiveTransformContent(value(props), isRenderEditor);
9
- } else if (typeof value === "object") {
10
- if (typeof value.dictionaryKey !== "undefined") {
11
- if (isRenderEditor) {
12
- return renderIntlayerEditor(value);
13
- }
14
- return value.content;
15
- } else if (Array.isArray(value)) {
16
- return value.map((el) => recursiveTransformContent(el, isRenderEditor));
17
- } else if (isValidElement(value)) {
18
- return value;
19
- }
20
- return Object.entries(value).reduce(
21
- (acc, [key, value2]) => ({
22
- ...acc,
23
- [key]: recursiveTransformContent(value2, isRenderEditor)
24
- }),
25
- {}
26
- );
27
- }
28
- return value;
29
- };
2
+ import {
3
+ recursiveTransformContent
4
+ } from './recursiveTransformContent.mjs';
30
5
  const getDictionary = (dictionary, locale, isRenderEditor = false) => {
31
6
  const result = processDictionary(
32
7
  dictionary.content,
@@ -41,7 +16,6 @@ const getDictionary = (dictionary, locale, isRenderEditor = false) => {
41
16
  );
42
17
  };
43
18
  export {
44
- getDictionary,
45
- recursiveTransformContent
19
+ getDictionary
46
20
  };
47
21
  //# sourceMappingURL=getDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getDictionary.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 {\n type IntlayerNode,\n renderIntlayerEditor,\n} from './editor/renderContentEditor';\nimport { processDictionary } from './processDictionary/index';\n\ntype TransformNodeType<T, L extends Locales, R extends boolean> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (\n quantity: number\n ) => DeepTransformContent<T[NodeType.Enumeration]['1'], L, R>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L, R>\n : never\n : T;\n\nexport type DeepTransformContent<\n T,\n L extends Locales,\n R extends boolean,\n> = 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, R>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L, R>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L, R>;\n }\n : T extends undefined\n ? never\n : R extends true\n ? IntlayerNode<T>\n : 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 isRenderEditor = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isRenderEditor);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryKey !== 'undefined') {\n if (isRenderEditor) {\n return renderIntlayerEditor(value);\n }\n return value.content;\n } else if (Array.isArray(value)) {\n return value.map((el) => recursiveTransformContent(el, isRenderEditor));\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, isRenderEditor),\n }),\n {} as object\n );\n }\n\n return value;\n};\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n R extends boolean = false,\n> = DeepTransformContent<T['content'], K, R>;\n\nexport type UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n R extends boolean = false,\n>(\n dictionary: T,\n locale?: L,\n isRenderEditor?: R\n) => DataFromDictionary<T, L, R>;\n\n/**\n * Hook that picks one dictionary by its id and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getDictionary: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n R extends boolean = false,\n>(\n dictionary: T,\n locale?: L,\n isRenderEditor: R = false as R\n) => {\n const result = processDictionary(\n dictionary.content as DictionaryValue,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isRenderEditor\n ) as DataFromDictionary<T, L, R>;\n};\n"],"mappings":"AAOA,SAAS,sBAAsC;AAC/C;AAAA,EAEE;AAAA,OACK;AACP,SAAS,yBAAyB;AAyC3B,MAAM,4BAA4B,CACvC,OACA,iBAAiB,UACN;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,cAAc;AAAA,EAC1D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,kBAAkB,aAAa;AAC9C,UAAI,gBAAgB;AAClB,eAAO,qBAAqB,KAAK;AAAA,MACnC;AACA,aAAO,MAAM;AAAA,IACf,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM,IAAI,CAAC,OAAO,0BAA0B,IAAI,cAAc,CAAC;AAAA,IACxE,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,cAAc;AAAA,MACxD;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAuBO,MAAM,gBAA+B,CAK1C,YACA,QACA,iBAAoB,UACjB;AACH,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["value"]}
1
+ {"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { DeclarationContent, DictionaryValue } from '@intlayer/core';\nimport { processDictionary } from './processDictionary/index';\nimport {\n DeepTransformContent,\n recursiveTransformContent,\n} from './recursiveTransformContent';\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n R extends boolean = false,\n> = DeepTransformContent<T['content'], K, R>;\n\nexport type UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n R extends boolean = false,\n>(\n dictionary: T,\n locale?: L,\n isRenderEditor?: R,\n isContentSelectable?: boolean\n) => DataFromDictionary<T, L, R>;\n\n/**\n * Hook that picks one dictionary by its id and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getDictionary: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n R extends boolean = false,\n>(\n dictionary: T,\n locale?: L,\n isRenderEditor: R = false as R\n) => {\n const result = processDictionary(\n dictionary.content as DictionaryValue,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isRenderEditor\n ) as DataFromDictionary<T, L, R>;\n};\n"],"mappings":"AAEA,SAAS,yBAAyB;AAClC;AAAA,EAEE;AAAA,OACK;AAwBA,MAAM,gBAA+B,CAK1C,YACA,QACA,iBAAoB,UACjB;AACH,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1,8 +1,8 @@
1
1
  import dictionaries from "@intlayer/dictionaries-entry";
2
+ import { processDictionary } from './processDictionary/index.mjs';
2
3
  import {
3
4
  recursiveTransformContent
4
- } from './getDictionary.mjs';
5
- import { processDictionary } from './processDictionary/index.mjs';
5
+ } from './recursiveTransformContent.mjs';
6
6
  const getIntlayer = (key, locale, isRenderEditor = false) => {
7
7
  const dictionary = dictionaries[key];
8
8
  if (!dictionary) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport {\n type DeepTransformContent,\n recursiveTransformContent,\n} from './getDictionary';\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\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\nexport type DataFromDictionaryKey<\n T extends DictionaryKeys,\n K extends Locales,\n R extends boolean = false,\n> = DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content'], K, R>;\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = false,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => DataFromDictionaryKey<T, L, R>;\n\nexport type UseIntlayerEditable = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => DataFromDictionaryKey<T, L, R>;\n\nexport const getIntlayer: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = false,\n>(\n key: T,\n locale?: L,\n isRenderEditor: R = false as R\n) => {\n const dictionary: Dictionary = dictionaries[key as keyof typeof dictionaries];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key} not found`, dictionaries);\n }\n\n const result = processDictionary(\n dictionary.content,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isRenderEditor\n ) as DataFromDictionaryKey<T, L, R>;\n};\n"],"mappings":"AAOA,OAAO,kBAAkB;AAEzB;AAAA,EAEE;AAAA,OACK;AACP,SAAS,yBAAyB;AA2D3B,MAAM,cAA2B,CAKtC,KACA,QACA,iBAAoB,UACjB;AACH,QAAM,aAAyB,aAAa,GAAgC;AAE5E,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,cAAc,GAAG,cAAc,YAAY;AAAA,EAC7D;AAEA,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { processDictionary } from './processDictionary/index';\nimport {\n type DeepTransformContent,\n recursiveTransformContent,\n} from './recursiveTransformContent';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\n */\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\nexport type DataFromDictionaryKey<\n T extends DictionaryKeys,\n K extends Locales,\n R extends boolean = false,\n> = DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content'], K, R>;\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = false,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R,\n isContentSelectable?: boolean\n) => DataFromDictionaryKey<T, L, R>;\n\nexport type UseIntlayerEditable = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R,\n isContentSelectable?: boolean\n) => DataFromDictionaryKey<T, L, R>;\n\nexport const getIntlayer: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = false,\n>(\n key: T,\n locale?: L,\n isRenderEditor: R = false as R\n) => {\n const dictionary: Dictionary = dictionaries[key as keyof typeof dictionaries];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key} not found`, dictionaries);\n }\n\n const result = processDictionary(\n dictionary.content,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isRenderEditor\n ) as DataFromDictionaryKey<T, L, R>;\n};\n"],"mappings":"AAOA,OAAO,kBAAkB;AAEzB,SAAS,yBAAyB;AAClC;AAAA,EAEE;AAAA,OACK;AA6DA,MAAM,cAA2B,CAKtC,KACA,QACA,iBAAoB,UACjB;AACH,QAAM,aAAyB,aAAa,GAAgC;AAE5E,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,cAAc,GAAG,cAAc,YAAY;AAAA,EAC7D;AAEA,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { fetchDistantDictionary } from './distantDictionary/fetchDistantDictionary.mjs';
2
+ import { fetchDistantDictionary } from "@intlayer/api";
3
3
  import { getDictionary } from './getDictionary.mjs';
4
4
  const getIntlayerAsync = async (key, locale, isRenderEditor = true) => {
5
5
  const jsonDistantDictionary = await fetchDistantDictionary(key);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { DeclarationContent } from 'intlayer';\nimport { fetchDistantDictionary } from './distantDictionary/fetchDistantDictionary';\nimport { getDictionary } from './getDictionary';\nimport { DictionaryKeys, DataFromDictionaryKey } from './getIntlayer';\n\nexport type GetIntlayerAsync = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => Promise<DataFromDictionaryKey<T, L, R> | null>;\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getIntlayerAsync: GetIntlayerAsync = async <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor = true as R\n) => {\n const jsonDistantDictionary = await fetchDistantDictionary(key);\n\n if (jsonDistantDictionary) {\n return getDictionary(\n jsonDistantDictionary as unknown as DeclarationContent,\n locale,\n isRenderEditor\n ) as DataFromDictionaryKey<T, L, R>;\n }\n\n return null;\n};\n"],"mappings":";AAIA,SAAS,8BAA8B;AACvC,SAAS,qBAAqB;AAqBvB,MAAM,mBAAqC,OAKhD,KACA,QACA,iBAAiB,SACd;AACH,QAAM,wBAAwB,MAAM,uBAAuB,GAAG;AAE9D,MAAI,uBAAuB;AACzB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/getIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport { fetchDistantDictionary } from '@intlayer/api';\nimport type { Locales } from '@intlayer/config/client';\nimport { DeclarationContent } from 'intlayer';\nimport { getDictionary } from './getDictionary';\nimport { DictionaryKeys, DataFromDictionaryKey } from './getIntlayer';\n\nexport type GetIntlayerAsync = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => Promise<DataFromDictionaryKey<T, L, R> | null>;\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getIntlayerAsync: GetIntlayerAsync = async <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor = true as R\n) => {\n const jsonDistantDictionary = await fetchDistantDictionary(key);\n\n if (jsonDistantDictionary) {\n return getDictionary(\n jsonDistantDictionary as unknown as DeclarationContent,\n locale,\n isRenderEditor\n ) as DataFromDictionaryKey<T, L, R>;\n }\n\n return null;\n};\n"],"mappings":";AAEA,SAAS,8BAA8B;AAGvC,SAAS,qBAAqB;AAqBvB,MAAM,mBAAqC,OAKhD,KACA,QACA,iBAAiB,SACd;AACH,QAAM,wBAAwB,MAAM,uBAAuB,GAAG;AAE9D,MAAI,uBAAuB;AACzB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,32 @@
1
+ import { isValidElement } from "react";
2
+ import {
3
+ renderIntlayerEditor
4
+ } from './editor/renderContentEditor.mjs';
5
+ const recursiveTransformContent = (value, isRenderEditor = false) => {
6
+ if (typeof value === "function") {
7
+ return (props) => recursiveTransformContent(value(props), isRenderEditor);
8
+ } else if (typeof value === "object") {
9
+ if (typeof value.dictionaryKey !== "undefined") {
10
+ if (isRenderEditor) {
11
+ return renderIntlayerEditor(value);
12
+ }
13
+ return value.content;
14
+ } else if (Array.isArray(value)) {
15
+ return value.map((el) => recursiveTransformContent(el, isRenderEditor));
16
+ } else if (isValidElement(value)) {
17
+ return value;
18
+ }
19
+ return Object.entries(value).reduce(
20
+ (acc, [key, value2]) => ({
21
+ ...acc,
22
+ [key]: recursiveTransformContent(value2, isRenderEditor)
23
+ }),
24
+ {}
25
+ );
26
+ }
27
+ return value;
28
+ };
29
+ export {
30
+ recursiveTransformContent
31
+ };
32
+ //# sourceMappingURL=recursiveTransformContent.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/recursiveTransformContent.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type { NodeType } from '@intlayer/core';\nimport { isValidElement, type ReactNode } from 'react';\nimport {\n type IntlayerNode,\n renderIntlayerEditor,\n} from './editor/renderContentEditor';\n\ntype TransformNodeType<T, L extends Locales, R extends boolean> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (\n quantity: number\n ) => DeepTransformContent<T[NodeType.Enumeration]['1'], L, R>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L, R>\n : never\n : T;\n\nexport type DeepTransformContent<\n T,\n L extends Locales,\n R extends boolean,\n> = 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, R>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L, R>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L, R>;\n }\n : T extends undefined\n ? never\n : R extends true\n ? IntlayerNode<T>\n : 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 isRenderEditor = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isRenderEditor);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryKey !== 'undefined') {\n if (isRenderEditor) {\n return renderIntlayerEditor(value);\n }\n return value.content;\n } else if (Array.isArray(value)) {\n return value.map((el) => recursiveTransformContent(el, isRenderEditor));\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, isRenderEditor),\n }),\n {} as object\n );\n }\n\n return value;\n};\n"],"mappings":"AAGA,SAAS,sBAAsC;AAC/C;AAAA,EAEE;AAAA,OACK;AAyCA,MAAM,4BAA4B,CACvC,OACA,iBAAiB,UACN;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,cAAc;AAAA,EAC1D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,kBAAkB,aAAa;AAC9C,UAAI,gBAAgB;AAClB,eAAO,qBAAqB,KAAK;AAAA,MACnC;AACA,aAAO,MAAM;AAAA,IACf,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM,IAAI,CAAC,OAAO,0BAA0B,IAAI,cAAc,CAAC;AAAA,IACxE,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,cAAc;AAAA,MACxD;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":["value"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PoweredByMeta.d.ts","sourceRoot":"","sources":["../../../src/client/PoweredByMeta.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAa,MAAM,OAAO,CAAC;AAE3C,eAAO,MAAM,aAAa,EAAE,EAW3B,CAAC"}
1
+ {"version":3,"file":"PoweredByMeta.d.ts","sourceRoot":"","sources":["../../../src/client/PoweredByMeta.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAa,MAAM,OAAO,CAAC;AAE3C,eAAO,MAAM,aAAa,EAAE,EAkB3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAKL,KAAK,EAAE,EAEP,cAAc,EACf,MAAM,OAAO,CAAC;AAOf,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,WAAW,GACnD,cAAc,CAAC,cAAc,CAAC,CAAC;AAEjC,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAkDlE,CAAC"}
1
+ {"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAM7D,OAAO,EAKL,KAAK,EAAE,EAEP,cAAc,EACf,MAAM,OAAO,CAAC;AAGf,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,WAAW,GACnD,cAAc,CAAC,cAAc,CAAC,CAAC;AAEjC,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CA4DlE,CAAC"}
@@ -1,3 +1,3 @@
1
- import { FC, PropsWithChildren } from 'react';
1
+ import { type FC, type PropsWithChildren } from 'react';
2
2
  export declare const IntlayerEditorProvider: FC<PropsWithChildren>;
3
3
  //# sourceMappingURL=IntlayerEditorProvider.d.ts.map
@@ -1 +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;AAQ9C,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAMxD,CAAC"}
1
+ {"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAa,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAqCnE,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAQxD,CAAC"}
@@ -1,14 +1,10 @@
1
- import type { KeyPath } from '@intlayer/core';
2
1
  import type { ReactNode } from 'react';
3
- export type IntlayerEditorElementProps = {
4
- content: string;
5
- dictionaryKey: string;
6
- dictionaryPath: string;
7
- keyPath: KeyPath[];
8
- isContentSelectable: boolean;
9
- };
2
+ import { type ContentSelectorWrapperProps } from './ContentSelectorWrapper';
10
3
  export type IntlayerNode<T = string> = ReactNode & {
11
4
  value: T;
12
5
  };
13
- export declare const renderIntlayerEditor: (data: IntlayerEditorElementProps, isContentSelectable?: boolean) => IntlayerNode;
6
+ export type RenderIntlayerEditorProps = Omit<ContentSelectorWrapperProps, 'children'> & {
7
+ content: string;
8
+ };
9
+ export declare const renderIntlayerEditor: (props: RenderIntlayerEditorProps) => IntlayerNode;
14
10
  //# sourceMappingURL=renderContentEditor.d.ts.map
@@ -1 +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,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAeF,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,MAAM,IAAI,SAAS,GAAG;IACjD,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,eAAO,MAAM,oBAAoB,SACzB,0BAA0B,oCAE/B,YASF,CAAC"}
1
+ {"version":3,"file":"renderContentEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/renderContentEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,MAAM,IAAI,SAAS,GAAG;IACjD,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,2BAA2B,EAC3B,UAAU,CACX,GAAG;IACF,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,oBAAoB,UACxB,yBAAyB,KAC/B,YAMF,CAAC"}
@@ -1,30 +1,8 @@
1
1
  import type { Locales } from '@intlayer/config';
2
- import type { DeclarationContent, NodeType } from '@intlayer/core';
3
- import { type ReactNode } from 'react';
4
- import { type IntlayerNode } from './editor/renderContentEditor';
5
- type TransformNodeType<T, L extends Locales, R extends boolean> = T extends {
6
- [NodeType.Enumeration]: {
7
- '1': any;
8
- };
9
- } ? (quantity: number) => DeepTransformContent<T[NodeType.Enumeration]['1'], L, R> : T extends {
10
- [NodeType.Translation]: object;
11
- } ? L extends keyof T[NodeType.Translation] ? DeepTransformContent<T[NodeType.Translation][L], L, R> : never : T;
12
- export type DeepTransformContent<T, L extends Locales, R extends boolean> = T extends object ? T extends (infer U)[] ? DeepTransformContent<U, L, R>[] : T extends {
13
- nodeType: NodeType | string;
14
- } ? TransformNodeType<T, L, R> : T extends {
15
- _owner: any;
16
- key: any;
17
- props: any;
18
- ref: any;
19
- } ? ReactNode : {
20
- [K in keyof T]: DeepTransformContent<T[K], L, R>;
21
- } : T extends undefined ? never : R extends true ? IntlayerNode<T> : T;
22
- /**
23
- * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.
24
- */
25
- export declare const recursiveTransformContent: (value: any, isRenderEditor?: boolean) => object;
2
+ import type { DeclarationContent } from '@intlayer/core';
3
+ import { DeepTransformContent } from './recursiveTransformContent';
26
4
  type DataFromDictionary<T extends DeclarationContent, K extends Locales, R extends boolean = false> = DeepTransformContent<T['content'], K, R>;
27
- export type UseDictionary = <T extends DeclarationContent, L extends Locales, R extends boolean = false>(dictionary: T, locale?: L, isRenderEditor?: R) => DataFromDictionary<T, L, R>;
5
+ export type UseDictionary = <T extends DeclarationContent, L extends Locales, R extends boolean = false>(dictionary: T, locale?: L, isRenderEditor?: R, isContentSelectable?: boolean) => DataFromDictionary<T, L, R>;
28
6
  /**
29
7
  * Hook that picks one dictionary by its id and return the content
30
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../src/getDictionary.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;AACvD,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,8BAA8B,CAAC;AAGtC,KAAK,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS;IAC1E,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,GAAG,CAAA;KAAE,CAAC;CACtC,GACG,CACE,QAAQ,EAAE,MAAM,KACb,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC7D,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,EAAE,CAAC,CAAC,GACtD,KAAK,GACP,CAAC,CAAC;AAER,MAAM,MAAM,oBAAoB,CAC9B,CAAC,EACD,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,SAAS,MAAM,GAChB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACnB,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAC/B,CAAC,SAAS;IACN,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC7B,GACD,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC1B,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,EAAE,CAAC,CAAC;CACjD,GACP,CAAC,SAAS,SAAS,GACjB,KAAK,GACL,CAAC,SAAS,IAAI,GACZ,YAAY,CAAC,CAAC,CAAC,GACf,CAAC,CAAC;AAEV;;GAEG;AACH,eAAO,MAAM,yBAAyB,UAC7B,GAAG,+BAET,MA0BF,CAAC;AAEF,KAAK,kBAAkB,CACrB,CAAC,SAAS,kBAAkB,EAC5B,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,KAAK,IACvB,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG,CAC1B,CAAC,SAAS,kBAAkB,EAC5B,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,KAAK,EAEzB,UAAU,EAAE,CAAC,EACb,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,KACf,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEjC;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,aAqB3B,CAAC"}
1
+ {"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../src/getDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EACL,oBAAoB,EAErB,MAAM,6BAA6B,CAAC;AAErC,KAAK,kBAAkB,CACrB,CAAC,SAAS,kBAAkB,EAC5B,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,KAAK,IACvB,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG,CAC1B,CAAC,SAAS,kBAAkB,EAC5B,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,KAAK,EAEzB,UAAU,EAAE,CAAC,EACb,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,EAClB,mBAAmB,CAAC,EAAE,OAAO,KAC1B,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEjC;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,aAqB3B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { Locales } from '@intlayer/config';
2
2
  import type { IntlayerDictionaryTypesConnector } from 'intlayer';
3
- import { type DeepTransformContent } from './getDictionary';
3
+ import { type DeepTransformContent } from './recursiveTransformContent';
4
4
  /**
5
5
  * Provides a fallback to string type if the generic type T is never,
6
6
  * otherwise returns T. This is useful for handling cases where no keys are found.
@@ -29,7 +29,7 @@ export type DataFromDictionaryKey<T extends DictionaryKeys, K extends Locales, R
29
29
  * and returns the deeply transformed dictionary content.
30
30
  *
31
31
  */
32
- export type UseIntlayer = <T extends DictionaryKeys, L extends Locales, R extends boolean = false>(key: T, locale?: L, isRenderEditor?: R) => DataFromDictionaryKey<T, L, R>;
33
- export type UseIntlayerEditable = <T extends DictionaryKeys, L extends Locales, R extends boolean = true>(key: T, locale?: L, isRenderEditor?: R) => DataFromDictionaryKey<T, L, R>;
32
+ export type UseIntlayer = <T extends DictionaryKeys, L extends Locales, R extends boolean = false>(key: T, locale?: L, isRenderEditor?: R, isContentSelectable?: boolean) => DataFromDictionaryKey<T, L, R>;
33
+ export type UseIntlayerEditable = <T extends DictionaryKeys, L extends Locales, R extends boolean = true>(key: T, locale?: L, isRenderEditor?: R, isContentSelectable?: boolean) => DataFromDictionaryKey<T, L, R>;
34
34
  export declare const getIntlayer: UseIntlayer;
35
35
  //# sourceMappingURL=getIntlayer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.d.ts","sourceRoot":"","sources":["../../src/getIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAQhD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,iBAAiB,CAAC;AAGzB;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,CACzC,MAAM,gCAAgC,CACvC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,qBAAqB,CAC/B,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,KAAK,IACvB,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,KAAK,EAEzB,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,KACf,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpC,MAAM,MAAM,mBAAmB,GAAG,CAChC,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,IAAI,EAExB,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,KACf,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpC,eAAO,MAAM,WAAW,EAAE,WA2BzB,CAAC"}
1
+ {"version":3,"file":"getIntlayer.d.ts","sourceRoot":"","sources":["../../src/getIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAQhD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAEjE,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,6BAA6B,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,CACzC,MAAM,gCAAgC,CACvC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,qBAAqB,CAC/B,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,KAAK,IACvB,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,KAAK,EAEzB,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,EAClB,mBAAmB,CAAC,EAAE,OAAO,KAC1B,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpC,MAAM,MAAM,mBAAmB,GAAG,CAChC,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,IAAI,EAExB,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,EAClB,mBAAmB,CAAC,EAAE,OAAO,KAC1B,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpC,eAAO,MAAM,WAAW,EAAE,WA2BzB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayerAsync.d.ts","sourceRoot":"","sources":["../../src/getIntlayerAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIvD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG,CAC7B,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,IAAI,EAExB,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,KACf,OAAO,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAoB9B,CAAC"}
1
+ {"version":3,"file":"getIntlayerAsync.d.ts","sourceRoot":"","sources":["../../src/getIntlayerAsync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG,CAC7B,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,IAAI,EAExB,GAAG,EAAE,CAAC,EACN,MAAM,CAAC,EAAE,CAAC,EACV,cAAc,CAAC,EAAE,CAAC,KACf,OAAO,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAoB9B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Locales } from '@intlayer/config';
2
+ import type { NodeType } from '@intlayer/core';
3
+ import { type ReactNode } from 'react';
4
+ import { type IntlayerNode } from './editor/renderContentEditor';
5
+ type TransformNodeType<T, L extends Locales, R extends boolean> = T extends {
6
+ [NodeType.Enumeration]: {
7
+ '1': any;
8
+ };
9
+ } ? (quantity: number) => DeepTransformContent<T[NodeType.Enumeration]['1'], L, R> : T extends {
10
+ [NodeType.Translation]: object;
11
+ } ? L extends keyof T[NodeType.Translation] ? DeepTransformContent<T[NodeType.Translation][L], L, R> : never : T;
12
+ export type DeepTransformContent<T, L extends Locales, R extends boolean> = T extends object ? T extends (infer U)[] ? DeepTransformContent<U, L, R>[] : T extends {
13
+ nodeType: NodeType | string;
14
+ } ? TransformNodeType<T, L, R> : T extends {
15
+ _owner: any;
16
+ key: any;
17
+ props: any;
18
+ ref: any;
19
+ } ? ReactNode : {
20
+ [K in keyof T]: DeepTransformContent<T[K], L, R>;
21
+ } : T extends undefined ? never : R extends true ? IntlayerNode<T> : T;
22
+ /**
23
+ * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.
24
+ */
25
+ export declare const recursiveTransformContent: (value: any, isRenderEditor?: boolean) => object;
26
+ export {};
27
+ //# sourceMappingURL=recursiveTransformContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recursiveTransformContent.d.ts","sourceRoot":"","sources":["../../src/recursiveTransformContent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,8BAA8B,CAAC;AAEtC,KAAK,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS;IAC1E,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,GAAG,CAAA;KAAE,CAAC;CACtC,GACG,CACE,QAAQ,EAAE,MAAM,KACb,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC7D,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,EAAE,CAAC,CAAC,GACtD,KAAK,GACP,CAAC,CAAC;AAER,MAAM,MAAM,oBAAoB,CAC9B,CAAC,EACD,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,SAAS,MAAM,GAChB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACnB,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAC/B,CAAC,SAAS;IACN,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC7B,GACD,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC1B,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,EAAE,CAAC,CAAC;CACjD,GACP,CAAC,SAAS,SAAS,GACjB,KAAK,GACL,CAAC,SAAS,IAAI,GACZ,YAAY,CAAC,CAAC,CAAC,GACf,CAAC,CAAC;AAEV;;GAEG;AACH,eAAO,MAAM,yBAAyB,UAC7B,GAAG,+BAET,MA0BF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -71,11 +71,11 @@
71
71
  ],
72
72
  "dependencies": {
73
73
  "js-cookie": "^3.0.5",
74
- "@intlayer/core": "4.0.3",
75
- "@intlayer/config": "4.0.3",
76
- "@intlayer/dictionaries-entry": "4.0.3",
77
- "@intlayer/api": "4.0.3",
78
- "@intlayer/editor-react": "4.0.3"
74
+ "@intlayer/editor-react": "4.0.4",
75
+ "@intlayer/core": "4.0.4",
76
+ "@intlayer/api": "4.0.4",
77
+ "@intlayer/config": "4.0.4",
78
+ "@intlayer/dictionaries-entry": "4.0.4"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@craco/types": "^7.1.0",
@@ -92,21 +92,22 @@
92
92
  "tsc-alias": "^1.8.10",
93
93
  "tsup": "^8.3.5",
94
94
  "typescript": "^5.7.3",
95
- "@intlayer/backend": "4.0.3",
95
+ "@intlayer/backend": "4.0.4",
96
96
  "@utils/ts-config": "1.0.4",
97
97
  "@utils/eslint-config": "1.0.4",
98
- "@utils/tsup-config": "1.0.4",
99
- "@utils/ts-config-types": "1.0.4"
98
+ "@utils/ts-config-types": "1.0.4",
99
+ "@utils/tsup-config": "1.0.4"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "react": ">=16.0.0",
103
103
  "react-dom": ">=16.0.0",
104
104
  "vite": ">=4.0.0",
105
- "@intlayer/config": "4.0.3",
106
- "@intlayer/dictionaries-entry": "4.0.3",
107
- "@intlayer/core": "4.0.3",
108
- "intlayer": "4.0.3",
109
- "@intlayer/editor-react": "4.0.3"
105
+ "@intlayer/api": "4.0.4",
106
+ "@intlayer/dictionaries-entry": "4.0.4",
107
+ "@intlayer/core": "4.0.4",
108
+ "intlayer": "4.0.4",
109
+ "@intlayer/config": "4.0.4",
110
+ "@intlayer/editor-react": "4.0.4"
110
111
  },
111
112
  "engines": {
112
113
  "node": ">=14.18"
@@ -1,23 +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 __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 PressableSpan_exports = {};
17
- module.exports = __toCommonJS(PressableSpan_exports);
18
- __reExport(PressableSpan_exports, require('../ContentSelector.cjs'), module.exports);
19
- // Annotate the CommonJS export names for ESM import in node:
20
- 0 && (module.exports = {
21
- ...require('../ContentSelector.cjs')
22
- });
23
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/UI/PressableSpan/index.ts"],"sourcesContent":["export * from '../ContentSelector';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kCAAc,+BAAd;","names":[]}
@@ -1,59 +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 fetchDistantDictionary_exports = {};
20
- __export(fetchDistantDictionary_exports, {
21
- fetchDistantDictionary: () => fetchDistantDictionary
22
- });
23
- module.exports = __toCommonJS(fetchDistantDictionary_exports);
24
- var import_api = require("@intlayer/api");
25
- var import_client = require("@intlayer/config/client");
26
- const fetchDistantDictionary = async (dictionaryKey) => {
27
- try {
28
- const config = (0, import_client.getConfiguration)();
29
- const { clientId, clientSecret } = config.editor;
30
- const intlayerAPI = (0, import_api.getIntlayerAPI)(void 0, config);
31
- if (!clientId || !clientSecret) {
32
- throw new Error(
33
- "Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
34
- );
35
- }
36
- const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();
37
- const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
38
- const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(
39
- dictionaryKey,
40
- void 0,
41
- {
42
- headers: { Authorization: `Bearer ${oAuth2AccessToken}` }
43
- }
44
- );
45
- const distantDictionary = getDictionaryResult.data;
46
- if (!distantDictionary) {
47
- throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
48
- }
49
- return distantDictionary;
50
- } catch (error) {
51
- console.error(error);
52
- return void 0;
53
- }
54
- };
55
- // Annotate the CommonJS export names for ESM import in node:
56
- 0 && (module.exports = {
57
- fetchDistantDictionary
58
- });
59
- //# sourceMappingURL=fetchDistantDictionary.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["import { getIntlayerAPI } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/client';\n// @ts-ignore @intlayer/design-system not build yet\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string\n): Promise<DictionaryAPI | undefined> => {\n try {\n const config = getConfiguration();\n const { clientId, clientSecret } = config.editor;\n const intlayerAPI = getIntlayerAPI(undefined, config);\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(\n dictionaryKey,\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n return distantDictionary;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA+B;AAG/B,oBAAiC;AAM1B,MAAM,yBAAyB,OACpC,kBACuC;AACvC,MAAI;AACF,UAAM,aAAS,gCAAiB;AAChC,UAAM,EAAE,UAAU,aAAa,IAAI,OAAO;AAC1C,UAAM,kBAAc,2BAAe,QAAW,MAAM;AAEpD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AAEtE,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,YAAY,WAAW;AAAA,MACvD;AAAA,MACA;AAAA,MACA;AAAA,QACE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,MAC1D;AAAA,IACF;AAEA,UAAM,oBAAoB,oBAAoB;AAE9C,QAAI,CAAC,mBAAmB;AACtB,YAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,IACnE;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,2 +0,0 @@
1
- export * from '../ContentSelector.mjs';
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/UI/PressableSpan/index.ts"],"sourcesContent":["export * from '../ContentSelector';\n"],"mappings":"AAAA,cAAc;","names":[]}
@@ -1,35 +0,0 @@
1
- import { getIntlayerAPI } from "@intlayer/api";
2
- import { getConfiguration } from "@intlayer/config/client";
3
- const fetchDistantDictionary = async (dictionaryKey) => {
4
- try {
5
- const config = getConfiguration();
6
- const { clientId, clientSecret } = config.editor;
7
- const intlayerAPI = getIntlayerAPI(void 0, config);
8
- if (!clientId || !clientSecret) {
9
- throw new Error(
10
- "Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project."
11
- );
12
- }
13
- const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();
14
- const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
15
- const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(
16
- dictionaryKey,
17
- void 0,
18
- {
19
- headers: { Authorization: `Bearer ${oAuth2AccessToken}` }
20
- }
21
- );
22
- const distantDictionary = getDictionaryResult.data;
23
- if (!distantDictionary) {
24
- throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
25
- }
26
- return distantDictionary;
27
- } catch (error) {
28
- console.error(error);
29
- return void 0;
30
- }
31
- };
32
- export {
33
- fetchDistantDictionary
34
- };
35
- //# sourceMappingURL=fetchDistantDictionary.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["import { getIntlayerAPI } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport { type DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/client';\n// @ts-ignore @intlayer/design-system not build yet\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string\n): Promise<DictionaryAPI | undefined> => {\n try {\n const config = getConfiguration();\n const { clientId, clientSecret } = config.editor;\n const intlayerAPI = getIntlayerAPI(undefined, config);\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Fetch the dictionary\n const getDictionaryResult = await intlayerAPI.dictionary.getDictionary(\n dictionaryKey,\n undefined,\n {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n }\n );\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n return distantDictionary;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":"AAAA,SAAS,sBAAsB;AAG/B,SAAS,wBAAwB;AAM1B,MAAM,yBAAyB,OACpC,kBACuC;AACvC,MAAI;AACF,UAAM,SAAS,iBAAiB;AAChC,UAAM,EAAE,UAAU,aAAa,IAAI,OAAO;AAC1C,UAAM,cAAc,eAAe,QAAW,MAAM;AAEpD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AAEtE,UAAM,oBAAoB,kBAAkB,MAAM;AAGlD,UAAM,sBAAsB,MAAM,YAAY,WAAW;AAAA,MACvD;AAAA,MACA;AAAA,MACA;AAAA,QACE,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,MAC1D;AAAA,IACF;AAEA,UAAM,oBAAoB,oBAAoB;AAE9C,QAAI,CAAC,mBAAmB;AACtB,YAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,IACnE;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,2 +0,0 @@
1
- export * from '../ContentSelector';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/UI/PressableSpan/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -1,6 +0,0 @@
1
- import { type DictionaryAPI } from '@intlayer/backend';
2
- /**
3
- * Fetch distant dictionary
4
- */
5
- export declare const fetchDistantDictionary: (dictionaryKey: string) => Promise<DictionaryAPI | undefined>;
6
- //# sourceMappingURL=fetchDistantDictionary.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchDistantDictionary.d.ts","sourceRoot":"","sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvD;;GAEG;AACH,eAAO,MAAM,sBAAsB,kBAClB,MAAM,KACpB,OAAO,CAAC,aAAa,GAAG,SAAS,CAoCnC,CAAC"}