react-intlayer 4.1.11 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/{getEnumeration.cjs → IntlayerNode.cjs} +14 -13
- package/dist/cjs/IntlayerNode.cjs.map +1 -0
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +2 -5
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/t.cjs +2 -2
- package/dist/cjs/client/t.cjs.map +1 -1
- package/dist/cjs/client/useContent.cjs +2 -2
- package/dist/cjs/client/useContent.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +3 -3
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +7 -4
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useIntlayerAsync.cjs +3 -4
- package/dist/cjs/client/useIntlayerAsync.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleCookie.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.cjs +5 -5
- package/dist/cjs/client/useTraduction.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -3
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +3 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/renderContentEditor.cjs +5 -4
- package/dist/cjs/editor/renderContentEditor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +13 -13
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +10 -29
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +5 -13
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/{getIntlayerAsync.cjs → markdown/MarkdownProvider.cjs} +18 -19
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -0
- package/dist/cjs/{server/useTraduction.cjs → markdown/MarkdownRenderer.cjs} +17 -12
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -0
- package/dist/cjs/markdown/index.cjs +27 -0
- package/dist/cjs/markdown/index.cjs.map +1 -0
- package/dist/cjs/{getTranslation.cjs → markdown/renderMarkdown.cjs} +13 -16
- package/dist/cjs/markdown/renderMarkdown.cjs.map +1 -0
- package/dist/cjs/plugins.cjs +85 -0
- package/dist/cjs/plugins.cjs.map +1 -0
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
- package/dist/cjs/server/index.cjs +2 -8
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/t.cjs +5 -3
- package/dist/cjs/server/t.cjs.map +1 -1
- package/dist/cjs/server/useDictionary.cjs +2 -2
- package/dist/cjs/server/useDictionary.cjs.map +1 -1
- package/dist/cjs/server/useIntlayer.cjs +2 -2
- package/dist/cjs/server/useIntlayer.cjs.map +1 -1
- package/dist/esm/IntlayerNode.mjs +16 -0
- package/dist/esm/IntlayerNode.mjs.map +1 -0
- package/dist/esm/UI/ContentSelector.mjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/index.mjs +1 -3
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/t.mjs +1 -1
- package/dist/esm/client/t.mjs.map +1 -1
- package/dist/esm/client/useContent.mjs +3 -3
- package/dist/esm/client/useContent.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +3 -3
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +8 -7
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useIntlayerAsync.mjs +5 -5
- package/dist/esm/client/useIntlayerAsync.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +1 -1
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
- package/dist/esm/client/useTraduction.mjs +3 -3
- package/dist/esm/client/useTraduction.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs +1 -3
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs +3 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
- package/dist/esm/editor/renderContentEditor.mjs +5 -4
- package/dist/esm/editor/renderContentEditor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +18 -14
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +15 -20
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +3 -9
- 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 +16 -0
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -0
- package/dist/esm/markdown/index.mjs +4 -0
- package/dist/esm/markdown/index.mjs.map +1 -0
- package/dist/esm/markdown/renderMarkdown.mjs +11 -0
- package/dist/esm/markdown/renderMarkdown.mjs.map +1 -0
- package/dist/esm/plugins.mjs +61 -0
- package/dist/esm/plugins.mjs.map +1 -0
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
- package/dist/esm/server/index.mjs +1 -5
- package/dist/esm/server/index.mjs.map +1 -1
- package/dist/esm/server/t.mjs +4 -2
- package/dist/esm/server/t.mjs.map +1 -1
- package/dist/esm/server/useDictionary.mjs +2 -2
- package/dist/esm/server/useDictionary.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.mjs +2 -4
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/types/IntlayerNode.d.ts +9 -0
- package/dist/types/IntlayerNode.d.ts.map +1 -0
- package/dist/types/UI/ContentSelector.d.ts +1 -1
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +4 -4
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +0 -1
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/t.d.ts +1 -1
- package/dist/types/client/t.d.ts.map +1 -1
- package/dist/types/client/useContent.d.ts +1 -1
- package/dist/types/client/useDictionary.d.ts +3 -2
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +4 -2
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useIntlayerAsync.d.ts +4 -5
- package/dist/types/client/useIntlayerAsync.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +3 -3
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +2 -2
- package/dist/types/client/useLocaleCookie.d.ts +4 -4
- package/dist/types/client/useLocaleCookie.d.ts.map +1 -1
- package/dist/types/client/useTraduction.d.ts +3 -3
- package/dist/types/client/useTraduction.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts +2 -8
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
- package/dist/types/editor/renderContentEditor.d.ts +3 -7
- package/dist/types/editor/renderContentEditor.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +4 -12
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +4 -34
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -5
- 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 +5 -0
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -0
- package/dist/types/markdown/index.d.ts +4 -0
- package/dist/types/markdown/index.d.ts.map +1 -0
- package/dist/types/markdown/renderMarkdown.d.ts +3 -0
- package/dist/types/markdown/renderMarkdown.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +48 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/server/IntlayerServerProvider.d.ts +7 -7
- package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +0 -2
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/t.d.ts +20 -4
- package/dist/types/server/t.d.ts.map +1 -1
- package/dist/types/server/useDictionary.d.ts +3 -2
- package/dist/types/server/useDictionary.d.ts.map +1 -1
- package/dist/types/server/useIntlayer.d.ts +3 -2
- package/dist/types/server/useIntlayer.d.ts.map +1 -1
- package/package.json +15 -15
- package/dist/cjs/getEnumeration.cjs.map +0 -1
- package/dist/cjs/getIntlayerAsync.cjs.map +0 -1
- package/dist/cjs/getTranslation.cjs.map +0 -1
- package/dist/cjs/processDictionary/contentDictionary.cjs +0 -17
- package/dist/cjs/processDictionary/contentDictionary.cjs.map +0 -1
- package/dist/cjs/processDictionary/index.cjs +0 -201
- package/dist/cjs/processDictionary/index.cjs.map +0 -1
- package/dist/cjs/recursiveTransformContent.cjs +0 -54
- package/dist/cjs/recursiveTransformContent.cjs.map +0 -1
- package/dist/cjs/server/getLocaleTranslation.cjs +0 -43
- package/dist/cjs/server/getLocaleTranslation.cjs.map +0 -1
- package/dist/cjs/server/useTraduction.cjs.map +0 -1
- package/dist/esm/getEnumeration.mjs +0 -12
- package/dist/esm/getEnumeration.mjs.map +0 -1
- package/dist/esm/getIntlayerAsync.mjs +0 -18
- package/dist/esm/getIntlayerAsync.mjs.map +0 -1
- package/dist/esm/getTranslation.mjs +0 -14
- package/dist/esm/getTranslation.mjs.map +0 -1
- package/dist/esm/processDictionary/contentDictionary.mjs +0 -1
- package/dist/esm/processDictionary/contentDictionary.mjs.map +0 -1
- package/dist/esm/processDictionary/index.mjs +0 -179
- package/dist/esm/processDictionary/index.mjs.map +0 -1
- package/dist/esm/recursiveTransformContent.mjs +0 -32
- package/dist/esm/recursiveTransformContent.mjs.map +0 -1
- package/dist/esm/server/getLocaleTranslation.mjs +0 -19
- package/dist/esm/server/getLocaleTranslation.mjs.map +0 -1
- package/dist/esm/server/useTraduction.mjs +0 -11
- package/dist/esm/server/useTraduction.mjs.map +0 -1
- package/dist/types/getEnumeration.d.ts +0 -31
- package/dist/types/getEnumeration.d.ts.map +0 -1
- package/dist/types/getIntlayerAsync.d.ts +0 -13
- package/dist/types/getIntlayerAsync.d.ts.map +0 -1
- package/dist/types/getTranslation.d.ts +0 -25
- package/dist/types/getTranslation.d.ts.map +0 -1
- package/dist/types/processDictionary/contentDictionary.d.ts +0 -14
- package/dist/types/processDictionary/contentDictionary.d.ts.map +0 -1
- package/dist/types/processDictionary/index.d.ts +0 -9
- package/dist/types/processDictionary/index.d.ts.map +0 -1
- package/dist/types/recursiveTransformContent.d.ts +0 -27
- package/dist/types/recursiveTransformContent.d.ts.map +0 -1
- package/dist/types/server/getLocaleTranslation.d.ts +0 -9
- package/dist/types/server/getLocaleTranslation.d.ts.map +0 -1
- package/dist/types/server/useTraduction.d.ts +0 -24
- package/dist/types/server/useTraduction.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n type DictionaryKeys,\n type Plugins,\n getIntlayer as getIntlayerCore,\n} from '@intlayer/core';\nimport {\n type DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n reactNodePlugins,\n} from './plugins';\nimport type { IntlayerDictionaryTypesConnector, Locales } from 'intlayer';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends Locales | `${Locales}`,\n>(\n key: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n reactNodePlugins,\n markdownPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getIntlayerCore(key, locale, plugins) as any as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAIO;AACP,qBAKO;AAGA,MAAM,cAAc,CAIzB,KACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,aAAO,YAAAA,aAAgB,KAAK,QAAQ,OAAO;AAG7C;","names":["getIntlayerCore"]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -20,10 +20,8 @@ var index_exports = {};
|
|
|
20
20
|
__export(index_exports, {
|
|
21
21
|
IntlayerClientContext: () => import_client.IntlayerClientContext,
|
|
22
22
|
IntlayerProvider: () => import_client.IntlayerProvider,
|
|
23
|
+
MarkdownProvider: () => import_markdown.MarkdownProvider,
|
|
23
24
|
getBrowserLocale: () => import_client.getBrowserLocale,
|
|
24
|
-
getDictionary: () => import_getDictionary.getDictionary,
|
|
25
|
-
getIntlayer: () => import_getIntlayer.getIntlayer,
|
|
26
|
-
getTranslation: () => import_getTranslation.getTranslation,
|
|
27
25
|
localeCookie: () => import_client.localeCookie,
|
|
28
26
|
setLocaleCookie: () => import_client.setLocaleCookie,
|
|
29
27
|
t: () => import_client.t,
|
|
@@ -33,22 +31,17 @@ __export(index_exports, {
|
|
|
33
31
|
useIntlayerContext: () => import_client.useIntlayerContext,
|
|
34
32
|
useLocale: () => import_client.useLocale,
|
|
35
33
|
useLocaleBase: () => import_client.useLocaleBase,
|
|
36
|
-
useLocaleCookie: () => import_client.useLocaleCookie
|
|
37
|
-
useTraduction: () => import_client.useTraduction
|
|
34
|
+
useLocaleCookie: () => import_client.useLocaleCookie
|
|
38
35
|
});
|
|
39
36
|
module.exports = __toCommonJS(index_exports);
|
|
40
|
-
var import_getTranslation = require('./getTranslation.cjs');
|
|
41
37
|
var import_client = require('./client/index.cjs');
|
|
42
|
-
var
|
|
43
|
-
var import_getIntlayer = require('./getIntlayer.cjs');
|
|
38
|
+
var import_markdown = require('./markdown/index.cjs');
|
|
44
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
40
|
0 && (module.exports = {
|
|
46
41
|
IntlayerClientContext,
|
|
47
42
|
IntlayerProvider,
|
|
43
|
+
MarkdownProvider,
|
|
48
44
|
getBrowserLocale,
|
|
49
|
-
getDictionary,
|
|
50
|
-
getIntlayer,
|
|
51
|
-
getTranslation,
|
|
52
45
|
localeCookie,
|
|
53
46
|
setLocaleCookie,
|
|
54
47
|
t,
|
|
@@ -58,7 +51,6 @@ var import_getIntlayer = require('./getIntlayer.cjs');
|
|
|
58
51
|
useIntlayerContext,
|
|
59
52
|
useLocale,
|
|
60
53
|
useLocaleBase,
|
|
61
|
-
useLocaleCookie
|
|
62
|
-
useTraduction
|
|
54
|
+
useLocaleCookie
|
|
63
55
|
});
|
|
64
56
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginReact<T, S> {}\n}\n\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useIntlayerAsync,\n useDictionary,\n useLocale,\n useLocaleCookie,\n useIntlayerContext,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n t,\n} from './client/index';\nexport { type IntlayerNode } from './IntlayerNode';\nexport { MarkdownProvider } from './markdown/index';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAeO;AAEP,sBAAiC;","names":[]}
|
|
@@ -17,26 +17,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
22
|
-
|
|
20
|
+
var MarkdownProvider_exports = {};
|
|
21
|
+
__export(MarkdownProvider_exports, {
|
|
22
|
+
MarkdownProvider: () => MarkdownProvider,
|
|
23
|
+
useMarkdownContext: () => useMarkdownContext
|
|
23
24
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
};
|
|
25
|
+
module.exports = __toCommonJS(MarkdownProvider_exports);
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
const MarkdownContext = (0, import_react.createContext)({
|
|
29
|
+
renderMarkdown: (markdown) => markdown
|
|
30
|
+
});
|
|
31
|
+
const useMarkdownContext = () => (0, import_react.useContext)(MarkdownContext);
|
|
32
|
+
const MarkdownProvider = ({
|
|
33
|
+
children,
|
|
34
|
+
renderMarkdown
|
|
35
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkdownContext.Provider, { value: { renderMarkdown }, children });
|
|
38
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
37
|
0 && (module.exports = {
|
|
40
|
-
|
|
38
|
+
MarkdownProvider,
|
|
39
|
+
useMarkdownContext
|
|
41
40
|
});
|
|
42
|
-
//# sourceMappingURL=
|
|
41
|
+
//# sourceMappingURL=MarkdownProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n useContext,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n} from 'react';\n\ntype MarkdownContextValue = {\n renderMarkdown: (markdown: string) => ReactNode;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<MarkdownContextValue>;\n\nconst MarkdownContext = createContext<MarkdownContextValue>({\n renderMarkdown: (markdown: string) => markdown,\n});\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nexport const MarkdownProvider: FC<MarkdownProviderProps> = ({\n children,\n renderMarkdown,\n}) => (\n <MarkdownContext.Provider value={{ renderMarkdown }}>\n {children}\n </MarkdownContext.Provider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BE;AAxBF,mBAMO;AAQP,MAAM,sBAAkB,4BAAoC;AAAA,EAC1D,gBAAgB,CAAC,aAAqB;AACxC,CAAC;AAEM,MAAM,qBAAqB,UAAM,yBAAW,eAAe;AAE3D,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AACF,MACE,4CAAC,gBAAgB,UAAhB,EAAyB,OAAO,EAAE,eAAe,GAC/C,UACH;","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -16,20 +17,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
17
|
return to;
|
|
17
18
|
};
|
|
18
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
20
|
+
var MarkdownRenderer_exports = {};
|
|
21
|
+
__export(MarkdownRenderer_exports, {
|
|
22
|
+
MarkdownRenderer: () => MarkdownRenderer
|
|
22
23
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
module.exports = __toCommonJS(MarkdownRenderer_exports);
|
|
25
|
+
var import_MarkdownProvider = require('./MarkdownProvider.cjs');
|
|
26
|
+
var import_IntlayerNode = require('../IntlayerNode.cjs');
|
|
27
|
+
const MarkdownRenderer = ({
|
|
28
|
+
markdown
|
|
29
|
+
}) => {
|
|
30
|
+
const { renderMarkdown } = (0, import_MarkdownProvider.useMarkdownContext)();
|
|
31
|
+
return (0, import_IntlayerNode.rendererIntlayerNode)({
|
|
32
|
+
value: markdown,
|
|
33
|
+
children: renderMarkdown(markdown)
|
|
34
|
+
});
|
|
30
35
|
};
|
|
31
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
37
|
0 && (module.exports = {
|
|
33
|
-
|
|
38
|
+
MarkdownRenderer
|
|
34
39
|
});
|
|
35
|
-
//# sourceMappingURL=
|
|
40
|
+
//# sourceMappingURL=MarkdownRenderer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport { FC } from 'react';\nimport { useMarkdownContext } from './MarkdownProvider';\nimport { IntlayerNode, rendererIntlayerNode } from '../IntlayerNode';\n\nexport const MarkdownRenderer: FC<{ markdown: string }> = ({\n markdown,\n}): IntlayerNode => {\n const { renderMarkdown } = useMarkdownContext();\n\n return rendererIntlayerNode({\n value: markdown,\n children: renderMarkdown(markdown),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,8BAAmC;AACnC,0BAAmD;AAE5C,MAAM,mBAA6C,CAAC;AAAA,EACzD;AACF,MAAoB;AAClB,QAAM,EAAE,eAAe,QAAI,4CAAmB;AAE9C,aAAO,0CAAqB;AAAA,IAC1B,OAAO;AAAA,IACP,UAAU,eAAe,QAAQ;AAAA,EACnC,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var markdown_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(markdown_exports);
|
|
18
|
+
__reExport(markdown_exports, require('./MarkdownProvider.cjs'), module.exports);
|
|
19
|
+
__reExport(markdown_exports, require('./MarkdownRenderer.cjs'), module.exports);
|
|
20
|
+
__reExport(markdown_exports, require('./renderMarkdown.cjs'), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require('./MarkdownProvider.cjs'),
|
|
24
|
+
...require('./MarkdownRenderer.cjs'),
|
|
25
|
+
...require('./renderMarkdown.cjs')
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["export * from './MarkdownProvider';\nexport * from './MarkdownRenderer';\nexport * from './renderMarkdown';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,+BAAd;AACA,6BAAc,+BADd;AAEA,6BAAc,6BAFd;","names":[]}
|
|
@@ -16,23 +16,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var renderMarkdown_exports = {};
|
|
20
|
+
__export(renderMarkdown_exports, {
|
|
21
|
+
renderMarkdown: () => renderMarkdown
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(renderMarkdown_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_IntlayerNode = require('../IntlayerNode.cjs');
|
|
26
|
+
var import_MarkdownRenderer = require('./MarkdownRenderer.cjs');
|
|
27
|
+
const renderMarkdown = (markdown) => (0, import_IntlayerNode.rendererIntlayerNode)({
|
|
28
|
+
value: markdown,
|
|
29
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MarkdownRenderer.MarkdownRenderer, { markdown })
|
|
22
30
|
});
|
|
23
|
-
module.exports = __toCommonJS(getTranslation_exports);
|
|
24
|
-
var import_client = require("@intlayer/config/client");
|
|
25
|
-
var import_core = require("@intlayer/core");
|
|
26
|
-
const getTranslation = (languageContent, locale) => {
|
|
27
|
-
const { defaultLocale } = (0, import_client.getConfiguration)().internationalization;
|
|
28
|
-
const result = (0, import_core.getTranslationContent)(
|
|
29
|
-
languageContent,
|
|
30
|
-
locale ?? defaultLocale
|
|
31
|
-
);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
32
|
0 && (module.exports = {
|
|
36
|
-
|
|
33
|
+
renderMarkdown
|
|
37
34
|
});
|
|
38
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=renderMarkdown.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/renderMarkdown.tsx"],"sourcesContent":["import { type IntlayerNode, rendererIntlayerNode } from '../IntlayerNode';\nimport { MarkdownRenderer } from './MarkdownRenderer';\n\nexport const renderMarkdown = (markdown: string): IntlayerNode =>\n rendererIntlayerNode({\n value: markdown,\n children: <MarkdownRenderer markdown={markdown} />,\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMc;AANd,0BAAwD;AACxD,8BAAiC;AAE1B,MAAM,iBAAiB,CAAC,iBAC7B,0CAAqB;AAAA,EACnB,OAAO;AAAA,EACP,UAAU,4CAAC,4CAAiB,UAAoB;AAClD,CAAC;","names":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
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 plugins_exports = {};
|
|
20
|
+
__export(plugins_exports, {
|
|
21
|
+
intlayerNodePlugins: () => intlayerNodePlugins,
|
|
22
|
+
markdownPlugin: () => markdownPlugin,
|
|
23
|
+
reactNodePlugins: () => reactNodePlugins
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(plugins_exports);
|
|
26
|
+
var import_core = require("@intlayer/core");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_editor = require('./editor/index.cjs');
|
|
29
|
+
var import_renderMarkdown = require('./markdown/renderMarkdown.cjs');
|
|
30
|
+
const intlayerNodePlugins = {
|
|
31
|
+
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
32
|
+
transform: (_node, {
|
|
33
|
+
plugins,
|
|
34
|
+
// Removed to avoid next error - Functions cannot be passed directly to Client Components
|
|
35
|
+
...rest
|
|
36
|
+
}) => (0, import_editor.renderIntlayerEditor)(rest)
|
|
37
|
+
};
|
|
38
|
+
const createReactElement = (element) => {
|
|
39
|
+
if (typeof element === "string") {
|
|
40
|
+
return element;
|
|
41
|
+
}
|
|
42
|
+
const convertChildrenAsArray = (element2) => {
|
|
43
|
+
if (element2?.props && typeof element2.props.children === "object") {
|
|
44
|
+
const childrenResult = [];
|
|
45
|
+
const { children } = element2.props;
|
|
46
|
+
Object.keys(children ?? {}).forEach((key) => {
|
|
47
|
+
childrenResult.push(
|
|
48
|
+
createReactElement((children ?? {})[key])
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
...element2,
|
|
53
|
+
props: { ...element2.props, children: childrenResult }
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
...element2,
|
|
58
|
+
props: { ...element2.props, children: element2.props.children }
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
const fixedElement = convertChildrenAsArray(
|
|
62
|
+
element
|
|
63
|
+
);
|
|
64
|
+
const { type, props } = fixedElement;
|
|
65
|
+
return (0, import_react.createElement)(
|
|
66
|
+
type ?? "div",
|
|
67
|
+
props,
|
|
68
|
+
...props.children
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
const reactNodePlugins = {
|
|
72
|
+
canHandle: (node) => typeof node === "object" && typeof node.ref !== "undefined" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
|
|
73
|
+
transform: createReactElement
|
|
74
|
+
};
|
|
75
|
+
const markdownPlugin = {
|
|
76
|
+
canHandle: (node) => typeof node === "object" && node?.nodeType === import_core.NodeType.Markdown,
|
|
77
|
+
transform: (node) => (0, import_renderMarkdown.renderMarkdown)(node[import_core.NodeType.Markdown])
|
|
78
|
+
};
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
intlayerNodePlugins,
|
|
82
|
+
markdownPlugin,
|
|
83
|
+
reactNodePlugins
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=plugins.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n type Plugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type DeepTransformContent as DeepTransformContentCore,\n type MarkdownContent,\n NodeType,\n} from '@intlayer/core';\nimport { type ReactElement, type ReactNode, createElement } from 'react';\nimport { renderIntlayerEditor } from './editor';\nimport type { IntlayerNode } from './IntlayerNode';\nimport { renderMarkdown } from './markdown/renderMarkdown';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T, _S> = 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 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 ) => renderIntlayerEditor(rest),\n};\n\n/** ---------------------------------------------\n * REACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type ReactNodeCond<T, _S> = T extends {\n ref: any;\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\n\n// This function recursively creates React elements from a given JSON-like structure\nconst createReactElement = (element: ReactElement) => {\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: ReactElement<{ children?: ReactNode }>\n ): ReactElement<{ children?: ReactNode }> => {\n if (element?.props && typeof element.props.children === 'object') {\n const childrenResult: ReactNode[] = [];\n const { children } = element.props;\n\n // Create the children elements recursively, if any\n Object.keys(children ?? {}).forEach((key) => {\n childrenResult.push(\n createReactElement((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 ReactElement<{ children?: ReactNode }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(\n type ?? 'div',\n props,\n ...(props.children as ReactNode[])\n );\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.ref !== 'undefined' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: createReactElement,\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownCond<T, _S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: string;\n}\n ? IntlayerNode<string>\n : never;\n\n/** Markdown plugin. Replaces node with a function that takes quantity => string. */\nexport const markdownPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent) => renderMarkdown(node[NodeType.Markdown]),\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginReact<T, _S> {\n reactNode: ReactNodeCond<T, _S>;\n intlayerNode: IntlayerNodeCond<T, _S>;\n markdown: MarkdownCond<T, _S>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n reactNode: true;\n intlayerNode: true;\n markdown: true;\n};\n\nexport type DeepTransformContent<T> = DeepTransformContentCore<\n T,\n IInterpreterPluginState\n>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAMO;AACP,mBAAiE;AACjE,oBAAqC;AAErC,4BAA+B;AAWxB,MAAM,sBAA+B;AAAA,EAC1C,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CACT,OACA;AAAA,IACE;AAAA;AAAA,IACA,GAAG;AAAA,EACL,UACG,oCAAqB,IAAI;AAChC;AAeA,MAAM,qBAAqB,CAAC,YAA0B;AACpD,MAAI,OAAO,YAAY,UAAU;AAE/B,WAAO;AAAA,EACT;AAEA,QAAM,yBAAyB,CAC7BA,aAC2C;AAC3C,QAAIA,UAAS,SAAS,OAAOA,SAAQ,MAAM,aAAa,UAAU;AAChE,YAAM,iBAA8B,CAAC;AACrC,YAAM,EAAE,SAAS,IAAIA,SAAQ;AAG7B,aAAO,KAAK,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ;AAC3C,uBAAe;AAAA,UACb,oBAAoB,YAAY,CAAC,GAAG,GAA4B,CAAC;AAAA,QACnE;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,MAAM,SAAS;AAAA,IAC9D;AAAA,EACF;AAEA,QAAM,eAAe;AAAA,IACnB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,MAAM,IAAI;AAGxB,aAAO;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA,GAAI,MAAM;AAAA,EACZ;AACF;AAGO,MAAM,mBAA4B;AAAA,EACvC,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,KAAK,QAAQ,eACpB,OAAO,KAAK,UAAU,eACtB,OAAO,KAAK,QAAQ;AAAA,EAEtB,WAAW;AACb;AAcO,MAAM,iBAA0B;AAAA,EACrC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,aAA0B,sCAAe,KAAK,qBAAS,QAAQ,CAAC;AAC9E;","names":["element"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = getConfiguration().internationalization;\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext
|
|
1
|
+
{"version":3,"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = getConfiguration().internationalization;\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext = createServerContext<\n Locales | `${Locales}`\n>(defaultLocale);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: Locales | `${Locales}`;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n {children}\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkCE;AAlCF,oBAA+C;AAE/C,2BAAsD;AAEtD,MAAM,EAAE,cAAc,QAAI,gCAAiB,EAAE;AAKtC,MAAM,4BAAwB,0CAEnC,aAAa;AAKR,MAAM,cAAc,UAAM,uCAAiB,qBAAqB;AAKhE,MAAM,aAAS,uCAAiB,qBAAqB;AASrD,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,QAAAA,UAAS;AACX,MACE,4CAAC,sBAAsB,UAAtB,EAA+B,OAAOA,SACpC,UACH;","names":["locale"]}
|
|
@@ -20,16 +20,12 @@ var server_exports = {};
|
|
|
20
20
|
__export(server_exports, {
|
|
21
21
|
IntlayerServer: () => import_IntlayerServerProvider.IntlayerServerContext,
|
|
22
22
|
IntlayerServerProvider: () => import_IntlayerServerProvider.IntlayerServerProvider,
|
|
23
|
-
getLocaleContent: () => import_getLocaleTranslation.getLocaleTranslation,
|
|
24
23
|
locale: () => import_IntlayerServerProvider.locale,
|
|
25
24
|
t: () => import_t.t,
|
|
26
25
|
useDictionary: () => import_useDictionary.useDictionary,
|
|
27
|
-
useIntlayer: () => import_useIntlayer.useIntlayer
|
|
28
|
-
useTraduction: () => import_useTraduction.useTraduction
|
|
26
|
+
useIntlayer: () => import_useIntlayer.useIntlayer
|
|
29
27
|
});
|
|
30
28
|
module.exports = __toCommonJS(server_exports);
|
|
31
|
-
var import_getLocaleTranslation = require('./getLocaleTranslation.cjs');
|
|
32
|
-
var import_useTraduction = require('./useTraduction.cjs');
|
|
33
29
|
var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
34
30
|
var import_useIntlayer = require('./useIntlayer.cjs');
|
|
35
31
|
var import_useDictionary = require('./useDictionary.cjs');
|
|
@@ -38,11 +34,9 @@ var import_t = require('./t.cjs');
|
|
|
38
34
|
0 && (module.exports = {
|
|
39
35
|
IntlayerServer,
|
|
40
36
|
IntlayerServerProvider,
|
|
41
|
-
getLocaleContent,
|
|
42
37
|
locale,
|
|
43
38
|
t,
|
|
44
39
|
useDictionary,
|
|
45
|
-
useIntlayer
|
|
46
|
-
useTraduction
|
|
40
|
+
useIntlayer
|
|
47
41
|
});
|
|
48
42
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServerContext as IntlayerServer,\n locale,\n IntlayerServerProvider,\n} from './IntlayerServerProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useDictionary } from './useDictionary';\nexport { t } from './t';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAIO;AACP,yBAA4B;AAC5B,2BAA8B;AAC9B,eAAkB;","names":[]}
|
package/dist/cjs/server/t.cjs
CHANGED
|
@@ -21,13 +21,15 @@ __export(t_exports, {
|
|
|
21
21
|
t: () => t
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(t_exports);
|
|
24
|
-
var import_getTranslation = require('../getTranslation.cjs');
|
|
25
24
|
var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
26
25
|
var import_serverContext = require('./serverContext.cjs');
|
|
26
|
+
var import_core = require("@intlayer/core");
|
|
27
27
|
const t = (multilangContent, locale) => {
|
|
28
|
-
const currentLocale = (0, import_serverContext.getServerContext)(
|
|
28
|
+
const currentLocale = (0, import_serverContext.getServerContext)(
|
|
29
|
+
import_IntlayerServerProvider.IntlayerServerContext
|
|
30
|
+
);
|
|
29
31
|
const localeTarget = locale ?? currentLocale;
|
|
30
|
-
return (0,
|
|
32
|
+
return (0, import_core.getTranslation)(multilangContent, localeTarget);
|
|
31
33
|
};
|
|
32
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
35
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/t.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/server/t.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { type LanguageContent, getTranslation } from '@intlayer/core';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = t<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const t = <Content = string>(\n multilangContent: LanguageContent<Content>,\n locale?: Locales | `${Locales}`\n) => {\n const currentLocale = getServerContext<Locales | `${Locales}`>(\n IntlayerServerContext\n );\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAAsC;AACtC,2BAAiC;AACjC,kBAAqD;AAuB9C,MAAM,IAAI,CACf,kBACA,WACG;AACH,QAAM,oBAAgB;AAAA,IACpB;AAAA,EACF;AACA,QAAM,eAAe,UAAU;AAE/B,aAAO,4BAAwB,kBAAkB,YAAY;AAC/D;","names":[]}
|
|
@@ -21,12 +21,12 @@ __export(useDictionary_exports, {
|
|
|
21
21
|
useDictionary: () => useDictionary
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(useDictionary_exports);
|
|
24
|
-
var import_getDictionary = require('../getDictionary.cjs');
|
|
25
24
|
var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
26
25
|
var import_serverContext = require('./serverContext.cjs');
|
|
26
|
+
var import_getDictionary = require('../getDictionary.cjs');
|
|
27
27
|
const useDictionary = (dictionary, locale, isRenderEditor = false) => {
|
|
28
28
|
const localeTarget = locale ?? (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
|
-
return (0, import_getDictionary.getDictionary)(dictionary, localeTarget
|
|
29
|
+
return (0, import_getDictionary.getDictionary)(dictionary, localeTarget);
|
|
30
30
|
};
|
|
31
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
32
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type
|
|
1
|
+
{"version":3,"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport { type Dictionary } from '@intlayer/core';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { getDictionary } from '../getDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: Locales | `${Locales}`,\n isRenderEditor = false\n) => {\n const localeTarget =\n locale ?? getServerContext<Locales | `${Locales}`>(IntlayerServerContext);\n\n return getDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oCAAsC;AACtC,2BAAiC;AACjC,2BAA8B;AAOvB,MAAM,gBAAgB,CAC3B,YACA,QACA,iBAAiB,UACd;AACH,QAAM,eACJ,cAAU,uCAAyC,mDAAqB;AAE1E,aAAO,oCAAc,YAAY,YAAY;AAC/C;","names":[]}
|
|
@@ -21,12 +21,12 @@ __export(useIntlayer_exports, {
|
|
|
21
21
|
useIntlayer: () => useIntlayer
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(useIntlayer_exports);
|
|
24
|
-
var import_getIntlayer = require('../getIntlayer.cjs');
|
|
25
24
|
var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
26
25
|
var import_serverContext = require('./serverContext.cjs');
|
|
26
|
+
var import_getIntlayer = require('../getIntlayer.cjs');
|
|
27
27
|
const useIntlayer = (key, locale, isRenderEditor = true) => {
|
|
28
28
|
const localeTarget = locale ?? (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
29
|
-
return (0, import_getIntlayer.getIntlayer)(key, localeTarget
|
|
29
|
+
return (0, import_getIntlayer.getIntlayer)(key, localeTarget);
|
|
30
30
|
};
|
|
31
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
32
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { type DictionaryKeys } from '@intlayer/core';\nimport { getIntlayer } from '../getIntlayer';\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n T extends DictionaryKeys,\n K extends Locales | `${Locales}`,\n>(\n key: T,\n locale?: K,\n isRenderEditor = true\n) => {\n const localeTarget =\n locale ?? getServerContext<Locales | `${Locales}`>(IntlayerServerContext);\n\n return getIntlayer(key, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAAsC;AACtC,2BAAiC;AAEjC,yBAA4B;AAOrB,MAAM,cAAc,CAIzB,KACA,QACA,iBAAiB,SACd;AACH,QAAM,eACJ,cAAU,uCAAyC,mDAAqB;AAE1E,aAAO,gCAAY,KAAK,YAAY;AACtC;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
cloneElement,
|
|
4
|
+
isValidElement
|
|
5
|
+
} from "react";
|
|
6
|
+
const rendererIntlayerNode = ({
|
|
7
|
+
value,
|
|
8
|
+
children
|
|
9
|
+
}) => {
|
|
10
|
+
const element = isValidElement(children) ? children : /* @__PURE__ */ jsx(Fragment, { children });
|
|
11
|
+
return { ...cloneElement(element), value };
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
rendererIntlayerNode
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=IntlayerNode.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core';\nimport {\n type PropsWithChildren,\n type ReactNode,\n type ReactElement,\n cloneElement,\n isValidElement,\n} from 'react';\n\nexport type IntlayerNode<T = NodeProps['content']> = ReactNode & {\n value: T;\n};\n\nexport const rendererIntlayerNode = <\n T extends number | string | boolean | undefined | null,\n>({\n value,\n children,\n}: PropsWithChildren<{\n value: T;\n}>): IntlayerNode => {\n // If children is not a valid ReactElement, wrap it in a fragment\n const element: ReactElement = isValidElement(children) ? (\n children\n ) : (\n <>{children}</>\n );\n\n // Use React.cloneElement to add the \"value\" prop to the element\n return { ...cloneElement(element), value };\n};\n"],"mappings":"AAyBI;AAxBJ;AAAA,EAIE;AAAA,EACA;AAAA,OACK;AAMA,MAAM,uBAAuB,CAElC;AAAA,EACA;AAAA,EACA;AACF,MAEqB;AAEnB,QAAM,UAAwB,eAAe,QAAQ,IACnD,WAEA,gCAAG,UAAS;AAId,SAAO,EAAE,GAAG,aAAa,OAAO,GAAG,MAAM;AAC3C;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n type HTMLAttributes,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n };\n\n const handleMouseUp = () => {\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: 'inline',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";AAqGI;AAnGJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP,MAAM,gCAAgC;AAS/B,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,GAAG;AACL,MAAM;AACJ,QAAM,SAAS,OAAuB,IAAI;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,eAAe;AACxE,QAAM,gBAAgB,OAA6C,IAAI;AAEvE,QAAM,oBAAoB,MAAM;AAC9B,wBAAoB,IAAI;AACxB,aAAS;AAAA,EACX;AAEA,QAAM,kBAAkB,MAAM;AAC5B,kBAAc,UAAU,WAAW,MAAM;AACvC,wBAAkB;AAAA,IACpB,GAAG,aAAa;AAAA,EAClB;AAEA,QAAM,kBAAkB,MAAM;AAC5B,QAAI,cAAc,SAAS;AACzB,mBAAa,cAAc,OAAO;AAClC,oBAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM;AAC5B,oBAAgB;AAChB,oBAAgB;AAAA,EAClB;AAEA,QAAM,mBAAmB,MAAM;AAC7B,iBAAa,IAAI;AAAA,EACnB;AAEA,QAAM,gBAAgB,MAAM;AAC1B,iBAAa,KAAK;AAClB,oBAAgB;AAAA,EAClB;AAGA,QAAM,qBAAqB;AAAA,IACzB,CAAC,UAAsB;AACrB,UAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;AACpE,4BAAoB,KAAK;AACzB,qBAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,YAAU,MAAM;AAEd,aAAS,iBAAiB,aAAa,kBAAkB;AAEzD,WAAO,MAAM;AAEX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAE9D;AAAA,EACF,GAAG,CAAC,kBAAkB,CAAC;AAEvB,QAAM,gBAAmD,CAAC,MAAM;AAC9D,QAAI,kBAAkB;AACpB,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,eAAe,MAAM;AAEzB,wBAAoB,KAAK;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,cAAc;AAAA,QACd,eAAe;AAAA,QACf,cAAc;AAAA,QACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;AAAA,QACN,YAAY;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n type HTMLAttributes,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n };\n\n const handleMouseUp = () => {\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: 'inline',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";AAqGI;AAnGJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP,MAAM,gCAAgC;AAS/B,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,GAAG;AACL,MAAM;AACJ,QAAM,SAAS,OAAuB,IAAI;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,eAAe;AACxE,QAAM,gBAAgB,OAA6C,IAAI;AAEvE,QAAM,oBAAoB,MAAM;AAC9B,wBAAoB,IAAI;AACxB,aAAS;AAAA,EACX;AAEA,QAAM,kBAAkB,MAAM;AAC5B,kBAAc,UAAU,WAAW,MAAM;AACvC,wBAAkB;AAAA,IACpB,GAAG,aAAa;AAAA,EAClB;AAEA,QAAM,kBAAkB,MAAM;AAC5B,QAAI,cAAc,SAAS;AACzB,mBAAa,cAAc,OAAO;AAClC,oBAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM;AAC5B,oBAAgB;AAChB,oBAAgB;AAAA,EAClB;AAEA,QAAM,mBAAmB,MAAM;AAC7B,iBAAa,IAAI;AAAA,EACnB;AAEA,QAAM,gBAAgB,MAAM;AAC1B,iBAAa,KAAK;AAClB,oBAAgB;AAAA,EAClB;AAGA,QAAM,qBAAqB;AAAA,IACzB,CAAC,UAAsB;AACrB,UAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;AACpE,4BAAoB,KAAK;AACzB,qBAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,YAAU,MAAM;AAEd,aAAS,iBAAiB,aAAa,kBAAkB;AAEzD,WAAO,MAAM;AAEX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAE9D;AAAA,EACF,GAAG,CAAC,kBAAkB,CAAC;AAEvB,QAAM,gBAAmD,CAAC,MAAM;AAC9D,QAAI,kBAAkB;AACpB,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,eAAe,MAAM;AAEzB,wBAAoB,KAAK;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,cAAc;AAAA,QACd,eAAe;AAAA,QACf,cAAc;AAAA,QACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;AAAA,QACN,YAAY;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n ChangedContentProvider,\n useCrossFrameState,\n} from '@intlayer/editor-react';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useCallback,\n} from 'react';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { PoweredByMeta } from './PoweredByMeta';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales
|
|
1
|
+
{"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n ChangedContentProvider,\n useCrossFrameState,\n} from '@intlayer/editor-react';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useCallback,\n} from 'react';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { PoweredByMeta } from './PoweredByMeta';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales | `${Locales}`;\n setLocale: (newLocale: Locales | `${Locales}`) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales | `${Locales}`;\n setLocale?: (locale: Locales | `${Locales}`) => void;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nconst IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n}) => {\n const { internationalization } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = internationalization;\n\n const [currentLocale, setCurrentLocale] = useCrossFrameState(\n 'INTLAYER_CURRENT_LOCALE',\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocaleBase = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const setLocale = useMemo(\n () => setLocaleProp ?? setLocaleBase,\n [setLocaleProp, setLocaleBase]\n );\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <ChangedContentProvider>\n <PoweredByMeta />\n {children}\n </ChangedContentProvider>\n </IntlayerClientContext.Provider>\n );\n};\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = (props) => (\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n);\n"],"mappings":";AAqFM,SACE,KADF;AAnFN,SAAS,wBAAsC;AAC/C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,qBAAqB;AAC9B,SAAS,cAAc,uBAAuB;AAUvC,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,iBAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AAUxE,MAAM,0BAAqD,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AACb,MAAM;AACJ,QAAM,EAAE,qBAAqB,IAAI,iBAAiB;AAClD,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAErD,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC;AAAA,IACA,UAAU,gBAAgB;AAAA,EAC5B;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,sBAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAY;AAAA,IAChB,MAAM,iBAAiB;AAAA,IACvB,CAAC,eAAe,aAAa;AAAA,EAC/B;AAEA,QAAM,QAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAU;AAAA,IAC1C,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAC9B,+BAAC,0BACC;AAAA,wBAAC,iBAAc;AAAA,IACd;AAAA,KACH,GACF;AAEJ;AAEO,MAAM,mBAA8C,CAAC,UAC1D,oBAAC,0BACC,8BAAC,2BAAyB,GAAG,OAAO,GACtC;","names":[]}
|
|
@@ -8,7 +8,6 @@ import { useIntlayerAsync } from "./useIntlayerAsync.mjs";
|
|
|
8
8
|
import { useDictionary } from "./useDictionary.mjs";
|
|
9
9
|
import { useLocaleBase } from "./useLocaleBase.mjs";
|
|
10
10
|
import { useLocale } from "./useLocale.mjs";
|
|
11
|
-
import { useTraduction } from "./useTraduction.mjs";
|
|
12
11
|
import {
|
|
13
12
|
useLocaleCookie,
|
|
14
13
|
localeCookie,
|
|
@@ -29,7 +28,6 @@ export {
|
|
|
29
28
|
useIntlayerContext,
|
|
30
29
|
useLocale,
|
|
31
30
|
useLocaleBase,
|
|
32
|
-
useLocaleCookie
|
|
33
|
-
useTraduction
|
|
31
|
+
useLocaleCookie
|
|
34
32
|
};
|
|
35
33
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayerContext,\n IntlayerProvider,\n} from './IntlayerProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useIntlayerAsync } from './useIntlayerAsync';\nexport { useDictionary } from './useDictionary';\nexport { useLocaleBase } from './useLocaleBase';\nexport { useLocale } from './useLocale';\nexport {
|
|
1
|
+
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayerContext,\n IntlayerProvider,\n} from './IntlayerProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useIntlayerAsync } from './useIntlayerAsync';\nexport { useDictionary } from './useDictionary';\nexport { useLocaleBase } from './useLocaleBase';\nexport { useLocale } from './useLocale';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\nexport { getBrowserLocale } from './getBrowserLocale';\nexport { t } from './t';\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,SAAS;","names":[]}
|
package/dist/esm/client/t.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { getTranslation } from "@intlayer/core";
|
|
2
3
|
import { useContext } from "react";
|
|
3
|
-
import { getTranslation } from "../getTranslation.mjs";
|
|
4
4
|
import { IntlayerClientContext } from "./IntlayerProvider.mjs";
|
|
5
5
|
const t = (multilangContent, locale) => {
|
|
6
6
|
const { locale: currentLocale } = useContext(IntlayerClientContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport type
|
|
1
|
+
{"version":3,"sources":["../../../src/client/t.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslation } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: LanguageContent<Content>,\n locale?: Locales\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";AAGA,SAA+B,sBAAsB;AACrD,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AAO/B,MAAM,IAAI,CACf,kBACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,eAAwB,kBAAkB,YAAY;AAC/D;","names":[]}
|