react-intlayer 4.0.2 → 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.
- package/README.md +1 -1
- package/dist/cjs/UI/ContentSelector.cjs +126 -0
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -0
- package/dist/cjs/client/IntlayerProvider.cjs +5 -1
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/{utils/PoweredByMeta/index.cjs → client/PoweredByMeta.cjs} +10 -5
- package/dist/cjs/client/PoweredByMeta.cjs.map +1 -0
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +51 -2
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +41 -6
- package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +0 -2
- package/dist/cjs/editor/index.cjs.map +1 -1
- package/dist/cjs/editor/renderContentEditor.cjs +4 -24
- package/dist/cjs/editor/renderContentEditor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +4 -31
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +2 -2
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/getIntlayerAsync.cjs +2 -2
- package/dist/cjs/getIntlayerAsync.cjs.map +1 -1
- package/dist/cjs/recursiveTransformContent.cjs +54 -0
- package/dist/cjs/recursiveTransformContent.cjs.map +1 -0
- package/dist/esm/UI/ContentSelector.mjs +107 -0
- package/dist/esm/UI/ContentSelector.mjs.map +1 -0
- package/dist/esm/client/IntlayerProvider.mjs +6 -2
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/PoweredByMeta.mjs +21 -0
- package/dist/esm/client/PoweredByMeta.mjs.map +1 -0
- package/dist/esm/editor/ContentSelectorWrapper.mjs +60 -2
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs +38 -7
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
- package/dist/esm/editor/index.mjs +0 -1
- package/dist/esm/editor/index.mjs.map +1 -1
- package/dist/esm/editor/renderContentEditor.mjs +6 -24
- package/dist/esm/editor/renderContentEditor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +4 -30
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +2 -2
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/getIntlayerAsync.mjs +1 -1
- package/dist/esm/getIntlayerAsync.mjs.map +1 -1
- package/dist/esm/recursiveTransformContent.mjs +32 -0
- package/dist/esm/recursiveTransformContent.mjs.map +1 -0
- package/dist/types/UI/ContentSelector.d.ts +10 -0
- package/dist/types/UI/ContentSelector.d.ts.map +1 -0
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/{utils/PoweredByMeta/index.d.ts → client/PoweredByMeta.d.ts} +1 -1
- package/dist/types/client/PoweredByMeta.d.ts.map +1 -0
- package/dist/types/editor/ContentSelectorWrapper.d.ts +5 -3
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts +1 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
- package/dist/types/editor/index.d.ts +0 -1
- package/dist/types/editor/index.d.ts.map +1 -1
- package/dist/types/editor/renderContentEditor.d.ts +5 -9
- package/dist/types/editor/renderContentEditor.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +3 -25
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +3 -3
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/getIntlayerAsync.d.ts.map +1 -1
- package/dist/types/recursiveTransformContent.d.ts +27 -0
- package/dist/types/recursiveTransformContent.d.ts.map +1 -0
- package/package.json +16 -13
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +0 -59
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +0 -1
- package/dist/cjs/editor/ContentSelectorConnector.cjs +0 -58
- package/dist/cjs/editor/ContentSelectorConnector.cjs.map +0 -1
- package/dist/cjs/utils/PoweredByMeta/index.cjs.map +0 -1
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +0 -35
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +0 -1
- package/dist/esm/editor/ContentSelectorConnector.mjs +0 -38
- package/dist/esm/editor/ContentSelectorConnector.mjs.map +0 -1
- package/dist/esm/utils/PoweredByMeta/index.mjs +0 -16
- package/dist/esm/utils/PoweredByMeta/index.mjs.map +0 -1
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +0 -6
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +0 -1
- package/dist/types/editor/ContentSelectorConnector.d.ts +0 -14
- package/dist/types/editor/ContentSelectorConnector.d.ts.map +0 -1
- package/dist/types/utils/PoweredByMeta/index.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EACL,KAAK,iBAAiB,EAItB,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAKf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAGhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAwCtD,CAAC"}
|
|
@@ -0,0 +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,EAkB3B,CAAC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type KeyPath } from '@intlayer/core';
|
|
2
|
-
import { type
|
|
3
|
-
|
|
2
|
+
import { type FC, HTMLAttributes } from 'react';
|
|
3
|
+
type ContentData = {
|
|
4
4
|
dictionaryKey: string;
|
|
5
5
|
dictionaryPath: string;
|
|
6
6
|
keyPath: KeyPath[];
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export type ContentSelectorWrapperProps = ContentData & HTMLAttributes<HTMLDivElement>;
|
|
8
9
|
export declare const ContentSelectorWrapper: FC<ContentSelectorWrapperProps>;
|
|
10
|
+
export {};
|
|
9
11
|
//# sourceMappingURL=ContentSelectorWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelectorWrapper.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"names":[],"mappings":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerEditorProvider.d.ts","sourceRoot":"","sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"names":[],"mappings":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/editor/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/editor/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type { KeyPath } from '@intlayer/core';
|
|
2
1
|
import type { ReactNode } from 'react';
|
|
3
|
-
|
|
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
|
|
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":"
|
|
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
|
|
3
|
-
import {
|
|
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":"
|
|
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 './
|
|
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;
|
|
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":"
|
|
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,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intlayer",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"intlayer",
|
|
8
8
|
"data",
|
|
@@ -71,10 +71,11 @@
|
|
|
71
71
|
],
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"js-cookie": "^3.0.5",
|
|
74
|
-
"@intlayer/
|
|
75
|
-
"@intlayer/core": "4.0.
|
|
76
|
-
"@intlayer/
|
|
77
|
-
"@intlayer/
|
|
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"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
81
|
"@craco/types": "^7.1.0",
|
|
@@ -91,20 +92,22 @@
|
|
|
91
92
|
"tsc-alias": "^1.8.10",
|
|
92
93
|
"tsup": "^8.3.5",
|
|
93
94
|
"typescript": "^5.7.3",
|
|
94
|
-
"@intlayer/backend": "4.0.
|
|
95
|
+
"@intlayer/backend": "4.0.4",
|
|
95
96
|
"@utils/ts-config": "1.0.4",
|
|
97
|
+
"@utils/eslint-config": "1.0.4",
|
|
96
98
|
"@utils/ts-config-types": "1.0.4",
|
|
97
|
-
"@utils/tsup-config": "1.0.4"
|
|
98
|
-
"@utils/eslint-config": "1.0.4"
|
|
99
|
+
"@utils/tsup-config": "1.0.4"
|
|
99
100
|
},
|
|
100
101
|
"peerDependencies": {
|
|
101
102
|
"react": ">=16.0.0",
|
|
102
103
|
"react-dom": ">=16.0.0",
|
|
103
104
|
"vite": ">=4.0.0",
|
|
104
|
-
"@intlayer/
|
|
105
|
-
"@intlayer/dictionaries-entry": "4.0.
|
|
106
|
-
"intlayer": "4.0.
|
|
107
|
-
"
|
|
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"
|
|
108
111
|
},
|
|
109
112
|
"engines": {
|
|
110
113
|
"node": ">=14.18"
|
|
@@ -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> => {\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,kBAC2B;AAC3B,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,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var ContentSelectorConnector_exports = {};
|
|
21
|
-
__export(ContentSelectorConnector_exports, {
|
|
22
|
-
ContentSelectorConnector: () => ContentSelectorConnector,
|
|
23
|
-
ContentSelectorContext: () => ContentSelectorContext,
|
|
24
|
-
ContentSelectorProvider: () => ContentSelectorProvider,
|
|
25
|
-
useContentSelectorContext: () => useContentSelectorContext
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(ContentSelectorConnector_exports);
|
|
28
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
var import_react = require("react");
|
|
30
|
-
var import_ContentSelectorWrapper = require('./ContentSelectorWrapper.cjs');
|
|
31
|
-
const ContentSelectorContext = (0, import_react.createContext)({
|
|
32
|
-
state: { ContentSelectorWrapper: import_ContentSelectorWrapper.ContentSelectorWrapper },
|
|
33
|
-
setState: () => {
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
const useContentSelectorContext = () => (0, import_react.useContext)(ContentSelectorContext);
|
|
37
|
-
const ContentSelectorProvider = ({
|
|
38
|
-
children
|
|
39
|
-
}) => {
|
|
40
|
-
const [state, setState] = (0, import_react.useState)({
|
|
41
|
-
// Add your default state here
|
|
42
|
-
ContentSelectorWrapper: import_ContentSelectorWrapper.ContentSelectorWrapper
|
|
43
|
-
});
|
|
44
|
-
const valueMemo = (0, import_react.useMemo)(() => ({ state, setState }), [state, setState]);
|
|
45
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentSelectorContext.Provider, { value: valueMemo, children });
|
|
46
|
-
};
|
|
47
|
-
const ContentSelectorConnector = (props) => {
|
|
48
|
-
const { ContentSelectorWrapper: ContentSelectorWrapper2 } = useContentSelectorContext().state;
|
|
49
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentSelectorWrapper2, { ...props });
|
|
50
|
-
};
|
|
51
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
-
0 && (module.exports = {
|
|
53
|
-
ContentSelectorConnector,
|
|
54
|
-
ContentSelectorContext,
|
|
55
|
-
ContentSelectorProvider,
|
|
56
|
-
useContentSelectorContext
|
|
57
|
-
});
|
|
58
|
-
//# sourceMappingURL=ContentSelectorConnector.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/ContentSelectorConnector.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n FC,\n PropsWithChildren,\n useContext,\n useMemo,\n useState,\n} from 'react';\nimport {\n ContentSelectorWrapper,\n ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\n\ntype ContentSelectorContextValue = {\n state: {\n ContentSelectorWrapper: typeof ContentSelectorWrapper;\n };\n setState: (value: ContentSelectorContextValue['state']) => void;\n};\n\nexport const ContentSelectorContext =\n createContext<ContentSelectorContextValue>({\n state: { ContentSelectorWrapper },\n setState: () => {},\n });\n\nexport const useContentSelectorContext = () =>\n useContext(ContentSelectorContext);\n\nexport const ContentSelectorProvider: FC<PropsWithChildren> = ({\n children,\n}) => {\n const [state, setState] = useState({\n // Add your default state here\n ContentSelectorWrapper,\n });\n\n const valueMemo = useMemo(() => ({ state, setState }), [state, setState]);\n\n return (\n <ContentSelectorContext.Provider value={valueMemo}>\n {children}\n </ContentSelectorContext.Provider>\n );\n};\n\nexport const ContentSelectorConnector: FC<ContentSelectorWrapperProps> = (\n props\n) => {\n const { ContentSelectorWrapper } = useContentSelectorContext().state;\n\n return <ContentSelectorWrapper {...props} />;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CI;AAxCJ,mBAOO;AACP,oCAGO;AASA,MAAM,6BACX,4BAA2C;AAAA,EACzC,OAAO,EAAE,6EAAuB;AAAA,EAChC,UAAU,MAAM;AAAA,EAAC;AACnB,CAAC;AAEI,MAAM,4BAA4B,UACvC,yBAAW,sBAAsB;AAE5B,MAAM,0BAAiD,CAAC;AAAA,EAC7D;AACF,MAAM;AACJ,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS;AAAA;AAAA,IAEjC;AAAA,EACF,CAAC;AAED,QAAM,gBAAY,sBAAQ,OAAO,EAAE,OAAO,SAAS,IAAI,CAAC,OAAO,QAAQ,CAAC;AAExE,SACE,4CAAC,uBAAuB,UAAvB,EAAgC,OAAO,WACrC,UACH;AAEJ;AAEO,MAAM,2BAA4D,CACvE,UACG;AACH,QAAM,EAAE,wBAAAA,wBAAuB,IAAI,0BAA0B,EAAE;AAE/D,SAAO,4CAACA,yBAAA,EAAwB,GAAG,OAAO;AAC5C;","names":["ContentSelectorWrapper"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/PoweredByMeta/index.ts"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect } from 'react';\n\nexport const PoweredByMeta: FC = () => {\n if (process.env.NODE_ENV !== 'production') return null;\n\n useEffect(() => {\n const metaTag = document.createElement('meta');\n metaTag.name = 'content-powered-by';\n metaTag.content = 'Intlayer - https://intlayer.org';\n document.head.appendChild(metaTag);\n }, []);\n\n return null; // This component does not render anything visible\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAmC;AAE5B,MAAM,gBAAoB,MAAM;AACrC,MAAI,QAAQ,IAAI,aAAa,aAAc,QAAO;AAElD,8BAAU,MAAM;AACd,UAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,YAAQ,OAAO;AACf,YAAQ,UAAU;AAClB,aAAS,KAAK,YAAY,OAAO;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","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> => {\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,kBAC2B;AAC3B,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,38 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
createContext,
|
|
5
|
-
useContext,
|
|
6
|
-
useMemo,
|
|
7
|
-
useState
|
|
8
|
-
} from "react";
|
|
9
|
-
import {
|
|
10
|
-
ContentSelectorWrapper
|
|
11
|
-
} from './ContentSelectorWrapper.mjs';
|
|
12
|
-
const ContentSelectorContext = createContext({
|
|
13
|
-
state: { ContentSelectorWrapper },
|
|
14
|
-
setState: () => {
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
const useContentSelectorContext = () => useContext(ContentSelectorContext);
|
|
18
|
-
const ContentSelectorProvider = ({
|
|
19
|
-
children
|
|
20
|
-
}) => {
|
|
21
|
-
const [state, setState] = useState({
|
|
22
|
-
// Add your default state here
|
|
23
|
-
ContentSelectorWrapper
|
|
24
|
-
});
|
|
25
|
-
const valueMemo = useMemo(() => ({ state, setState }), [state, setState]);
|
|
26
|
-
return /* @__PURE__ */ jsx(ContentSelectorContext.Provider, { value: valueMemo, children });
|
|
27
|
-
};
|
|
28
|
-
const ContentSelectorConnector = (props) => {
|
|
29
|
-
const { ContentSelectorWrapper: ContentSelectorWrapper2 } = useContentSelectorContext().state;
|
|
30
|
-
return /* @__PURE__ */ jsx(ContentSelectorWrapper2, { ...props });
|
|
31
|
-
};
|
|
32
|
-
export {
|
|
33
|
-
ContentSelectorConnector,
|
|
34
|
-
ContentSelectorContext,
|
|
35
|
-
ContentSelectorProvider,
|
|
36
|
-
useContentSelectorContext
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=ContentSelectorConnector.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/ContentSelectorConnector.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n FC,\n PropsWithChildren,\n useContext,\n useMemo,\n useState,\n} from 'react';\nimport {\n ContentSelectorWrapper,\n ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\n\ntype ContentSelectorContextValue = {\n state: {\n ContentSelectorWrapper: typeof ContentSelectorWrapper;\n };\n setState: (value: ContentSelectorContextValue['state']) => void;\n};\n\nexport const ContentSelectorContext =\n createContext<ContentSelectorContextValue>({\n state: { ContentSelectorWrapper },\n setState: () => {},\n });\n\nexport const useContentSelectorContext = () =>\n useContext(ContentSelectorContext);\n\nexport const ContentSelectorProvider: FC<PropsWithChildren> = ({\n children,\n}) => {\n const [state, setState] = useState({\n // Add your default state here\n ContentSelectorWrapper,\n });\n\n const valueMemo = useMemo(() => ({ state, setState }), [state, setState]);\n\n return (\n <ContentSelectorContext.Provider value={valueMemo}>\n {children}\n </ContentSelectorContext.Provider>\n );\n};\n\nexport const ContentSelectorConnector: FC<ContentSelectorWrapperProps> = (\n props\n) => {\n const { ContentSelectorWrapper } = useContentSelectorContext().state;\n\n return <ContentSelectorWrapper {...props} />;\n};\n"],"mappings":";AA0CI;AAxCJ;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAEK;AASA,MAAM,yBACX,cAA2C;AAAA,EACzC,OAAO,EAAE,uBAAuB;AAAA,EAChC,UAAU,MAAM;AAAA,EAAC;AACnB,CAAC;AAEI,MAAM,4BAA4B,MACvC,WAAW,sBAAsB;AAE5B,MAAM,0BAAiD,CAAC;AAAA,EAC7D;AACF,MAAM;AACJ,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS;AAAA;AAAA,IAEjC;AAAA,EACF,CAAC;AAED,QAAM,YAAY,QAAQ,OAAO,EAAE,OAAO,SAAS,IAAI,CAAC,OAAO,QAAQ,CAAC;AAExE,SACE,oBAAC,uBAAuB,UAAvB,EAAgC,OAAO,WACrC,UACH;AAEJ;AAEO,MAAM,2BAA4D,CACvE,UACG;AACH,QAAM,EAAE,wBAAAA,wBAAuB,IAAI,0BAA0B,EAAE;AAE/D,SAAO,oBAACA,yBAAA,EAAwB,GAAG,OAAO;AAC5C;","names":["ContentSelectorWrapper"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
const PoweredByMeta = () => {
|
|
4
|
-
if (process.env.NODE_ENV !== "production") return null;
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
const metaTag = document.createElement("meta");
|
|
7
|
-
metaTag.name = "content-powered-by";
|
|
8
|
-
metaTag.content = "Intlayer - https://intlayer.org";
|
|
9
|
-
document.head.appendChild(metaTag);
|
|
10
|
-
}, []);
|
|
11
|
-
return null;
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
PoweredByMeta
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/PoweredByMeta/index.ts"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect } from 'react';\n\nexport const PoweredByMeta: FC = () => {\n if (process.env.NODE_ENV !== 'production') return null;\n\n useEffect(() => {\n const metaTag = document.createElement('meta');\n metaTag.name = 'content-powered-by';\n metaTag.content = 'Intlayer - https://intlayer.org';\n document.head.appendChild(metaTag);\n }, []);\n\n return null; // This component does not render anything visible\n};\n"],"mappings":";AAEA,SAAkB,iBAAiB;AAE5B,MAAM,gBAAoB,MAAM;AACrC,MAAI,QAAQ,IAAI,aAAa,aAAc,QAAO;AAElD,YAAU,MAAM;AACd,UAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,YAAQ,OAAO;AACf,YAAQ,UAAU;AAClB,aAAS,KAAK,YAAY,OAAO;AAAA,EACnC,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","names":[]}
|
|
@@ -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,CAoCvB,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FC, PropsWithChildren } from 'react';
|
|
2
|
-
import { ContentSelectorWrapper, ContentSelectorWrapperProps } from './ContentSelectorWrapper';
|
|
3
|
-
type ContentSelectorContextValue = {
|
|
4
|
-
state: {
|
|
5
|
-
ContentSelectorWrapper: typeof ContentSelectorWrapper;
|
|
6
|
-
};
|
|
7
|
-
setState: (value: ContentSelectorContextValue['state']) => void;
|
|
8
|
-
};
|
|
9
|
-
export declare const ContentSelectorContext: import("react").Context<ContentSelectorContextValue>;
|
|
10
|
-
export declare const useContentSelectorContext: () => ContentSelectorContextValue;
|
|
11
|
-
export declare const ContentSelectorProvider: FC<PropsWithChildren>;
|
|
12
|
-
export declare const ContentSelectorConnector: FC<ContentSelectorWrapperProps>;
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=ContentSelectorConnector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelectorConnector.d.ts","sourceRoot":"","sources":["../../../src/editor/ContentSelectorConnector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,EAAE,EACF,iBAAiB,EAIlB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAElC,KAAK,2BAA2B,GAAG;IACjC,KAAK,EAAE;QACL,sBAAsB,EAAE,OAAO,sBAAsB,CAAC;KACvD,CAAC;IACF,QAAQ,EAAE,CAAC,KAAK,EAAE,2BAA2B,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;CACjE,CAAC;AAEF,eAAO,MAAM,sBAAsB,sDAI/B,CAAC;AAEL,eAAO,MAAM,yBAAyB,mCACF,CAAC;AAErC,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,iBAAiB,CAezD,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,2BAA2B,CAMpE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/PoweredByMeta/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAa,MAAM,OAAO,CAAC;AAE3C,eAAO,MAAM,aAAa,EAAE,EAW3B,CAAC"}
|