preact-intlayer 5.5.5 → 5.5.7
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/dist/cjs/IntlayerNode.cjs +47 -0
- package/dist/cjs/IntlayerNode.cjs.map +1 -0
- package/dist/cjs/UI/ContentSelector.cjs +127 -0
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -0
- package/dist/cjs/client/IntlayerProvider.cjs +98 -0
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -0
- package/dist/cjs/client/getBrowserLocale.cjs +173 -0
- package/dist/cjs/client/getBrowserLocale.cjs.map +1 -0
- package/dist/cjs/client/index.cjs +69 -0
- package/dist/cjs/client/index.cjs.map +1 -0
- package/dist/cjs/client/t.cjs +37 -0
- package/dist/cjs/client/t.cjs.map +1 -0
- package/dist/cjs/client/useContent.cjs +39 -0
- package/dist/cjs/client/useContent.cjs.map +1 -0
- package/dist/cjs/client/useDictionary.cjs +42 -0
- package/dist/cjs/client/useDictionary.cjs.map +1 -0
- package/dist/cjs/client/useDictionaryDynamic.cjs +42 -0
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -0
- package/dist/cjs/client/useIntlayer.cjs +43 -0
- package/dist/cjs/client/useIntlayer.cjs.map +1 -0
- package/dist/cjs/client/useIntlayerAsync.cjs +54 -0
- package/dist/cjs/client/useIntlayerAsync.cjs.map +1 -0
- package/dist/cjs/client/useLoadDynamic.cjs +56 -0
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -0
- package/dist/cjs/client/useLocale.cjs +69 -0
- package/dist/cjs/client/useLocale.cjs.map +1 -0
- package/dist/cjs/client/useLocaleBase.cjs +56 -0
- package/dist/cjs/client/useLocaleBase.cjs.map +1 -0
- package/dist/cjs/client/useLocaleCookie.cjs +60 -0
- package/dist/cjs/client/useLocaleCookie.cjs.map +1 -0
- package/dist/cjs/client/useTraduction.cjs +35 -0
- package/dist/cjs/client/useTraduction.cjs.map +1 -0
- package/dist/cjs/editor/ChangedContentContext.cjs +77 -0
- package/dist/cjs/editor/ChangedContentContext.cjs.map +1 -0
- package/dist/cjs/editor/CommunicatorContext.cjs +66 -0
- package/dist/cjs/editor/CommunicatorContext.cjs.map +1 -0
- package/dist/cjs/editor/ConfigurationContext.cjs +50 -0
- package/dist/cjs/editor/ConfigurationContext.cjs.map +1 -0
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +66 -0
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -0
- package/dist/cjs/editor/DictionariesRecordContext.cjs +77 -0
- package/dist/cjs/editor/DictionariesRecordContext.cjs.map +1 -0
- package/dist/cjs/editor/EditedContentContext.cjs +217 -0
- package/dist/cjs/editor/EditedContentContext.cjs.map +1 -0
- package/dist/cjs/editor/EditorEnabledContext.cjs +62 -0
- package/dist/cjs/editor/EditorEnabledContext.cjs.map +1 -0
- package/dist/cjs/editor/EditorProvider.cjs +72 -0
- package/dist/cjs/editor/EditorProvider.cjs.map +1 -0
- package/dist/cjs/editor/FocusDictionaryContext.cjs +81 -0
- package/dist/cjs/editor/FocusDictionaryContext.cjs.map +1 -0
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +122 -0
- package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -0
- package/dist/cjs/editor/index.cjs +23 -0
- package/dist/cjs/editor/index.cjs.map +1 -0
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs +53 -0
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -0
- package/dist/cjs/editor/useCrossFrameState.cjs +77 -0
- package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -0
- package/dist/cjs/editor/useCrossURLPathState.cjs +69 -0
- package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -0
- package/dist/cjs/editor/useEditedContentRenderer.cjs +63 -0
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -0
- package/dist/cjs/editor/useIframeClickInterceptor.cjs +50 -0
- package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -0
- package/dist/cjs/getDictionary.cjs +43 -0
- package/dist/cjs/getDictionary.cjs.map +1 -0
- package/dist/cjs/getIntlayer.cjs +39 -0
- package/dist/cjs/getIntlayer.cjs.map +1 -0
- package/dist/cjs/index.cjs +42 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs +41 -0
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -0
- package/dist/cjs/markdown/MarkdownRenderer.cjs +83 -0
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -0
- package/dist/cjs/markdown/index.cjs +25 -0
- package/dist/cjs/markdown/index.cjs.map +1 -0
- package/dist/cjs/plugins.cjs +128 -0
- package/dist/cjs/plugins.cjs.map +1 -0
- package/dist/cjs/preactElement/renderPreactElement.cjs +62 -0
- package/dist/cjs/preactElement/renderPreactElement.cjs.map +1 -0
- package/dist/esm/IntlayerNode.mjs +27 -0
- package/dist/esm/IntlayerNode.mjs.map +1 -0
- package/dist/esm/UI/ContentSelector.mjs +103 -0
- package/dist/esm/UI/ContentSelector.mjs.map +1 -0
- package/dist/esm/client/IntlayerProvider.mjs +63 -0
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -0
- package/dist/esm/client/getBrowserLocale.mjs +138 -0
- package/dist/esm/client/getBrowserLocale.mjs.map +1 -0
- package/dist/esm/client/index.mjs +39 -0
- package/dist/esm/client/index.mjs.map +1 -0
- package/dist/esm/client/t.mjs +13 -0
- package/dist/esm/client/t.mjs.map +1 -0
- package/dist/esm/client/useContent.mjs +15 -0
- package/dist/esm/client/useContent.mjs.map +1 -0
- package/dist/esm/client/useDictionary.mjs +18 -0
- package/dist/esm/client/useDictionary.mjs.map +1 -0
- package/dist/esm/client/useDictionaryDynamic.mjs +18 -0
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -0
- package/dist/esm/client/useIntlayer.mjs +19 -0
- package/dist/esm/client/useIntlayer.mjs.map +1 -0
- package/dist/esm/client/useIntlayerAsync.mjs +33 -0
- package/dist/esm/client/useIntlayerAsync.mjs.map +1 -0
- package/dist/esm/client/useLoadDynamic.mjs +32 -0
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -0
- package/dist/esm/client/useLocale.mjs +35 -0
- package/dist/esm/client/useLocale.mjs.map +1 -0
- package/dist/esm/client/useLocaleBase.mjs +22 -0
- package/dist/esm/client/useLocaleBase.mjs.map +1 -0
- package/dist/esm/client/useLocaleCookie.mjs +24 -0
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -0
- package/dist/esm/client/useTraduction.mjs +11 -0
- package/dist/esm/client/useTraduction.mjs.map +1 -0
- package/dist/esm/editor/ChangedContentContext.mjs +55 -0
- package/dist/esm/editor/ChangedContentContext.mjs.map +1 -0
- package/dist/esm/editor/CommunicatorContext.mjs +33 -0
- package/dist/esm/editor/CommunicatorContext.mjs.map +1 -0
- package/dist/esm/editor/ConfigurationContext.mjs +27 -0
- package/dist/esm/editor/ConfigurationContext.mjs.map +1 -0
- package/dist/esm/editor/ContentSelectorWrapper.mjs +45 -0
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -0
- package/dist/esm/editor/DictionariesRecordContext.mjs +55 -0
- package/dist/esm/editor/DictionariesRecordContext.mjs.map +1 -0
- package/dist/esm/editor/EditedContentContext.mjs +198 -0
- package/dist/esm/editor/EditedContentContext.mjs.map +1 -0
- package/dist/esm/editor/EditorEnabledContext.mjs +39 -0
- package/dist/esm/editor/EditorEnabledContext.mjs.map +1 -0
- package/dist/esm/editor/EditorProvider.mjs +62 -0
- package/dist/esm/editor/EditorProvider.mjs.map +1 -0
- package/dist/esm/editor/FocusDictionaryContext.mjs +58 -0
- package/dist/esm/editor/FocusDictionaryContext.mjs.map +1 -0
- package/dist/esm/editor/IntlayerEditorProvider.mjs +88 -0
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -0
- package/dist/esm/editor/index.mjs +2 -0
- package/dist/esm/editor/index.mjs.map +1 -0
- package/dist/esm/editor/useCrossFrameMessageListener.mjs +29 -0
- package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -0
- package/dist/esm/editor/useCrossFrameState.mjs +53 -0
- package/dist/esm/editor/useCrossFrameState.mjs.map +1 -0
- package/dist/esm/editor/useCrossURLPathState.mjs +46 -0
- package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -0
- package/dist/esm/editor/useEditedContentRenderer.mjs +38 -0
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -0
- package/dist/esm/editor/useIframeClickInterceptor.mjs +25 -0
- package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -0
- package/dist/esm/getDictionary.mjs +25 -0
- package/dist/esm/getDictionary.mjs.map +1 -0
- package/dist/esm/getIntlayer.mjs +21 -0
- package/dist/esm/getIntlayer.mjs.map +1 -0
- package/dist/esm/index.mjs +38 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownProvider.mjs +19 -0
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -0
- package/dist/esm/markdown/MarkdownRenderer.mjs +62 -0
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -0
- package/dist/esm/markdown/index.mjs +3 -0
- package/dist/esm/markdown/index.mjs.map +1 -0
- package/dist/esm/plugins.mjs +104 -0
- package/dist/esm/plugins.mjs.map +1 -0
- package/dist/esm/preactElement/renderPreactElement.mjs +38 -0
- package/dist/esm/preactElement/renderPreactElement.mjs.map +1 -0
- package/dist/types/IntlayerNode.d.ts +15 -0
- package/dist/types/IntlayerNode.d.ts.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 +29 -0
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -0
- package/dist/types/client/getBrowserLocale.d.ts +25 -0
- package/dist/types/client/getBrowserLocale.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +12 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/t.d.ts +9 -0
- package/dist/types/client/t.d.ts.map +1 -0
- package/dist/types/client/useContent.d.ts +10 -0
- package/dist/types/client/useContent.d.ts.map +1 -0
- package/dist/types/client/useDictionary.d.ts +9 -0
- package/dist/types/client/useDictionary.d.ts.map +1 -0
- package/dist/types/client/useDictionaryDynamic.d.ts +9 -0
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
- package/dist/types/client/useIntlayer.d.ts +11 -0
- package/dist/types/client/useIntlayer.d.ts.map +1 -0
- package/dist/types/client/useIntlayerAsync.d.ts +14 -0
- package/dist/types/client/useIntlayerAsync.d.ts.map +1 -0
- package/dist/types/client/useLoadDynamic.d.ts +2 -0
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -0
- package/dist/types/client/useLocale.d.ts +15 -0
- package/dist/types/client/useLocale.d.ts.map +1 -0
- package/dist/types/client/useLocaleBase.d.ts +10 -0
- package/dist/types/client/useLocaleBase.d.ts.map +1 -0
- package/dist/types/client/useLocaleCookie.d.ts +17 -0
- package/dist/types/client/useLocaleCookie.d.ts.map +1 -0
- package/dist/types/client/useTraduction.d.ts +24 -0
- package/dist/types/client/useTraduction.d.ts.map +1 -0
- package/dist/types/editor/ChangedContentContext.d.ts +13 -0
- package/dist/types/editor/ChangedContentContext.d.ts.map +1 -0
- package/dist/types/editor/CommunicatorContext.d.ts +14 -0
- package/dist/types/editor/CommunicatorContext.d.ts.map +1 -0
- package/dist/types/editor/ConfigurationContext.d.ts +9 -0
- package/dist/types/editor/ConfigurationContext.d.ts.map +1 -0
- package/dist/types/editor/ContentSelectorWrapper.d.ts +5 -0
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -0
- package/dist/types/editor/DictionariesRecordContext.d.ts +16 -0
- package/dist/types/editor/DictionariesRecordContext.d.ts.map +1 -0
- package/dist/types/editor/EditedContentContext.d.ts +33 -0
- package/dist/types/editor/EditedContentContext.d.ts.map +1 -0
- package/dist/types/editor/EditorEnabledContext.d.ts +11 -0
- package/dist/types/editor/EditorEnabledContext.d.ts.map +1 -0
- package/dist/types/editor/EditorProvider.d.ts +6 -0
- package/dist/types/editor/EditorProvider.d.ts.map +1 -0
- package/dist/types/editor/FocusDictionaryContext.d.ts +21 -0
- package/dist/types/editor/FocusDictionaryContext.d.ts.map +1 -0
- package/dist/types/editor/IntlayerEditorProvider.d.ts +5 -0
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -0
- package/dist/types/editor/index.d.ts +2 -0
- package/dist/types/editor/index.d.ts.map +1 -0
- package/dist/types/editor/useCrossFrameMessageListener.d.ts +19 -0
- package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +1 -0
- package/dist/types/editor/useCrossFrameState.d.ts +30 -0
- package/dist/types/editor/useCrossFrameState.d.ts.map +1 -0
- package/dist/types/editor/useCrossURLPathState.d.ts +4 -0
- package/dist/types/editor/useCrossURLPathState.d.ts.map +1 -0
- package/dist/types/editor/useEditedContentRenderer.d.ts +13 -0
- package/dist/types/editor/useEditedContentRenderer.d.ts.map +1 -0
- package/dist/types/editor/useIframeClickInterceptor.d.ts +3 -0
- package/dist/types/editor/useIframeClickInterceptor.d.ts.map +1 -0
- package/dist/types/getDictionary.d.ts +5 -0
- package/dist/types/getDictionary.d.ts.map +1 -0
- package/dist/types/getIntlayer.d.ts +5 -0
- package/dist/types/getIntlayer.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +9 -0
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -0
- package/dist/types/markdown/MarkdownRenderer.d.ts +16 -0
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -0
- package/dist/types/markdown/index.d.ts +3 -0
- package/dist/types/markdown/index.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +54 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/preactElement/renderPreactElement.d.ts +5 -0
- package/dist/types/preactElement/renderPreactElement.d.ts.map +1 -0
- package/package.json +17 -10
- package/dist/cjs/intlayerMiddlewarePlugin.cjs +0 -224
- package/dist/cjs/intlayerMiddlewarePlugin.cjs.map +0 -1
- package/dist/cjs/intlayerPlugin.cjs +0 -76
- package/dist/cjs/intlayerPlugin.cjs.map +0 -1
- package/dist/esm/intlayerMiddlewarePlugin.mjs +0 -200
- package/dist/esm/intlayerMiddlewarePlugin.mjs.map +0 -1
- package/dist/esm/intlayerPlugin.mjs +0 -52
- package/dist/esm/intlayerPlugin.mjs.map +0 -1
- package/dist/types/intlayerMiddlewarePlugin.d.ts +0 -6
- package/dist/types/intlayerMiddlewarePlugin.d.ts.map +0 -1
- package/dist/types/intlayerPlugin.d.ts +0 -16
- package/dist/types/intlayerPlugin.d.ts.map +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
getContent,
|
|
4
|
+
getContentNodeByKeyPath,
|
|
5
|
+
getMarkdownMetadata
|
|
6
|
+
} from "@intlayer/core";
|
|
7
|
+
import { useEditedContentRenderer } from "../editor/useEditedContentRenderer.mjs";
|
|
8
|
+
import { useMarkdownContext } from "./MarkdownProvider.mjs";
|
|
9
|
+
const MarkdownRenderer = ({
|
|
10
|
+
dictionaryKey,
|
|
11
|
+
keyPath,
|
|
12
|
+
children,
|
|
13
|
+
locale
|
|
14
|
+
}) => {
|
|
15
|
+
const { renderMarkdown } = useMarkdownContext();
|
|
16
|
+
const editedContentContext = useEditedContentRenderer({
|
|
17
|
+
dictionaryKey,
|
|
18
|
+
keyPath,
|
|
19
|
+
children
|
|
20
|
+
});
|
|
21
|
+
if (typeof editedContentContext !== "string") {
|
|
22
|
+
const transformedEditedContent = getContent(
|
|
23
|
+
editedContentContext,
|
|
24
|
+
{
|
|
25
|
+
dictionaryKey,
|
|
26
|
+
keyPath
|
|
27
|
+
},
|
|
28
|
+
locale
|
|
29
|
+
);
|
|
30
|
+
if (typeof transformedEditedContent !== "string") {
|
|
31
|
+
console.error(
|
|
32
|
+
`Incorrect Markdown content. Edited Markdown content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`
|
|
33
|
+
);
|
|
34
|
+
return renderMarkdown(children);
|
|
35
|
+
}
|
|
36
|
+
return renderMarkdown(transformedEditedContent);
|
|
37
|
+
}
|
|
38
|
+
return renderMarkdown(editedContentContext);
|
|
39
|
+
};
|
|
40
|
+
const MarkdownMetadataRenderer = ({
|
|
41
|
+
dictionaryKey,
|
|
42
|
+
keyPath,
|
|
43
|
+
children,
|
|
44
|
+
metadataKeyPath
|
|
45
|
+
}) => {
|
|
46
|
+
const editedContentContext = useEditedContentRenderer({
|
|
47
|
+
dictionaryKey,
|
|
48
|
+
keyPath,
|
|
49
|
+
children
|
|
50
|
+
});
|
|
51
|
+
const metadata = getMarkdownMetadata(editedContentContext);
|
|
52
|
+
const metadataEl = getContentNodeByKeyPath(
|
|
53
|
+
metadata,
|
|
54
|
+
metadataKeyPath
|
|
55
|
+
);
|
|
56
|
+
return metadataEl;
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
MarkdownMetadataRenderer,
|
|
60
|
+
MarkdownRenderer
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=MarkdownRenderer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport { LocalesValues } from '@intlayer/config/client';\nimport {\n ContentNode,\n getContent,\n getContentNodeByKeyPath,\n getMarkdownMetadata,\n KeyPath,\n} from '@intlayer/core';\nimport { FC, ReactNode } from 'preact/compat';\nimport { useEditedContentRenderer } from '../editor/useEditedContentRenderer';\nimport { useMarkdownContext } from './MarkdownProvider';\n\ntype MarkdownRendererProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n};\n\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n locale,\n}): ReactNode => {\n const { renderMarkdown } = useMarkdownContext();\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n\n if (typeof editedContentContext !== 'string') {\n const transformedEditedContent = getContent(\n editedContentContext,\n {\n dictionaryKey,\n keyPath,\n },\n locale\n );\n\n if (typeof transformedEditedContent !== 'string') {\n console.error(\n `Incorrect Markdown content. Edited Markdown content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`\n );\n\n return renderMarkdown(children);\n }\n\n return renderMarkdown(transformedEditedContent);\n }\n\n return renderMarkdown(editedContentContext);\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = ({\n dictionaryKey,\n keyPath,\n children,\n metadataKeyPath,\n}): ReactNode => {\n const editedContentContext = useEditedContentRenderer({\n dictionaryKey,\n keyPath,\n children,\n });\n const metadata = getMarkdownMetadata(editedContentContext);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath\n );\n\n return metadataEl as ReactNode;\n};\n"],"mappings":";AAGA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,gCAAgC;AACzC,SAAS,0BAA0B;AAS5B,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAiB;AACf,QAAM,EAAE,eAAe,IAAI,mBAAmB;AAC9C,QAAM,uBAAuB,yBAAyB;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,MAAI,OAAO,yBAAyB,UAAU;AAC5C,UAAM,2BAA2B;AAAA,MAC/B;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAEA,QAAI,OAAO,6BAA6B,UAAU;AAChD,cAAQ;AAAA,QACN,6DAA6D,OAAO,wBAAwB,4BAA4B,KAAK,UAAU,wBAAwB,CAAC;AAAA,MAClK;AAEA,aAAO,eAAe,QAAQ;AAAA,IAChC;AAEA,WAAO,eAAe,wBAAwB;AAAA,EAChD;AAEA,SAAO,eAAe,oBAAoB;AAC5C;AAMO,MAAM,2BAA8D,CAAC;AAAA,EAC1E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAiB;AACf,QAAM,uBAAuB,yBAAyB;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,WAAW,oBAAoB,oBAAoB;AAEzD,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["export * from './MarkdownProvider';\nexport * from './MarkdownRenderer';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { createElement } from "preact";
|
|
3
|
+
import {
|
|
4
|
+
NodeType,
|
|
5
|
+
getMarkdownMetadata
|
|
6
|
+
} from "@intlayer/core";
|
|
7
|
+
import { renderIntlayerNode } from "./IntlayerNode.mjs";
|
|
8
|
+
import { ContentSelectorRenderer } from "./editor/index.mjs";
|
|
9
|
+
import { EditedContentRenderer } from "./editor/useEditedContentRenderer.mjs";
|
|
10
|
+
import { MarkdownMetadataRenderer, MarkdownRenderer } from "./markdown/index.mjs";
|
|
11
|
+
import { renderPreactElement } from "./preactElement/renderPreactElement.mjs";
|
|
12
|
+
const intlayerNodePlugins = {
|
|
13
|
+
id: "intlayer-node-plugin",
|
|
14
|
+
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
15
|
+
transform: (_node, {
|
|
16
|
+
plugins,
|
|
17
|
+
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
18
|
+
...rest
|
|
19
|
+
}) => renderIntlayerNode({
|
|
20
|
+
...rest,
|
|
21
|
+
value: rest.children,
|
|
22
|
+
children: /* @__PURE__ */ createElement(ContentSelectorRenderer, { ...rest, key: rest.children }, /* @__PURE__ */ jsx(EditedContentRenderer, { ...rest, children: rest.children }))
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
const preactNodePlugins = {
|
|
26
|
+
id: "preact-node-plugin",
|
|
27
|
+
canHandle: (node) => typeof node === "object" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
|
|
28
|
+
transform: (node, {
|
|
29
|
+
plugins,
|
|
30
|
+
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
31
|
+
...rest
|
|
32
|
+
}) => renderIntlayerNode({
|
|
33
|
+
...rest,
|
|
34
|
+
value: "[[preact-element]]",
|
|
35
|
+
children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, children: renderPreactElement(node) })
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
const markdownStringPlugin = {
|
|
39
|
+
id: "markdown-string-plugin",
|
|
40
|
+
canHandle: (node) => typeof node === "string",
|
|
41
|
+
transform: (node, props, deepTransformNode) => {
|
|
42
|
+
const {
|
|
43
|
+
plugins,
|
|
44
|
+
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
45
|
+
...rest
|
|
46
|
+
} = props;
|
|
47
|
+
const metadata = getMarkdownMetadata(node);
|
|
48
|
+
const metadataPlugins = {
|
|
49
|
+
id: "markdown-metadata-plugin",
|
|
50
|
+
canHandle: (metadataNode) => typeof metadataNode === "string" || typeof metadataNode === "number" || typeof metadataNode === "boolean" || !metadataNode,
|
|
51
|
+
transform: (metadataNode, props2) => renderIntlayerNode({
|
|
52
|
+
...props2,
|
|
53
|
+
value: metadataNode,
|
|
54
|
+
children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, children: /* @__PURE__ */ jsx(
|
|
55
|
+
MarkdownMetadataRenderer,
|
|
56
|
+
{
|
|
57
|
+
...rest,
|
|
58
|
+
metadataKeyPath: props2.keyPath,
|
|
59
|
+
children: node
|
|
60
|
+
}
|
|
61
|
+
) })
|
|
62
|
+
})
|
|
63
|
+
};
|
|
64
|
+
const metadataNodes = deepTransformNode(metadata, {
|
|
65
|
+
plugins: [metadataPlugins],
|
|
66
|
+
dictionaryKey: rest.dictionaryKey,
|
|
67
|
+
keyPath: []
|
|
68
|
+
});
|
|
69
|
+
return renderIntlayerNode({
|
|
70
|
+
...props,
|
|
71
|
+
value: node,
|
|
72
|
+
children: /* @__PURE__ */ jsx(ContentSelectorRenderer, { ...rest, children: /* @__PURE__ */ jsx(MarkdownRenderer, { ...rest, children: node }) }),
|
|
73
|
+
additionalProps: {
|
|
74
|
+
metadata: metadataNodes
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const markdownPlugin = {
|
|
80
|
+
id: "markdown-plugin",
|
|
81
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Markdown,
|
|
82
|
+
transform: (node, props, deepTransformNode) => {
|
|
83
|
+
const newKeyPath = [
|
|
84
|
+
...props.keyPath,
|
|
85
|
+
{
|
|
86
|
+
type: NodeType.Markdown
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
const children = node[NodeType.Markdown];
|
|
90
|
+
return deepTransformNode(children, {
|
|
91
|
+
...props,
|
|
92
|
+
children,
|
|
93
|
+
keyPath: newKeyPath,
|
|
94
|
+
plugins: [markdownStringPlugin, ...props.plugins ?? []]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
intlayerNodePlugins,
|
|
100
|
+
markdownPlugin,
|
|
101
|
+
markdownStringPlugin,
|
|
102
|
+
preactNodePlugins
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=plugins.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import {\n KeyPath,\n NodeType,\n getMarkdownMetadata,\n type DeepTransformContent as DeepTransformContentCore,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type MarkdownContent,\n type Plugins,\n} from '@intlayer/core';\nimport type { ComponentChildren } from 'preact';\nimport { renderIntlayerNode, type IntlayerNode } from './IntlayerNode';\nimport { ContentSelectorRenderer } from './editor';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { MarkdownMetadataRenderer, MarkdownRenderer } from './markdown';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: (\n <ContentSelectorRenderer {...rest} key={rest.children}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? ComponentChildren\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children: (\n <ContentSelectorRenderer {...rest}>\n {renderPreactElement(node)}\n </ContentSelectorRenderer>\n ),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n return renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownRenderer {...rest}>{node}</MarkdownRenderer>\n </ContentSelectorRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n metadata?: infer U;\n}\n ? IntlayerNode<DeepTransformContent<M>, { metadata: DeepTransformContent<U> }>\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T> {\n preactNode: PreactNodeCond<T>;\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n preactNode: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":"AA2CU;AADF;AA1CR;AAAA,EAEE;AAAA,EACA;AAAA,OAKK;AAEP,SAAS,0BAA6C;AACtD,SAAS,+BAA+B;AACxC,SAAS,6BAA6B;AACtC,SAAS,0BAA0B,wBAAwB;AAC3D,SAAS,2BAA2B;AAW7B,MAAM,sBAA+B;AAAA,EAC1C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CACT,OACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,MAEA,mBAAmB;AAAA,IACjB,GAAG;AAAA,IACH,OAAO,KAAK;AAAA,IACZ,UACE,8BAAC,2BAAyB,GAAG,MAAM,KAAK,KAAK,YAC3C,oBAAC,yBAAuB,GAAG,MACxB,eAAK,UACR,CACF;AAAA,EAEJ,CAAC;AACL;AAcO,MAAM,oBAA6B;AAAA,EACxC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;AAAA,EAEtB,WAAW,CACT,MACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,MAEA,mBAAmB;AAAA,IACjB,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UACE,oBAAC,2BAAyB,GAAG,MAC1B,8BAAoB,IAAI,GAC3B;AAAA,EAEJ,CAAC;AACL;AAWO,MAAM,uBAAgC;AAAA,EAC3C,IAAI;AAAA,EACJ,WAAW,CAAC,SAAS,OAAO,SAAS;AAAA,EACrC,WAAW,CAAC,MAAc,OAAO,sBAAsB;AACrD,UAAM;AAAA,MACJ;AAAA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AAEJ,UAAM,WAAW,oBAAoB,IAAI;AAEzC,UAAM,kBAA2B;AAAA,MAC/B,IAAI;AAAA,MACJ,WAAW,CAAC,iBACV,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,YACxB,OAAO,iBAAiB,aACxB,CAAC;AAAA,MACH,WAAW,CAAC,cAAcA,WACxB,mBAAmB;AAAA,QACjB,GAAGA;AAAA,QACH,OAAO;AAAA,QACP,UACE,oBAAC,2BAAyB,GAAG,MAC3B;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,iBAAiBA,OAAM;AAAA,YAEtB;AAAA;AAAA,QACH,GACF;AAAA,MAEJ,CAAC;AAAA,IACL;AAGA,UAAM,gBAAgB,kBAAkB,UAAU;AAAA,MAChD,SAAS,CAAC,eAAe;AAAA,MACzB,eAAe,KAAK;AAAA,MACpB,SAAS,CAAC;AAAA,IACZ,CAAC;AAED,WAAO,mBAAmB;AAAA,MACxB,GAAG;AAAA,MACH,OAAO;AAAA,MACP,UACE,oBAAC,2BAAyB,GAAG,MAC3B,8BAAC,oBAAkB,GAAG,MAAO,gBAAK,GACpC;AAAA,MAEF,iBAAiB;AAAA,QACf,UAAU;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAUO,MAAM,iBAA0B;AAAA,EACrC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAuB,OAAO,sBAAsB;AAC9D,UAAM,aAAwB;AAAA,MAC5B,GAAG,MAAM;AAAA,MACT;AAAA,QACE,MAAM,SAAS;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,WAAW,KAAK,SAAS,QAAQ;AAEvC,WAAO,kBAAkB,UAAU;AAAA,MACjC,GAAG;AAAA,MACH;AAAA,MACA,SAAS;AAAA,MACT,SAAS,CAAC,sBAAsB,GAAI,MAAM,WAAW,CAAC,CAAE;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;","names":["props"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createElement } from "preact/compat";
|
|
2
|
+
const renderPreactElement = (element) => {
|
|
3
|
+
if (typeof element === "string") {
|
|
4
|
+
return element;
|
|
5
|
+
}
|
|
6
|
+
const convertChildrenAsArray = (element2) => {
|
|
7
|
+
if (element2?.props && typeof element2.props.children === "object") {
|
|
8
|
+
const childrenResult = [];
|
|
9
|
+
const { children } = element2.props;
|
|
10
|
+
Object.keys(children ?? {}).forEach((key) => {
|
|
11
|
+
childrenResult.push(
|
|
12
|
+
renderPreactElement((children ?? {})[key])
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
...element2,
|
|
17
|
+
props: { ...element2.props, children: childrenResult }
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...element2,
|
|
22
|
+
props: { ...element2.props, children: element2.props?.children ?? [] }
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const fixedElement = convertChildrenAsArray(
|
|
26
|
+
element
|
|
27
|
+
);
|
|
28
|
+
const { type, props } = fixedElement;
|
|
29
|
+
return createElement(
|
|
30
|
+
type ?? "span",
|
|
31
|
+
props,
|
|
32
|
+
...props.children
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
renderPreactElement
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=renderPreactElement.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, type VNode } from 'preact';\nimport { createElement } from 'preact/compat';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>) => {\n if (typeof element === 'string') {\n // If it's a string, simply return it (used for text content)\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ComponentChild[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children ?? {}).forEach((key) => {\n childrenResult.push(\n renderPreactElement((children ?? {})[key as keyof typeof children])\n );\n });\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: element.props?.children ?? [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n type ?? 'span',\n props,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":"AACA,SAAS,qBAAqB;AAGvB,MAAM,sBAAsB,CAAC,YAAwB;AAC1D,MAAI,OAAO,YAAY,UAAU;AAE/B,WAAO;AAAA,EACT;AAEA,QAAM,yBAAyB,CAC7BA,aAC4D;AAC5D,QAAIA,UAAS,SAAS,OAAOA,SAAQ,MAAM,aAAa,UAAU;AAChE,YAAM,iBAAmC,CAAC;AAC1C,YAAM,EAAE,SAAS,IAAIA,SAAQ;AAG7B,aAAO,KAAK,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ;AAC3C,uBAAe;AAAA,UACb,qBAAqB,YAAY,CAAC,GAAG,GAA4B,CAAC;AAAA,QACpE;AAAA,MACF,CAAC;AAED,aAAO;AAAA,QACL,GAAGA;AAAA,QACH,OAAO,EAAE,GAAGA,SAAQ,OAAO,UAAU,eAAe;AAAA,MACtD;AAAA,IACF;AAEA,WAAO;AAAA,MACL,GAAGA;AAAA,MACH,OAAO,EAAE,GAAGA,SAAQ,OAAO,UAAUA,SAAQ,OAAO,YAAY,CAAC,EAAE;AAAA,IACrE;AAAA,EACF;AAEA,QAAM,eAAe;AAAA,IACnB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,MAAM,IAAI;AAGxB,SAAO;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA,GAAI,MAAM;AAAA,EACZ;AACF;","names":["element"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NodeProps } from '@intlayer/core';
|
|
2
|
+
import { type ComponentChildren, type VNode } from 'preact';
|
|
3
|
+
export type IntlayerNode<T = NodeProps['children'], AdditionalProps = {}> = VNode & {
|
|
4
|
+
value: T;
|
|
5
|
+
} & AdditionalProps;
|
|
6
|
+
type RenderIntlayerNodeProps<T> = {
|
|
7
|
+
value: T;
|
|
8
|
+
children: ComponentChildren;
|
|
9
|
+
additionalProps?: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const renderIntlayerNode: <T extends number | string | boolean | undefined | null>({ children, value, additionalProps, }: RenderIntlayerNodeProps<T>) => IntlayerNode<T>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=IntlayerNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlayerNode.d.ts","sourceRoot":"","sources":["../../src/IntlayerNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,KAAK,EAGX,MAAM,QAAQ,CAAC;AAEhB,MAAM,MAAM,YAAY,CACtB,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,EACzB,eAAe,GAAG,EAAE,IAClB,KAAK,GAAG;IACV,KAAK,EAAE,CAAC,CAAC;CACV,GAAG,eAAe,CAAC;AAEpB,KAAK,uBAAuB,CAAC,CAAC,IAAI;IAChC,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,eAAe,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,EACtD,uCAIC,uBAAuB,CAAC,CAAC,CAAC,KAAG,YAAY,CAAC,CAAC,CAwB7C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC, HTMLAttributes } from 'preact/compat';
|
|
2
|
+
type ContentSelectorProps = {
|
|
3
|
+
onPress: () => void;
|
|
4
|
+
onClickOutside?: () => void;
|
|
5
|
+
pressDuration?: number;
|
|
6
|
+
isSelecting?: boolean;
|
|
7
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;
|
|
8
|
+
export declare const ContentSelector: FC<ContentSelectorProps>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=ContentSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentSelector.d.ts","sourceRoot":"","sources":["../../../src/UI/ContentSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAC;AAKtE,KAAK,oBAAoB,GAAG;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,CAAC;AAEpD,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAkHpD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
import { type ComponentChild, type FunctionComponent } from 'preact';
|
|
3
|
+
type IntlayerValue = {
|
|
4
|
+
locale: LocalesValues;
|
|
5
|
+
setLocale: (newLocale: LocalesValues) => void;
|
|
6
|
+
disableEditor?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Context that store the current locale on the client side
|
|
10
|
+
*/
|
|
11
|
+
export declare const IntlayerClientContext: import("preact").Context<IntlayerValue>;
|
|
12
|
+
/**
|
|
13
|
+
* Hook that provides the current locale
|
|
14
|
+
*/
|
|
15
|
+
export declare const useIntlayerContext: () => IntlayerValue;
|
|
16
|
+
export type IntlayerProviderProps = {
|
|
17
|
+
children?: ComponentChild;
|
|
18
|
+
locale?: LocalesValues;
|
|
19
|
+
defaultLocale?: LocalesValues;
|
|
20
|
+
setLocale?: (locale: LocalesValues) => void;
|
|
21
|
+
disableEditor?: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Provider that store the current locale on the client side
|
|
25
|
+
*/
|
|
26
|
+
export declare const IntlayerProviderContent: FunctionComponent<IntlayerProviderProps>;
|
|
27
|
+
export declare const IntlayerProvider: FunctionComponent<IntlayerProviderProps>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=IntlayerProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,iBAAiB,EACvB,MAAM,QAAQ,CAAC;AAMhB,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,yCAIhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAAiB,CACrD,qBAAqB,CA+CtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,CAMrE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Locales } from '@intlayer/config/client';
|
|
2
|
+
export declare enum LanguageDetector {
|
|
3
|
+
Querystring = "querystring",
|
|
4
|
+
Cookie = "cookie",
|
|
5
|
+
LocalStorage = "localStorage",
|
|
6
|
+
SessionStorage = "sessionStorage",
|
|
7
|
+
Navigator = "navigator",
|
|
8
|
+
HtmlTag = "htmlTag"
|
|
9
|
+
}
|
|
10
|
+
type LanguageDetectorOptions = {
|
|
11
|
+
order?: LanguageDetector[];
|
|
12
|
+
lookupQuerystring?: string;
|
|
13
|
+
lookupCookie?: string;
|
|
14
|
+
lookupLocalStorage?: string;
|
|
15
|
+
lookupSessionStorage?: string;
|
|
16
|
+
excludeCacheFor?: string[];
|
|
17
|
+
htmlTag?: HTMLElement | null;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Core language detector function
|
|
21
|
+
* const detectedLanguages = detectLanguage(['LanguageDetector.Cookie', 'LanguageDetector.LocalStorage'], { lookupCookie: 'myCookie' });
|
|
22
|
+
*/
|
|
23
|
+
export declare const getBrowserLocale: (userOptions?: LanguageDetectorOptions | undefined) => Locales;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=getBrowserLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBrowserLocale.d.ts","sourceRoot":"","sources":["../../../src/client/getBrowserLocale.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,oBAAY,gBAAgB;IAC1B,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB;AAGD,KAAK,uBAAuB,GAAG;IAC7B,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B,CAAC;AA2JF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,cAAa,uBAAuB,GAAG,SAAc,KACpD,OAMF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { getBrowserLocale } from './getBrowserLocale';
|
|
2
|
+
export { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIntlayerContext, type IntlayerProviderProps, } from './IntlayerProvider';
|
|
3
|
+
export { t } from './t';
|
|
4
|
+
export { useDictionary } from './useDictionary';
|
|
5
|
+
export { useDictionaryDynamic } from './useDictionaryDynamic';
|
|
6
|
+
export { useIntlayer } from './useIntlayer';
|
|
7
|
+
export { useIntlayerAsync } from './useIntlayerAsync';
|
|
8
|
+
export { useLoadDynamic } from './useLoadDynamic';
|
|
9
|
+
export { useLocale } from './useLocale';
|
|
10
|
+
export { useLocaleBase } from './useLocaleBase';
|
|
11
|
+
export { localeCookie, setLocaleCookie, useLocaleCookie, } from './useLocaleCookie';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Locales } from '@intlayer/config/client';
|
|
2
|
+
import { type LanguageContent } from '@intlayer/core';
|
|
3
|
+
/**
|
|
4
|
+
* On the client side, this function returns the translation of the provided multilang content.
|
|
5
|
+
*
|
|
6
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
7
|
+
*/
|
|
8
|
+
export declare const t: <Content = string>(multilangContent: LanguageContent<Content>, locale?: Locales) => Content;
|
|
9
|
+
//# sourceMappingURL=t.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"t.d.ts","sourceRoot":"","sources":["../../../src/client/t.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,gBAAgB,CAAC;AAItE;;;;GAIG;AACH,eAAO,MAAM,CAAC,GAAI,OAAO,GAAG,MAAM,EAChC,kBAAkB,eAAe,CAAC,OAAO,CAAC,EAC1C,SAAS,OAAO,YAMjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LanguageContent } from '@intlayer/core';
|
|
2
|
+
/**
|
|
3
|
+
* On the client side, hook to get the translation content based on the locale
|
|
4
|
+
*/
|
|
5
|
+
export declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
|
|
6
|
+
locale: import("intlayer").LocalesValues;
|
|
7
|
+
content: Content;
|
|
8
|
+
t: <Content_1 = string>(languageContent: LanguageContent<Content_1>) => Content_1;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContent.d.ts","sourceRoot":"","sources":["../../../src/client/useContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,EAChC,iBAAiB,eAAe,CAAC,OAAO,CAAC;;;;CAW1C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
import type { Dictionary } from '@intlayer/core';
|
|
3
|
+
/**
|
|
4
|
+
* On the server side, Hook that transform a dictionary and return the content
|
|
5
|
+
*
|
|
6
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
7
|
+
*/
|
|
8
|
+
export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => any;
|
|
9
|
+
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,QAYvB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
import type { Dictionary, DictionaryKeys, LanguageContent } from '@intlayer/core';
|
|
3
|
+
/**
|
|
4
|
+
* On the server side, Hook that transform a dictionary and return the content
|
|
5
|
+
*
|
|
6
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
7
|
+
*/
|
|
8
|
+
export declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: LanguageContent<() => Promise<T>>, key: K, locale?: LocalesValues) => any;
|
|
9
|
+
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionaryDynamic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAMxB;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,cAAc,EAExB,mBAAmB,eAAe,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EACpD,KAAK,CAAC,EACN,SAAS,aAAa,QAWvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
import type { DictionaryKeys } from '@intlayer/core';
|
|
3
|
+
import type { IntlayerDictionaryTypesConnector } from 'intlayer';
|
|
4
|
+
import type { DeepTransformContent } from '../plugins';
|
|
5
|
+
/**
|
|
6
|
+
* On the client side, Hook that picking one dictionary by its key and return the content
|
|
7
|
+
*
|
|
8
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
9
|
+
*/
|
|
10
|
+
export declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>;
|
|
11
|
+
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAKjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAClD,KAAK,CAAC,EACN,SAAS,aAAa,KACrB,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAWrE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
import { type DictionaryKeys } from '@intlayer/core';
|
|
3
|
+
/**
|
|
4
|
+
* On the client side, Hook that picking one dictionary by its key and return the content
|
|
5
|
+
*
|
|
6
|
+
* This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
10
|
+
*/
|
|
11
|
+
export declare const useIntlayerAsync: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => import("@intlayer/core").DeepTransformContent<import("intlayer").IntlayerDictionaryTypesConnector[T]["content"], import("@intlayer/core").IInterpreterPluginState> & {
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useIntlayerAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntlayerAsync.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayerAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AAIxB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,cAAc,EACvD,KAAK,CAAC,EACN,SAAS,aAAa,KA6B6B,qKAA0B;IAC3E,SAAS,EAAE,OAAO,CAAC;CAEtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLoadDynamic.d.ts","sourceRoot":"","sources":["../../../src/client/useLoadDynamic.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,KAAK,MAAM,EAAE,SAAS,OAAO,CAAC,CAAC,CAAC,KAAG,CAMpE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
type useLocaleProps = {
|
|
3
|
+
onLocaleChange?: (locale: LocalesValues) => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* On the client side, hook to get the current locale and all related fields
|
|
7
|
+
*/
|
|
8
|
+
export declare const useLocale: ({ onLocaleChange }?: useLocaleProps) => {
|
|
9
|
+
locale: LocalesValues;
|
|
10
|
+
defaultLocale: import("intlayer").Locales;
|
|
11
|
+
availableLocales: import("intlayer").Locales[];
|
|
12
|
+
setLocale: (locale: LocalesValues) => void;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=useLocale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/client/useLocale.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAK7D,KAAK,cAAc,GAAG;IACpB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,qBAAoB,cAAmB;;;;wBASpC,aAAa;CAiBzC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On the client side, hook to get the current locale and all related fields
|
|
3
|
+
*/
|
|
4
|
+
export declare const useLocaleBase: () => {
|
|
5
|
+
locale: import("intlayer").LocalesValues;
|
|
6
|
+
defaultLocale: import("intlayer").Locales;
|
|
7
|
+
availableLocales: import("intlayer").Locales[];
|
|
8
|
+
setLocale: (newLocale: import("intlayer").LocalesValues) => void;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useLocaleBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocaleBase.d.ts","sourceRoot":"","sources":["../../../src/client/useLocaleBase.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;CASzB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
/**
|
|
3
|
+
* Get the locale cookie
|
|
4
|
+
*/
|
|
5
|
+
export declare const localeCookie: LocalesValues | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Set the locale cookie
|
|
8
|
+
*/
|
|
9
|
+
export declare const setLocaleCookie: (locale: LocalesValues) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Hook that provides the locale cookie and a function to set it
|
|
12
|
+
*/
|
|
13
|
+
export declare const useLocaleCookie: () => {
|
|
14
|
+
localeCookie: LocalesValues;
|
|
15
|
+
setLocaleCookie: (locale: LocalesValues) => void;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useLocaleCookie.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocaleCookie.d.ts","sourceRoot":"","sources":["../../../src/client/useLocaleCookie.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAc7D;;GAEG;AACH,eAAO,MAAM,YAAY,EACrB,aAAa,GACb,SAAS,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,aAAa,SAEpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;8BAPY,aAAa;CAUnD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type LanguageContent } from '@intlayer/core';
|
|
2
|
+
/**
|
|
3
|
+
* On the client side, Hook that picking one dictionary by its id and return the content.
|
|
4
|
+
*
|
|
5
|
+
* If not locale found, it will return the content related to the default locale.
|
|
6
|
+
*
|
|
7
|
+
* Return either the content editor, or the content itself depending on the configuration.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const content = useTranslation<string>({
|
|
13
|
+
* en: 'Hello',
|
|
14
|
+
* fr: 'Bonjour',
|
|
15
|
+
* }, 'fr');
|
|
16
|
+
* // 'Bonjour'
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Using TypeScript:
|
|
20
|
+
* - this function will require each locale to be defined if defined in the project configuration.
|
|
21
|
+
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useTranslation: <Content = string>(languageContent: LanguageContent<Content>) => Content;
|
|
24
|
+
//# sourceMappingURL=useTraduction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTraduction.d.ts","sourceRoot":"","sources":["../../../src/client/useTraduction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,GAAG,MAAM,EAC7C,iBAAiB,eAAe,CAAC,OAAO,CAAC,KACxC,OAIF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Dictionary } from '@intlayer/core';
|
|
2
|
+
import { type FC, type PropsWithChildren } from 'preact/compat';
|
|
3
|
+
type ChangedContentActionsContextType = {
|
|
4
|
+
setChangedContent: (dictionaryKey: Dictionary['key'], newValue: Dictionary['content']) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const ChangedContentProvider: FC<PropsWithChildren>;
|
|
7
|
+
export declare const useChangedContentActions: () => ChangedContentActionsContextType;
|
|
8
|
+
export declare const useChangedContent: () => {
|
|
9
|
+
setChangedContent: (dictionaryKey: Dictionary["key"], newValue: Dictionary["content"]) => void;
|
|
10
|
+
changedContent: Record<Dictionary["key"], Dictionary> | undefined;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=ChangedContentContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangedContentContext.d.ts","sourceRoot":"","sources":["../../../src/editor/ChangedContentContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAIL,KAAK,EAAE,EACP,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAC;AAWvB,KAAK,gCAAgC,GAAG;IACtC,iBAAiB,EAAE,CACjB,aAAa,EAAE,UAAU,CAAC,KAAK,CAAC,EAChC,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC,KAC5B,IAAI,CAAC;CACX,CAAC;AAMF,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,iBAAiB,CAiCxD,CAAC;AAEF,eAAO,MAAM,wBAAwB,wCAIpC,CAAC;AAEF,eAAO,MAAM,iBAAiB;uBAnDT,CACjB,aAAa,EAAE,UAAU,CAAC,KAAK,CAAC,EAChC,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC,KAC5B,IAAI;oBAXO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG,SAAS;CAgElE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ComponentChildren, type FunctionComponent } from 'preact';
|
|
2
|
+
export type UseCrossPlatformStateProps = {
|
|
3
|
+
postMessage: typeof window.postMessage;
|
|
4
|
+
allowedOrigins?: string[];
|
|
5
|
+
senderId: string;
|
|
6
|
+
};
|
|
7
|
+
export type CommunicatorProviderProps = {
|
|
8
|
+
children?: ComponentChildren;
|
|
9
|
+
postMessage: typeof window.postMessage;
|
|
10
|
+
allowedOrigins?: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare const CommunicatorProvider: FunctionComponent<CommunicatorProviderProps>;
|
|
13
|
+
export declare const useCommunicator: () => UseCrossPlatformStateProps;
|
|
14
|
+
//# sourceMappingURL=CommunicatorContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommunicatorContext.d.ts","sourceRoot":"","sources":["../../../src/editor/CommunicatorContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,QAAQ,CAAC;AAIhB,MAAM,MAAM,0BAA0B,GAAG;IACvC,WAAW,EAAE,OAAO,MAAM,CAAC,WAAW,CAAC;IACvC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAcF,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,WAAW,EAAE,OAAO,MAAM,CAAC,WAAW,CAAC;IACvC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAClD,yBAAyB,CAe1B,CAAC;AAEF,eAAO,MAAM,eAAe,kCAAwC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type IntlayerConfig } from '@intlayer/config/client';
|
|
2
|
+
import { type FC, type PropsWithChildren } from 'preact/compat';
|
|
3
|
+
export declare const useConfigurationState: () => [IntlayerConfig, import("preact/hooks").Dispatch<import("preact/hooks").StateUpdater<IntlayerConfig>>, () => void];
|
|
4
|
+
export type ConfigurationProviderProps = {
|
|
5
|
+
configuration?: IntlayerConfig;
|
|
6
|
+
};
|
|
7
|
+
export declare const ConfigurationProvider: FC<PropsWithChildren<ConfigurationProviderProps>>;
|
|
8
|
+
export declare const useConfiguration: () => IntlayerConfig;
|
|
9
|
+
//# sourceMappingURL=ConfigurationContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigurationContext.d.ts","sourceRoot":"","sources":["../../../src/editor/ConfigurationContext.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EACL,KAAK,EAAE,EACP,KAAK,iBAAiB,EAGvB,MAAM,eAAe,CAAC;AAOvB,eAAO,MAAM,qBAAqB,0HAQ/B,CAAC;AAEJ,MAAM,MAAM,0BAA0B,GAAG;IACvC,aAAa,CAAC,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,EAAE,CACpC,iBAAiB,CAAC,0BAA0B,CAAC,CAK9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,sBAA+C,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type NodeProps } from '@intlayer/core';
|
|
2
|
+
import { type FC, type HTMLAttributes } from 'preact/compat';
|
|
3
|
+
export type ContentSelectorWrapperProps = NodeProps & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
4
|
+
export declare const ContentSelectorRenderer: FC<ContentSelectorWrapperProps>;
|
|
5
|
+
//# sourceMappingURL=ContentSelectorWrapper.d.ts.map
|