react-intlayer 1.2.1 → 2.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/dist/cjs/{ContentEditor/contentRender.cjs → client/ContentEditionLayout.cjs} +9 -14
- package/dist/cjs/client/ContentEditionLayout.cjs.map +1 -0
- package/dist/cjs/client/ContentEditionLayout.d.ts +6 -0
- package/dist/cjs/client/IntlayerClientProvider.cjs +10 -1
- package/dist/cjs/client/IntlayerClientProvider.cjs.map +1 -1
- package/dist/cjs/client/useContent.d.ts +1 -2
- package/dist/cjs/getEnumeration.cjs +0 -4
- package/dist/cjs/getEnumeration.cjs.map +1 -1
- package/dist/cjs/getTranslation.cjs +0 -4
- package/dist/cjs/getTranslation.cjs.map +1 -1
- package/dist/cjs/processDictionary/{contentDictionary.d.cjs → contentDictionary.cjs} +3 -3
- package/dist/cjs/processDictionary/contentDictionary.cjs.map +1 -0
- package/dist/cjs/processDictionary/contentDictionary.d.ts +16 -0
- package/dist/cjs/processDictionary/index.cjs +88 -23
- package/dist/cjs/processDictionary/index.cjs.map +1 -1
- package/dist/cjs/processDictionary/index.d.ts +5 -4
- package/dist/cjs/useIntlayerBase.cjs +3 -0
- package/dist/cjs/useIntlayerBase.cjs.map +1 -1
- package/dist/cjs/vite/intlayerPlugin.cjs +1 -1
- package/dist/cjs/vite/intlayerPlugin.cjs.map +1 -1
- package/dist/esm/client/ContentEditionLayout.d.mts +6 -0
- package/dist/esm/client/ContentEditionLayout.mjs +11 -0
- package/dist/esm/client/ContentEditionLayout.mjs.map +1 -0
- package/dist/esm/client/IntlayerClientProvider.mjs +10 -1
- package/dist/esm/client/IntlayerClientProvider.mjs.map +1 -1
- package/dist/esm/client/useContent.d.mts +1 -2
- package/dist/esm/getEnumeration.mjs +0 -4
- package/dist/esm/getEnumeration.mjs.map +1 -1
- package/dist/esm/getTranslation.mjs +0 -4
- package/dist/esm/getTranslation.mjs.map +1 -1
- package/dist/esm/processDictionary/contentDictionary.d.mts +16 -0
- package/dist/esm/processDictionary/contentDictionary.mjs +1 -0
- package/dist/esm/processDictionary/index.d.mts +5 -4
- package/dist/esm/processDictionary/index.mjs +90 -24
- package/dist/esm/processDictionary/index.mjs.map +1 -1
- package/dist/esm/useIntlayerBase.mjs +3 -0
- package/dist/esm/useIntlayerBase.mjs.map +1 -1
- package/dist/esm/vite/intlayerPlugin.mjs +1 -1
- package/dist/esm/vite/intlayerPlugin.mjs.map +1 -1
- package/package.json +14 -8
- package/src/client/ContentEditionLayout.tsx +15 -0
- package/src/client/IntlayerClientProvider.tsx +8 -1
- package/src/getEnumeration.ts +0 -5
- package/src/getTranslation.ts +0 -5
- package/src/processDictionary/{contentDictionary.d.ts → contentDictionary.ts} +6 -5
- package/src/processDictionary/index.ts +111 -24
- package/src/useIntlayerBase.ts +3 -0
- package/src/vite/intlayerPlugin.ts +1 -1
- package/dist/cjs/ContentEditor/ContentEditor.cjs +0 -110
- package/dist/cjs/ContentEditor/ContentEditor.cjs.map +0 -1
- package/dist/cjs/ContentEditor/ContentEditor.d.ts +0 -8
- package/dist/cjs/ContentEditor/contentRender.cjs.map +0 -1
- package/dist/cjs/ContentEditor/contentRender.d.ts +0 -3
- package/dist/cjs/ContentEditor/index.cjs +0 -25
- package/dist/cjs/ContentEditor/index.cjs.map +0 -1
- package/dist/cjs/ContentEditor/index.d.ts +0 -3
- package/dist/cjs/processDictionary/contentDictionary.d.cjs.map +0 -1
- package/dist/cjs/processDictionary/contentDictionary.d.d.ts +0 -29
- package/dist/esm/ContentEditor/ContentEditor.d.mts +0 -8
- package/dist/esm/ContentEditor/ContentEditor.mjs +0 -92
- package/dist/esm/ContentEditor/ContentEditor.mjs.map +0 -1
- package/dist/esm/ContentEditor/contentRender.d.mts +0 -3
- package/dist/esm/ContentEditor/contentRender.mjs +0 -14
- package/dist/esm/ContentEditor/contentRender.mjs.map +0 -1
- package/dist/esm/ContentEditor/index.d.mts +0 -3
- package/dist/esm/ContentEditor/index.mjs +0 -3
- package/dist/esm/ContentEditor/index.mjs.map +0 -1
- package/dist/esm/processDictionary/contentDictionary.d.d.mts +0 -29
- package/dist/esm/processDictionary/contentDictionary.d.mjs +0 -1
- package/src/ContentEditor/ContentEditor.tsx +0 -116
- package/src/ContentEditor/contentRender.tsx +0 -11
- package/src/ContentEditor/index.tsx +0 -2
- /package/dist/esm/processDictionary/{contentDictionary.d.mjs.map → contentDictionary.mjs.map} +0 -0
|
@@ -16,22 +16,17 @@ 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 ContentEditionLayout_exports = {};
|
|
20
|
+
__export(ContentEditionLayout_exports, {
|
|
21
|
+
ContentEditionLayout: () => ContentEditionLayout
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(ContentEditionLayout_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
var
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
if (isEditable && import_ContentEditor.ContentEditor) {
|
|
29
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentEditor.ContentEditor, { children: content });
|
|
30
|
-
}
|
|
31
|
-
return content;
|
|
32
|
-
};
|
|
25
|
+
var import_client = require("intlayer-editor/client");
|
|
26
|
+
const BlankLayout = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
27
|
+
const ContentEditionLayout = typeof import_client.ContentEditionLayout === "undefined" ? BlankLayout : import_client.ContentEditionLayout;
|
|
33
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
29
|
0 && (module.exports = {
|
|
35
|
-
|
|
30
|
+
ContentEditionLayout
|
|
36
31
|
});
|
|
37
|
-
//# sourceMappingURL=
|
|
32
|
+
//# sourceMappingURL=ContentEditionLayout.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import {\n ContentEditionLayout as ContentEditionLayoutBase,\n type ContentEditionLayoutProps,\n} from 'intlayer-editor/client';\nimport type { FC } from 'react';\n\nconst BlankLayout: FC<ContentEditionLayoutProps> = ({ children }) => (\n <>{children}</>\n);\n\n// intlayer-editor is an optional dependency. If it's not installed, return the blank layout\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> =\n typeof ContentEditionLayoutBase === 'undefined'\n ? BlankLayout\n : (ContentEditionLayoutBase as typeof ContentEditionLayout);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOE;AAPF,oBAGO;AAGP,MAAM,cAA6C,CAAC,EAAE,SAAS,MAC7D,2EAAG,UAAS;AAIP,MAAM,uBACX,OAAO,cAAAA,yBAA6B,cAChC,cACC,cAAAA;","names":["ContentEditionLayoutBase"]}
|
|
@@ -27,6 +27,7 @@ module.exports = __toCommonJS(IntlayerClientProvider_exports);
|
|
|
27
27
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
28
|
var import_client = require("@intlayer/config/client");
|
|
29
29
|
var import_react = require("react");
|
|
30
|
+
var import_ContentEditionLayout = require('./ContentEditionLayout.cjs');
|
|
30
31
|
var import_useLocaleCookie = require('./useLocaleCookie.cjs');
|
|
31
32
|
const IntlayerClientContext = (0, import_react.createContext)({
|
|
32
33
|
locale: import_useLocaleCookie.localeCookie ?? (0, import_client.getConfiguration)().internationalization.defaultLocale,
|
|
@@ -58,7 +59,15 @@ const IntlayerClientProvider = ({
|
|
|
58
59
|
() => ({ locale: currentLocale, setLocale }),
|
|
59
60
|
[currentLocale, setLocale]
|
|
60
61
|
);
|
|
61
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerClientContext.Provider, { value, children
|
|
62
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerClientContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
63
|
+
import_ContentEditionLayout.ContentEditionLayout,
|
|
64
|
+
{
|
|
65
|
+
locale: currentLocale,
|
|
66
|
+
setLocale,
|
|
67
|
+
localeList: availableLocales,
|
|
68
|
+
children
|
|
69
|
+
}
|
|
70
|
+
) });
|
|
62
71
|
};
|
|
63
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
64
73
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerClientProviderProps = PropsWithChildren & {\n locale?: Locales;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerClientProvider: FC<IntlayerClientProviderProps> = ({\n locale,\n children,\n}) => {\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocale = 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 value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { ContentEditionLayout } from './ContentEditionLayout';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerClientProviderProps = PropsWithChildren & {\n locale?: Locales;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerClientProvider: FC<IntlayerClientProviderProps> = ({\n locale,\n children,\n}) => {\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocale = 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 value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <ContentEditionLayout\n locale={currentLocale}\n setLocale={setLocale}\n localeList={availableLocales}\n >\n {children}\n </ContentEditionLayout>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyEM;AAvEN,oBAA+C;AAC/C,mBAQO;AACP,kCAAqC;AACrC,6BAA8C;AAUvC,MAAM,4BAAwB,4BAA6B;AAAA,EAChE,QAAQ,2CAAgB,gCAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,UAAM,yBAAW,qBAAqB;AASjE,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,eAAe,SAAS,iBAAiB,QAC/C,gCAAiB,EAAE;AAErB,QAAM,CAAC,eAAe,gBAAgB,QAAI;AAAA,IACxC,UAAU,uCAAgB;AAAA,EAC5B;AAEA,QAAM,gBAAY;AAAA,IAChB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS;AAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,kDAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAU;AAAA,IAC1C,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,4CAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,IAAC;AAAA;AAAA,MACC,QAAQ;AAAA,MACR;AAAA,MACA,YAAY;AAAA,MAEX;AAAA;AAAA,EACH,GACF;AAEJ;","names":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as _intlayer_config_client from '@intlayer/config/client';
|
|
2
1
|
import * as intlayer from 'intlayer';
|
|
3
2
|
import { LanguageContent } from '@intlayer/core';
|
|
4
3
|
|
|
@@ -8,7 +7,7 @@ import { LanguageContent } from '@intlayer/core';
|
|
|
8
7
|
declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
|
|
9
8
|
locale: intlayer.Locales;
|
|
10
9
|
content: Content;
|
|
11
|
-
t: <Content_1 = string>(languageContent: Partial<Record<
|
|
10
|
+
t: <Content_1 = string>(languageContent: Partial<Record<intlayer.LocalesValues, Content_1>>) => Content_1;
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
export { useContent };
|
|
@@ -22,15 +22,11 @@ __export(getEnumeration_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(getEnumeration_exports);
|
|
24
24
|
var import_core = require("@intlayer/core");
|
|
25
|
-
var import_contentRender = require('./ContentEditor/contentRender.cjs');
|
|
26
25
|
const getEnumeration = (enumerationContent, quantity) => {
|
|
27
26
|
const result = (0, import_core.getEnumerationContent)(
|
|
28
27
|
enumerationContent,
|
|
29
28
|
quantity
|
|
30
29
|
);
|
|
31
|
-
if (typeof result === "string") {
|
|
32
|
-
return (0, import_contentRender.contentRender)(result);
|
|
33
|
-
}
|
|
34
30
|
return result;
|
|
35
31
|
};
|
|
36
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\
|
|
1
|
+
{"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\n\n/**\n * Allow to pick a content based on a quantity.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = getEnumeration({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // 'You have two'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const content = getEnumeration({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // 'You have less than four'\n * ```\n *\n */\nexport const getEnumeration = <Content>(\n enumerationContent: QuantityContent<Content>,\n quantity: number\n): Content => {\n const result: Content = getEnumerationContent<Content>(\n enumerationContent,\n quantity\n );\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4D;AA8BrD,MAAM,iBAAiB,CAC5B,oBACA,aACY;AACZ,QAAM,aAAkB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -23,16 +23,12 @@ __export(getTranslation_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(getTranslation_exports);
|
|
24
24
|
var import_client = require("@intlayer/config/client");
|
|
25
25
|
var import_core = require("@intlayer/core");
|
|
26
|
-
var import_contentRender = require('./ContentEditor/contentRender.cjs');
|
|
27
26
|
const getTranslation = (languageContent, locale) => {
|
|
28
27
|
const { defaultLocale } = (0, import_client.getConfiguration)().internationalization;
|
|
29
28
|
const result = (0, import_core.getTranslationContent)(
|
|
30
29
|
languageContent,
|
|
31
30
|
locale ?? defaultLocale
|
|
32
31
|
);
|
|
33
|
-
if (typeof result === "string") {
|
|
34
|
-
return (0, import_contentRender.contentRender)(result);
|
|
35
|
-
}
|
|
36
32
|
return result;
|
|
37
33
|
};
|
|
38
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\
|
|
1
|
+
{"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\n\n/**\n *\n * Allow to pick a content based on a locale.\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 = getTranslation<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 getTranslation = <Content = string>(\n languageContent: LanguageContent<Content>,\n locale?: Locales\n): Content => {\n const { defaultLocale } = getConfiguration().internationalization;\n\n const result: Content = getTranslationContent<Content>(\n languageContent,\n locale ?? defaultLocale\n );\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,kBAA4D;AAuBrD,MAAM,iBAAiB,CAC5B,iBACA,WACY;AACZ,QAAM,EAAE,cAAc,QAAI,gCAAiB,EAAE;AAE7C,QAAM,aAAkB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,EACZ;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -12,6 +12,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
return to;
|
|
13
13
|
};
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var
|
|
16
|
-
module.exports = __toCommonJS(
|
|
17
|
-
//# sourceMappingURL=contentDictionary.
|
|
15
|
+
var contentDictionary_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(contentDictionary_exports);
|
|
17
|
+
//# sourceMappingURL=contentDictionary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/processDictionary/contentDictionary.ts"],"sourcesContent":["import type { TranslationContent } from '@intlayer/core';\nimport type { ReactNode } from 'react';\n\nexport type ContentValue =\n | string\n | {\n [key: string]: ContentValue;\n }\n | TranslationContent<unknown>;\n\nexport type Content = Record<string, ContentValue | undefined>;\n\nexport type TransformedContentValue =\n | string\n | ReactNode\n | {\n [key: string]: TransformedContentValue;\n }\n | undefined\n | ((quantity: number) => TransformedContentValue);\n\nexport type TransformedContent =\n | Record<string, TransformedContentValue | undefined>\n | ReactNode;\n\nexport type ContentDictionary = Content & {\n id: string;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TranslationContent } from '@intlayer/core';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type ContentValue = string | {
|
|
5
|
+
[key: string]: ContentValue;
|
|
6
|
+
} | TranslationContent<unknown>;
|
|
7
|
+
type Content = Record<string, ContentValue | undefined>;
|
|
8
|
+
type TransformedContentValue = string | ReactNode | {
|
|
9
|
+
[key: string]: TransformedContentValue;
|
|
10
|
+
} | undefined | ((quantity: number) => TransformedContentValue);
|
|
11
|
+
type TransformedContent = Record<string, TransformedContentValue | undefined> | ReactNode;
|
|
12
|
+
type ContentDictionary = Content & {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type { Content, ContentDictionary, ContentValue, TransformedContent, TransformedContentValue };
|
|
@@ -24,44 +24,82 @@ __export(processDictionary_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(processDictionary_exports);
|
|
25
25
|
var import_client = require("@intlayer/config/client");
|
|
26
26
|
var import_core = require("@intlayer/core");
|
|
27
|
+
var import_client2 = require("intlayer-editor/client");
|
|
27
28
|
var import_react = require("react");
|
|
28
29
|
var import_getEnumeration = require('../getEnumeration.cjs');
|
|
29
30
|
var import_getTranslation = require('../getTranslation.cjs');
|
|
30
|
-
const {
|
|
31
|
-
|
|
31
|
+
const {
|
|
32
|
+
internationalization: { defaultLocale }
|
|
33
|
+
} = (0, import_client.getConfiguration)();
|
|
34
|
+
const processTranslation = (languageContent, locale, dictionaryId, dictionaryPath, keyPath = []) => {
|
|
32
35
|
const translationResult = (0, import_getTranslation.getTranslation)(
|
|
33
36
|
languageContent,
|
|
34
37
|
locale
|
|
35
38
|
);
|
|
36
|
-
|
|
39
|
+
const resultKeyPath = [
|
|
40
|
+
...keyPath,
|
|
41
|
+
{ type: import_core.NodeType.Translation, key: locale }
|
|
42
|
+
];
|
|
43
|
+
return processDictionary(
|
|
44
|
+
translationResult,
|
|
45
|
+
dictionaryId,
|
|
46
|
+
dictionaryPath,
|
|
47
|
+
resultKeyPath,
|
|
48
|
+
locale
|
|
49
|
+
);
|
|
37
50
|
};
|
|
38
|
-
const processEnumeration = (enumerationContent, locale) => {
|
|
51
|
+
const processEnumeration = (enumerationContent, locale, dictionaryId, dictionaryPath, keyPath = []) => {
|
|
39
52
|
return (quantity) => {
|
|
40
53
|
const enumerationResult = (0, import_getEnumeration.getEnumeration)(
|
|
41
54
|
enumerationContent,
|
|
42
55
|
quantity
|
|
43
56
|
);
|
|
44
|
-
|
|
57
|
+
const matchingCondition = (0, import_core.findMatchingCondition)(
|
|
58
|
+
enumerationContent,
|
|
59
|
+
quantity
|
|
60
|
+
);
|
|
61
|
+
const resultKeyPath = [
|
|
62
|
+
...keyPath,
|
|
63
|
+
{ type: import_core.NodeType.Enumeration, key: matchingCondition.toString() }
|
|
64
|
+
];
|
|
65
|
+
return processDictionary(
|
|
66
|
+
enumerationResult,
|
|
67
|
+
dictionaryId,
|
|
68
|
+
dictionaryPath,
|
|
69
|
+
resultKeyPath,
|
|
70
|
+
locale
|
|
71
|
+
);
|
|
45
72
|
};
|
|
46
73
|
};
|
|
47
74
|
const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
|
|
48
|
-
const processNode = (field, locale) => {
|
|
49
|
-
if (typeof field
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
const processNode = (field, locale, dictionaryId, dictionaryPath, keyPath = []) => {
|
|
76
|
+
if (typeof field === "object") {
|
|
77
|
+
if (field.nodeType === import_core.NodeType.Translation) {
|
|
78
|
+
return processTranslation(
|
|
79
|
+
field,
|
|
80
|
+
locale,
|
|
81
|
+
dictionaryId,
|
|
82
|
+
dictionaryPath,
|
|
83
|
+
keyPath
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
if (field.nodeType === import_core.NodeType.Enumeration) {
|
|
87
|
+
return processEnumeration(
|
|
88
|
+
field,
|
|
89
|
+
locale,
|
|
90
|
+
dictionaryId,
|
|
91
|
+
dictionaryPath,
|
|
92
|
+
keyPath
|
|
93
|
+
);
|
|
94
|
+
}
|
|
63
95
|
}
|
|
64
|
-
return
|
|
96
|
+
return processDictionary(
|
|
97
|
+
field,
|
|
98
|
+
dictionaryId,
|
|
99
|
+
dictionaryPath,
|
|
100
|
+
keyPath,
|
|
101
|
+
locale
|
|
102
|
+
);
|
|
65
103
|
};
|
|
66
104
|
const createReactElement = (element) => {
|
|
67
105
|
if (typeof element === "string") {
|
|
@@ -88,7 +126,8 @@ const createReactElement = (element) => {
|
|
|
88
126
|
const { type, props } = fixedElement;
|
|
89
127
|
return (0, import_react.createElement)(type ?? "div", props, ...props.children);
|
|
90
128
|
};
|
|
91
|
-
const
|
|
129
|
+
const traceKeys = ["filePath", "id", "nodeType"];
|
|
130
|
+
const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [], locale = defaultLocale) => {
|
|
92
131
|
if (isReactNode(content)) {
|
|
93
132
|
return createReactElement(
|
|
94
133
|
content
|
|
@@ -98,10 +137,36 @@ const processDictionary = (content, locale = defaultLocale) => {
|
|
|
98
137
|
const result = {};
|
|
99
138
|
for (const key of Object.keys(content)) {
|
|
100
139
|
const field = content[key];
|
|
101
|
-
|
|
140
|
+
if (traceKeys.includes(key)) {
|
|
141
|
+
result[key] = field;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const resultKeyPath = [
|
|
145
|
+
...keyPath,
|
|
146
|
+
{ type: "ObjectExpression", key }
|
|
147
|
+
];
|
|
148
|
+
result[key] = processNode(
|
|
149
|
+
field,
|
|
150
|
+
locale,
|
|
151
|
+
dictionaryId,
|
|
152
|
+
dictionaryPath,
|
|
153
|
+
resultKeyPath
|
|
154
|
+
);
|
|
102
155
|
}
|
|
103
156
|
return result;
|
|
104
157
|
}
|
|
158
|
+
if (typeof content === "string") {
|
|
159
|
+
try {
|
|
160
|
+
return (0, import_client2.renderContentEditor)(
|
|
161
|
+
content,
|
|
162
|
+
dictionaryId,
|
|
163
|
+
dictionaryPath,
|
|
164
|
+
keyPath
|
|
165
|
+
);
|
|
166
|
+
} catch (e) {
|
|
167
|
+
return content;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
105
170
|
return content;
|
|
106
171
|
};
|
|
107
172
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/processDictionary/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Locales, getConfiguration } from '@intlayer/config/client';\nimport {\n NodeType,\n type QuantityContent,\n type LanguageContent,\n} from '@intlayer/core';\nimport { type ReactElement, createElement, type ReactNode } from 'react';\nimport { getEnumeration } from '../getEnumeration';\nimport { getTranslation } from '../getTranslation';\nimport type {\n Content,\n ContentValue,\n TransformedContent,\n TransformedContentValue,\n} from './contentDictionary';\n\nconst { defaultLocale } = getConfiguration()
|
|
1
|
+
{"version":3,"sources":["../../../src/processDictionary/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type Locales, getConfiguration } from '@intlayer/config/client';\nimport {\n NodeType,\n type QuantityContent,\n type LanguageContent,\n findMatchingCondition,\n type KeyPath,\n} from '@intlayer/core';\nimport { renderContentEditor } from 'intlayer-editor/client';\nimport { type ReactElement, createElement, type ReactNode } from 'react';\nimport { getEnumeration } from '../getEnumeration';\nimport { getTranslation } from '../getTranslation';\nimport type {\n Content,\n ContentValue,\n TransformedContent,\n TransformedContentValue,\n} from './contentDictionary';\n\nconst {\n internationalization: { defaultLocale },\n} = getConfiguration();\n\nconst processTranslation = (\n languageContent: LanguageContent<ContentValue>,\n locale: Locales,\n dictionaryId: string,\n dictionaryPath: string,\n keyPath: KeyPath[] = []\n): TransformedContent => {\n const translationResult: ContentValue = getTranslation<ContentValue>(\n languageContent,\n locale\n );\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Translation, key: locale },\n ];\n\n return processDictionary(\n translationResult as Content,\n dictionaryId,\n dictionaryPath,\n resultKeyPath,\n locale\n );\n};\n\nconst processEnumeration = (\n enumerationContent: QuantityContent<ContentValue>,\n locale: Locales,\n dictionaryId: string,\n dictionaryPath: string,\n keyPath: KeyPath[] = []\n): TransformedContentValue => {\n return (quantity: number): TransformedContentValue => {\n const enumerationResult: ContentValue = getEnumeration<ContentValue>(\n enumerationContent,\n quantity\n );\n\n const matchingCondition = findMatchingCondition(\n enumerationContent,\n quantity\n );\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: NodeType.Enumeration, key: matchingCondition.toString() },\n ];\n\n //\n return processDictionary(\n enumerationResult as Content,\n dictionaryId,\n dictionaryPath,\n resultKeyPath,\n locale\n );\n };\n};\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' && typeof node?.props !== 'undefined';\n\nexport const processNode = (\n field: ContentValue | undefined,\n locale: Locales,\n dictionaryId: string,\n dictionaryPath: string,\n keyPath: KeyPath[] = []\n): TransformedContentValue => {\n if (typeof field === 'object') {\n if (field.nodeType === NodeType.Translation) {\n return processTranslation(\n field as LanguageContent<ContentValue>,\n locale,\n dictionaryId,\n dictionaryPath,\n keyPath\n );\n }\n\n if (field.nodeType === NodeType.Enumeration) {\n return processEnumeration(\n field satisfies QuantityContent<ContentValue>,\n locale,\n dictionaryId,\n dictionaryPath,\n keyPath\n );\n }\n }\n\n return processDictionary(\n field as Content,\n dictionaryId,\n dictionaryPath,\n keyPath,\n locale\n );\n};\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 // Destructure the component properties\n\n const convertChildrenAsArray = (element: ReactElement): ReactElement => {\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(createReactElement(children[key]));\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(element);\n\n const { type, props } = fixedElement;\n\n // Create and return the React element\n return createElement(type ?? 'div', props, ...props.children);\n};\n\nconst traceKeys: string[] = ['filePath', 'id', 'nodeType'];\n\n/**\n * Function that process a dictionary and return the result to be used in the application.\n */\nexport const processDictionary = (\n content: Content,\n dictionaryId: string,\n dictionaryPath: string,\n keyPath: KeyPath[] = [],\n locale: Locales = defaultLocale\n): TransformedContent => {\n // If it's a React element, render it\n if (isReactNode(content)) {\n return createReactElement(\n content as unknown as ReactElement\n ) as unknown as TransformedContent;\n }\n\n if (content && typeof content === 'object') {\n const result: TransformedContent = {};\n\n // List each key in the content and process it\n for (const key of Object.keys(content)) {\n const field = content[key];\n\n if (traceKeys.includes(key)) {\n result[key] = field as TransformedContentValue;\n continue;\n }\n\n const resultKeyPath: KeyPath[] = [\n ...keyPath,\n { type: 'ObjectExpression', key },\n ];\n\n result[key] = processNode(\n field,\n locale,\n dictionaryId,\n dictionaryPath,\n resultKeyPath\n );\n }\n\n return result;\n }\n\n if (typeof content === 'string') {\n try {\n // renderContentEditor come from intlayer-editor, which is an optional dependency.\n // intlayer-editor should be installed in the project to use the content editor.\n return renderContentEditor(\n content,\n dictionaryId,\n dictionaryPath,\n keyPath\n );\n } catch (e) {\n // If renderContentEditor not available, it will return the content as is.\n return content;\n }\n }\n\n // If it's a string, number, or function, return it\n return content;\n};\n"],"mappings":"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","names":["import_client","element"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Locales } from '@intlayer/config/client';
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
2
|
+
import { KeyPath } from '@intlayer/core';
|
|
3
|
+
import { ContentValue, TransformedContentValue, Content, TransformedContent } from './contentDictionary.js';
|
|
4
|
+
import 'react';
|
|
4
5
|
|
|
5
|
-
declare const processNode: (field: ContentValue | undefined, locale: Locales) => TransformedContentValue;
|
|
6
|
+
declare const processNode: (field: ContentValue | undefined, locale: Locales, dictionaryId: string, dictionaryPath: string, keyPath?: KeyPath[]) => TransformedContentValue;
|
|
6
7
|
/**
|
|
7
8
|
* Function that process a dictionary and return the result to be used in the application.
|
|
8
9
|
*/
|
|
9
|
-
declare const processDictionary: (content: Content, locale?: Locales) => TransformedContent;
|
|
10
|
+
declare const processDictionary: (content: Content, dictionaryId: string, dictionaryPath: string, keyPath?: KeyPath[], locale?: Locales) => TransformedContent;
|
|
10
11
|
|
|
11
12
|
export { processDictionary, processNode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { Content } from './processDictionary/contentDictionary';\nimport { processDictionary } from './processDictionary/index';\n\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\nexport type UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => IntlayerDictionaryTypesConnector[T];\n\n/**\n * Hook that picking one dictionary by its id and return the content.\n */\nexport const useIntlayerBase: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const dictionary: Content = dictionaries[id];\n\n return processDictionary(\n dictionary,\n locale\n ) as IntlayerDictionaryTypesConnector[T];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,gCAAyB;AAGzB,+BAAkC;AAe3B,MAAM,kBAA+B,CAC1C,IACA,WACG;AACH,QAAM,aAAsB,0BAAAA,QAAa,EAAE;AAE3C,aAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["dictionaries"]}
|
|
1
|
+
{"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { Content } from './processDictionary/contentDictionary';\nimport { processDictionary } from './processDictionary/index';\n\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\nexport type UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => IntlayerDictionaryTypesConnector[T];\n\n/**\n * Hook that picking one dictionary by its id and return the content.\n */\nexport const useIntlayerBase: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const dictionary: Content = dictionaries[id];\n\n return processDictionary(\n dictionary,\n id,\n dictionary.filePath as string,\n [],\n locale\n ) as IntlayerDictionaryTypesConnector[T];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,gCAAyB;AAGzB,+BAAkC;AAe3B,MAAM,kBAA+B,CAC1C,IACA,WACG;AACH,QAAM,aAAsB,0BAAAA,QAAa,EAAE;AAE3C,aAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AACF;","names":["dictionaries"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/vite/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates IntLayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intLayerPlugin() ],\n * });\n * ```\n * */\nexport const intLayerPlugin = (_pluginOptions: PluginOptions = {}): Plugin => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, { mode }) => {\n const intlayerConfig = getConfiguration();\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = { ...process.env, ...loadEnv(mode, process.cwd()), ...env };\n\n const { mainDir, baseDir } = intlayerConfig.content;\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n return config;\n },\n\n buildStart: () => {\n // Code to run when Vite build starts\n watch({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n persistent: (import.meta as any).env === 'development',\n });\n },\n configureServer: (
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates IntLayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intLayerPlugin() ],\n * });\n * ```\n * */\nexport const intLayerPlugin = (_pluginOptions: PluginOptions = {}): Plugin => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, { mode }) => {\n const intlayerConfig = getConfiguration();\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = { ...process.env, ...loadEnv(mode, process.cwd()), ...env };\n\n const { mainDir, baseDir } = intlayerConfig.content;\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n return config;\n },\n\n buildStart: () => {\n // Code to run when Vite build starts\n watch({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n persistent: (import.meta as any).env === 'development',\n });\n },\n configureServer: () => {\n // Custom server configuration, if needed\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwC;AACxC,sBAAsB;AACtB,oBAAoD;AACpD,kBAAqC;AAHrC;AAqBO,MAAM,iBAAiB,CAAC,iBAAgC,CAAC,OAAe;AAAA,EAC7E,MAAM;AAAA,EAEN,QAAQ,CAAC,QAAQ,EAAE,KAAK,MAAM;AAC5B,UAAM,qBAAiB,gCAAiB;AAGxC,UAAM,UAAM,iCAAkB,MAAM;AAEpC,YAAQ,MAAM,EAAE,GAAG,QAAQ,KAAK,OAAG,qBAAQ,MAAM,QAAQ,IAAI,CAAC,GAAG,GAAG,IAAI;AAExE,UAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAC5C,UAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,UAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAGnE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,oCAAgC,qBAAQ,wBAAwB;AAAA,MAClE;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAAM;AAEhB,+BAAM;AAAA;AAAA,MAEJ,YAAa,YAAoB,QAAQ;AAAA,IAC3C,CAAC;AAAA,EACH;AAAA,EACA,iBAAiB,MAAM;AAAA,EAEvB;AACF;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "../chunk-ZNCO4QRF.mjs";
|
|
2
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
ContentEditionLayout as ContentEditionLayoutBase
|
|
5
|
+
} from "intlayer-editor/client";
|
|
6
|
+
const BlankLayout = ({ children }) => /* @__PURE__ */ jsx(Fragment, { children });
|
|
7
|
+
const ContentEditionLayout = typeof ContentEditionLayoutBase === "undefined" ? BlankLayout : ContentEditionLayoutBase;
|
|
8
|
+
export {
|
|
9
|
+
ContentEditionLayout
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=ContentEditionLayout.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import {\n ContentEditionLayout as ContentEditionLayoutBase,\n type ContentEditionLayoutProps,\n} from 'intlayer-editor/client';\nimport type { FC } from 'react';\n\nconst BlankLayout: FC<ContentEditionLayoutProps> = ({ children }) => (\n <>{children}</>\n);\n\n// intlayer-editor is an optional dependency. If it's not installed, return the blank layout\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> =\n typeof ContentEditionLayoutBase === 'undefined'\n ? BlankLayout\n : (ContentEditionLayoutBase as typeof ContentEditionLayout);\n"],"mappings":";AAOE;AAPF;AAAA,EACE,wBAAwB;AAAA,OAEnB;AAGP,MAAM,cAA6C,CAAC,EAAE,SAAS,MAC7D,gCAAG,UAAS;AAIP,MAAM,uBACX,OAAO,6BAA6B,cAChC,cACC;","names":[]}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
useState,
|
|
10
10
|
useCallback
|
|
11
11
|
} from "react";
|
|
12
|
+
import { ContentEditionLayout } from './ContentEditionLayout.mjs';
|
|
12
13
|
import { localeCookie, setLocaleCookie } from './useLocaleCookie.mjs';
|
|
13
14
|
const IntlayerClientContext = createContext({
|
|
14
15
|
locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,
|
|
@@ -40,7 +41,15 @@ const IntlayerClientProvider = ({
|
|
|
40
41
|
() => ({ locale: currentLocale, setLocale }),
|
|
41
42
|
[currentLocale, setLocale]
|
|
42
43
|
);
|
|
43
|
-
return /* @__PURE__ */ jsx(IntlayerClientContext.Provider, { value, children
|
|
44
|
+
return /* @__PURE__ */ jsx(IntlayerClientContext.Provider, { value, children: /* @__PURE__ */ jsx(
|
|
45
|
+
ContentEditionLayout,
|
|
46
|
+
{
|
|
47
|
+
locale: currentLocale,
|
|
48
|
+
setLocale,
|
|
49
|
+
localeList: availableLocales,
|
|
50
|
+
children
|
|
51
|
+
}
|
|
52
|
+
) });
|
|
44
53
|
};
|
|
45
54
|
export {
|
|
46
55
|
IntlayerClientContext,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerClientProviderProps = PropsWithChildren & {\n locale?: Locales;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerClientProvider: FC<IntlayerClientProviderProps> = ({\n locale,\n children,\n}) => {\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocale = 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 value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;
|
|
1
|
+
{"version":3,"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { ContentEditionLayout } from './ContentEditionLayout';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerClientProviderProps = PropsWithChildren & {\n locale?: Locales;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerClientProvider: FC<IntlayerClientProviderProps> = ({\n locale,\n children,\n}) => {\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocale = 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 value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <ContentEditionLayout\n locale={currentLocale}\n setLocale={setLocale}\n localeList={availableLocales}\n >\n {children}\n </ContentEditionLayout>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;AAyEM;AAvEN,SAAS,wBAAsC;AAC/C;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,cAAc,uBAAuB;AAUvC,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,iBAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AASjE,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,iBAAiB,EAAE;AAErB,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC,UAAU,gBAAgB;AAAA,EAC5B;AAEA,QAAM,YAAY;AAAA,IAChB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS;AAAG;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,QAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAU;AAAA,IAC1C,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,IAAC;AAAA;AAAA,MACC,QAAQ;AAAA,MACR;AAAA,MACA,YAAY;AAAA,MAEX;AAAA;AAAA,EACH,GACF;AAEJ;","names":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as _intlayer_config_client from '@intlayer/config/client';
|
|
2
1
|
import * as intlayer from 'intlayer';
|
|
3
2
|
import { LanguageContent } from '@intlayer/core';
|
|
4
3
|
|
|
@@ -8,7 +7,7 @@ import { LanguageContent } from '@intlayer/core';
|
|
|
8
7
|
declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
|
|
9
8
|
locale: intlayer.Locales;
|
|
10
9
|
content: Content;
|
|
11
|
-
t: <Content_1 = string>(languageContent: Partial<Record<
|
|
10
|
+
t: <Content_1 = string>(languageContent: Partial<Record<intlayer.LocalesValues, Content_1>>) => Content_1;
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
export { useContent };
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import "./chunk-ZNCO4QRF.mjs";
|
|
2
2
|
import { getEnumerationContent } from "@intlayer/core";
|
|
3
|
-
import { contentRender } from './ContentEditor/contentRender.mjs';
|
|
4
3
|
const getEnumeration = (enumerationContent, quantity) => {
|
|
5
4
|
const result = getEnumerationContent(
|
|
6
5
|
enumerationContent,
|
|
7
6
|
quantity
|
|
8
7
|
);
|
|
9
|
-
if (typeof result === "string") {
|
|
10
|
-
return contentRender(result);
|
|
11
|
-
}
|
|
12
8
|
return result;
|
|
13
9
|
};
|
|
14
10
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\
|
|
1
|
+
{"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\n\n/**\n * Allow to pick a content based on a quantity.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = getEnumeration({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // 'You have two'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const content = getEnumeration({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // 'You have less than four'\n * ```\n *\n */\nexport const getEnumeration = <Content>(\n enumerationContent: QuantityContent<Content>,\n quantity: number\n): Content => {\n const result: Content = getEnumerationContent<Content>(\n enumerationContent,\n quantity\n );\n\n return result;\n};\n"],"mappings":";AAAA,SAA+B,6BAA6B;AA8BrD,MAAM,iBAAiB,CAC5B,oBACA,aACY;AACZ,QAAM,SAAkB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import "./chunk-ZNCO4QRF.mjs";
|
|
2
2
|
import { getConfiguration } from "@intlayer/config/client";
|
|
3
3
|
import { getTranslationContent } from "@intlayer/core";
|
|
4
|
-
import { contentRender } from './ContentEditor/contentRender.mjs';
|
|
5
4
|
const getTranslation = (languageContent, locale) => {
|
|
6
5
|
const { defaultLocale } = getConfiguration().internationalization;
|
|
7
6
|
const result = getTranslationContent(
|
|
8
7
|
languageContent,
|
|
9
8
|
locale ?? defaultLocale
|
|
10
9
|
);
|
|
11
|
-
if (typeof result === "string") {
|
|
12
|
-
return contentRender(result);
|
|
13
|
-
}
|
|
14
10
|
return result;
|
|
15
11
|
};
|
|
16
12
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\
|
|
1
|
+
{"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\n\n/**\n *\n * Allow to pick a content based on a locale.\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 = getTranslation<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 getTranslation = <Content = string>(\n languageContent: LanguageContent<Content>,\n locale?: Locales\n): Content => {\n const { defaultLocale } = getConfiguration().internationalization;\n\n const result: Content = getTranslationContent<Content>(\n languageContent,\n locale ?? defaultLocale\n );\n\n return result;\n};\n"],"mappings":";AAAA,SAAuB,wBAAwB;AAC/C,SAA+B,6BAA6B;AAuBrD,MAAM,iBAAiB,CAC5B,iBACA,WACY;AACZ,QAAM,EAAE,cAAc,IAAI,iBAAiB,EAAE;AAE7C,QAAM,SAAkB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,EACZ;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TranslationContent } from '@intlayer/core';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type ContentValue = string | {
|
|
5
|
+
[key: string]: ContentValue;
|
|
6
|
+
} | TranslationContent<unknown>;
|
|
7
|
+
type Content = Record<string, ContentValue | undefined>;
|
|
8
|
+
type TransformedContentValue = string | ReactNode | {
|
|
9
|
+
[key: string]: TransformedContentValue;
|
|
10
|
+
} | undefined | ((quantity: number) => TransformedContentValue);
|
|
11
|
+
type TransformedContent = Record<string, TransformedContentValue | undefined> | ReactNode;
|
|
12
|
+
type ContentDictionary = Content & {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type { Content, ContentDictionary, ContentValue, TransformedContent, TransformedContentValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=contentDictionary.mjs.map
|