react-intlayer 5.0.1 → 5.0.3
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/client/IntlayerProvider.cjs +13 -9
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +2 -0
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +4 -1
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -4
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useIntlayerAsync.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleCookie.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +4 -2
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +2 -35
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/reactElement/renderReactElement.cjs +62 -0
- package/dist/cjs/reactElement/renderReactElement.cjs.map +1 -0
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
- package/dist/cjs/server/t.cjs +1 -3
- package/dist/cjs/server/t.cjs.map +1 -1
- package/dist/cjs/server/useDictionary.cjs +1 -1
- package/dist/cjs/server/useDictionary.cjs.map +1 -1
- package/dist/cjs/server/useIntlayer.cjs +1 -1
- package/dist/cjs/server/useIntlayer.cjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +12 -9
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/index.mjs +2 -0
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +4 -1
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -4
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useIntlayerAsync.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.mjs +4 -2
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/plugins.mjs +2 -35
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/reactElement/renderReactElement.mjs +38 -0
- package/dist/esm/reactElement/renderReactElement.mjs.map +1 -0
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
- package/dist/esm/server/t.mjs +1 -3
- package/dist/esm/server/t.mjs.map +1 -1
- package/dist/esm/server/useDictionary.mjs +1 -1
- package/dist/esm/server/useDictionary.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.mjs +1 -1
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +12 -6
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/useContent.d.ts +1 -1
- package/dist/types/client/useDictionary.d.ts +3 -3
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +3 -2
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useIntlayerAsync.d.ts +2 -2
- package/dist/types/client/useIntlayerAsync.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +7 -7
- 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 +5 -5
- package/dist/types/client/useLocaleCookie.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +2 -2
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +2 -2
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +8 -8
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/reactElement/renderReactElement.d.ts +3 -0
- package/dist/types/reactElement/renderReactElement.d.ts.map +1 -0
- package/dist/types/server/IntlayerServerProvider.d.ts +8 -8
- package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
- package/dist/types/server/t.d.ts +2 -2
- package/dist/types/server/t.d.ts.map +1 -1
- package/dist/types/server/useDictionary.d.ts +2 -2
- package/dist/types/server/useDictionary.d.ts.map +1 -1
- package/dist/types/server/useIntlayer.d.ts +2 -2
- package/dist/types/server/useIntlayer.d.ts.map +1 -1
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type
|
|
1
|
+
{"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type LocalesValues } from '@intlayer/config/client';\nimport {\n ChangedContentProvider,\n useCrossFrameState,\n} from '@intlayer/editor-react';\nimport {\n type FC,\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n useCallback,\n} from 'react';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { PoweredByMeta } from './PoweredByMeta';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n disableEditor?: boolean;\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 disableEditor: false,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n disableEditor?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n disableEditor,\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: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.map(String).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, setCurrentLocale]\n );\n\n const setLocale = useMemo(\n () => setLocaleProp ?? setLocaleBase,\n [setLocaleProp, setLocaleBase]\n );\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale, disableEditor }),\n [currentLocale, setLocale, disableEditor]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <PoweredByMeta />\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = (props) => (\n <ChangedContentProvider>\n <IntlayerEditorProvider>\n <IntlayerProviderContent {...props} />\n </IntlayerEditorProvider>\n </ChangedContentProvider>\n);\n"],"mappings":";AAwFI,SACE,KADF;AAtFJ,SAAS,wBAA4C;AACrD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,qBAAqB;AAC9B,SAAS,cAAc,uBAAuB;AAWvC,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,iBAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AAAA,EACjB,eAAe;AACjB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AAWjE,MAAM,0BAAqD,CAAC;AAAA,EACjE;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,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,cAA6B;AAC5B,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,IAAI,MAAM,EAAE,SAAS,SAAS,GAAG;AACrD,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,sBAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,QAAQ,gBAAgB;AAAA,EAC5D;AAEA,QAAM,YAAY;AAAA,IAChB,MAAM,iBAAiB;AAAA,IACvB,CAAC,eAAe,aAAa;AAAA,EAC/B;AAEA,QAAM,QAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,WAAW,cAAc;AAAA,IACzD,CAAC,eAAe,WAAW,aAAa;AAAA,EAC1C;AAEA,SACE,qBAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,wBAAC,iBAAc;AAAA,IACd;AAAA,KACH;AAEJ;AAEO,MAAM,mBAA8C,CAAC,UAC1D,oBAAC,0BACC,8BAAC,0BACC,8BAAC,2BAAyB,GAAG,OAAO,GACtC,GACF;","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IntlayerClientContext,
|
|
3
|
+
IntlayerProviderContent,
|
|
3
4
|
useIntlayerContext,
|
|
4
5
|
IntlayerProvider
|
|
5
6
|
} from "./IntlayerProvider.mjs";
|
|
@@ -18,6 +19,7 @@ import { t } from "./t.mjs";
|
|
|
18
19
|
export {
|
|
19
20
|
IntlayerClientContext,
|
|
20
21
|
IntlayerProvider,
|
|
22
|
+
IntlayerProviderContent,
|
|
21
23
|
getBrowserLocale,
|
|
22
24
|
localeCookie,
|
|
23
25
|
setLocaleCookie,
|
|
@@ -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 {\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":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n type IntlayerProviderProps,\n IntlayerClientContext,\n IntlayerProviderContent,\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,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":[]}
|
|
@@ -5,7 +5,10 @@ import { getDictionary } from "../getDictionary.mjs";
|
|
|
5
5
|
const useDictionary = (dictionary, locale) => {
|
|
6
6
|
const { locale: currentLocale } = useContext(IntlayerClientContext);
|
|
7
7
|
const localeTarget = locale ?? currentLocale;
|
|
8
|
-
return getDictionary(
|
|
8
|
+
return getDictionary(
|
|
9
|
+
dictionary,
|
|
10
|
+
localeTarget
|
|
11
|
+
);
|
|
9
12
|
};
|
|
10
13
|
export {
|
|
11
14
|
useDictionary
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { DeepTransformContent, type Dictionary } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\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 client context\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, LocalesValues>(\n dictionary,\n localeTarget\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":";AAKA,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAOvB,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -9,10 +9,7 @@ const useIntlayer = (key, locale) => {
|
|
|
9
9
|
const { changedContent } = useChangedContent();
|
|
10
10
|
const localeTarget = locale ?? currentLocale;
|
|
11
11
|
if (changedContent?.[key]) {
|
|
12
|
-
return getDictionary(
|
|
13
|
-
changedContent?.[key],
|
|
14
|
-
localeTarget
|
|
15
|
-
);
|
|
12
|
+
return getDictionary(changedContent?.[key], localeTarget);
|
|
16
13
|
}
|
|
17
14
|
return getIntlayer(key, localeTarget);
|
|
18
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useChangedContent } from '@intlayer/editor-react';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useChangedContent } from '@intlayer/editor-react';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport type { DictionaryKeys } from '@intlayer/core';\nimport { getDictionary } from '../getDictionary';\nimport { getIntlayer } from '../getIntlayer';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DeepTransformContent } from '../plugins';\n\n/**\n * On the client 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 client context\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: Locales\n): DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const { changedContent } = useChangedContent();\n const localeTarget = locale ?? currentLocale;\n\n if (changedContent?.[key]) {\n // @ts-ignore\n return getDictionary(changedContent?.[key], localeTarget);\n }\n\n return getIntlayer(key, localeTarget);\n};\n"],"mappings":";AAGA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AAEtC,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAUrB,MAAM,cAAc,CACzB,KACA,WACyE;AACzE,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,EAAE,eAAe,IAAI,kBAAkB;AAC7C,QAAM,eAAe,UAAU;AAE/B,MAAI,iBAAiB,GAAG,GAAG;AAEzB,WAAO,cAAc,iBAAiB,GAAG,GAAG,YAAY;AAAA,EAC1D;AAEA,SAAO,YAAY,KAAK,YAAY;AACtC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { useContext, useEffect, useMemo, useState } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport {\n type DictionaryKeys,\n getIntlayer,\n getIntlayerAsync,\n} from '@intlayer/core';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayerAsync = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues,\n isRenderEditor = true\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n const localeDictionary = getIntlayer(key, localeTarget);\n const [distantDictionary, setDistantDictionary] = useState<\n typeof localeDictionary | null | undefined\n >(undefined);\n const [isLoading, setIsLoading] = useState(false);\n\n useEffect(() => {\n setIsLoading(true);\n\n getIntlayerAsync(key)\n .then((distantDictionary) => {\n if (distantDictionary) {\n setDistantDictionary(distantDictionary);\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, []);\n\n const dictionary = useMemo(\n () => distantDictionary ?? localeDictionary,\n [distantDictionary, localeDictionary]\n );\n\n return { ...(dictionary as object), isLoading } as typeof localeDictionary & {\n isLoading: boolean;\n };\n};\n"],"mappings":";AAGA,SAAS,YAAY,WAAW,SAAS,gBAAgB;AACzD,SAAS,6BAA6B;AACtC;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAUA,MAAM,mBAAmB,CAC9B,KACA,QACA,iBAAiB,SACd;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAC/B,QAAM,mBAAmB,YAAY,KAAK,YAAY;AACtD,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAEhD,MAAS;AACX,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,YAAU,MAAM;AACd,iBAAa,IAAI;AAEjB,qBAAiB,GAAG,EACjB,KAAK,CAACA,uBAAsB;AAC3B,UAAIA,oBAAmB;AACrB,6BAAqBA,kBAAiB;AAAA,MACxC;AAAA,IACF,CAAC,EACA,QAAQ,MAAM;AACb,mBAAa,KAAK;AAAA,IACpB,CAAC;AAAA,EACL,GAAG,CAAC,CAAC;AAEL,QAAM,aAAa;AAAA,IACjB,MAAM,qBAAqB;AAAA,IAC3B,CAAC,mBAAmB,gBAAgB;AAAA,EACtC;AAEA,SAAO,EAAE,GAAI,YAAuB,UAAU;AAGhD;","names":["distantDictionary"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { type
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { type LocalesValues, getConfiguration } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\nimport { useCallback, useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useLocaleCookie } from './useLocaleCookie';\n\ntype useLocaleProps = {\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = ({ onLocaleChange }: useLocaleProps = {}) => {\n const {\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n */\n prefixDefault,\n } = getConfiguration().middleware;\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n const { locale, setLocale: setLocaleState } = useContext(\n IntlayerClientContext\n );\n const { setLocaleCookie } = useLocaleCookie();\n\n const setLocale = useCallback(\n (locale: LocalesValues) => {\n if (!availableLocales.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n setLocaleCookie(locale);\n onLocaleChange?.(locale);\n },\n [\n onLocaleChange,\n availableLocales,\n setLocaleState,\n prefixDefault,\n defaultLocale,\n ]\n );\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n localeList, // List of all available locales\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";AAEA,SAA6B,wBAAwB;AACrD,SAAS,kBAAkB;AAC3B,SAAS,aAAa,kBAAkB;AACxC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AASzB,MAAM,YAAY,CAAC,EAAE,eAAe,IAAoB,CAAC,MAAM;AACpE,QAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWJ;AAAA,EACF,IAAI,iBAAiB,EAAE;AACvB,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,iBAAiB,EAAE;AACrB,QAAM,EAAE,QAAQ,WAAW,eAAe,IAAI;AAAA,IAC5C;AAAA,EACF;AACA,QAAM,EAAE,gBAAgB,IAAI,gBAAgB;AAE5C,QAAM,YAAY;AAAA,IAChB,CAACA,YAA0B;AACzB,UAAI,CAAC,iBAAiB,IAAI,MAAM,EAAE,SAASA,OAAM,GAAG;AAClD,gBAAQ,MAAM,UAAUA,OAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,qBAAeA,OAAM;AACrB,sBAAgBA,OAAM;AACtB,uBAAiBA,OAAM;AAAA,IACzB;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":["locale"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useLocaleCookie.ts"],"sourcesContent":["import { type
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useLocaleCookie.ts"],"sourcesContent":["import { type LocalesValues, getConfiguration } from '@intlayer/config/client';\nimport Cookies from 'js-cookie';\n\nconst { cookieName } = getConfiguration().middleware;\n\nconst cookieAttributes: Cookies.CookieAttributes = {\n path: '/',\n expires: undefined,\n domain: undefined,\n secure: false,\n sameSite: 'strict',\n};\n\n/**\n * Get the locale cookie\n */\nexport const localeCookie = Cookies.get(cookieName) as unknown as\n | LocalesValues\n | undefined;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleCookie = (locale: LocalesValues) => {\n Cookies.set(cookieName, locale, cookieAttributes);\n};\n\n/**\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = () => ({\n localeCookie,\n setLocaleCookie,\n});\n"],"mappings":"AAAA,SAA6B,wBAAwB;AACrD,OAAO,aAAa;AAEpB,MAAM,EAAE,WAAW,IAAI,iBAAiB,EAAE;AAE1C,MAAM,mBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AACZ;AAKO,MAAM,eAAe,QAAQ,IAAI,UAAU;AAO3C,MAAM,kBAAkB,CAAC,WAA0B;AACxD,UAAQ,IAAI,YAAY,QAAQ,gBAAgB;AAClD;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EACA;AACF;","names":[]}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
useMemo
|
|
14
14
|
} from "react";
|
|
15
15
|
import { ContentSelector } from "../UI/ContentSelector.mjs";
|
|
16
|
+
import { useIntlayerContext } from "../client/index.mjs";
|
|
16
17
|
const ContentSelectorWrapperContent = ({
|
|
17
18
|
children,
|
|
18
19
|
dictionaryKey,
|
|
@@ -35,7 +36,7 @@ const ContentSelectorWrapperContent = ({
|
|
|
35
36
|
);
|
|
36
37
|
const isSelected = useMemo(
|
|
37
38
|
() => (focusedContent?.dictionaryKey === dictionaryKey && (focusedContent?.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ?? false,
|
|
38
|
-
[focusedContent, keyPath]
|
|
39
|
+
[focusedContent, keyPath, dictionaryKey]
|
|
39
40
|
);
|
|
40
41
|
useEffect(() => {
|
|
41
42
|
if (editedValue && typeof editedValue === "string") {
|
|
@@ -51,7 +52,8 @@ const ContentSelectorWrapper = ({
|
|
|
51
52
|
...props
|
|
52
53
|
}) => {
|
|
53
54
|
const { enabled } = useEditorEnabled();
|
|
54
|
-
|
|
55
|
+
const { disableEditor } = useIntlayerContext();
|
|
56
|
+
if (enabled && !disableEditor) {
|
|
55
57
|
return /* @__PURE__ */ jsx(ContentSelectorWrapperContent, { ...props, children });
|
|
56
58
|
}
|
|
57
59
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n HTMLAttributes,\n} from 'react';\nimport { ContentSelector } from '../UI/ContentSelector';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n ...props\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { getEditedContentValue } = useEditedContentActions();\n\n const editedValue = useMemo(\n () => getEditedContentValue(dictionaryKey, keyPath),\n [dictionaryKey, keyPath, getEditedContentValue]\n );\n\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath,\n }),\n [dictionaryKey, keyPath, setFocusedContent]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n } else {\n setDisplayedChildren(children);\n }\n }, [editedValue, focusedContent, children]);\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected} {...props}>\n {displayedChildren}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n\n if (enabled) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return <>{children}</>;\n};\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { type NodeProps, isSameKeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n HTMLAttributes,\n} from 'react';\nimport { ContentSelector } from '../UI/ContentSelector';\nimport { useIntlayerContext } from '../client';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'content'>;\n\nconst ContentSelectorWrapperContent: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n keyPath,\n ...props\n}) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { getEditedContentValue } = useEditedContentActions();\n\n const editedValue = useMemo(\n () => getEditedContentValue(dictionaryKey, keyPath),\n [dictionaryKey, keyPath, getEditedContentValue]\n );\n\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n keyPath,\n }),\n [dictionaryKey, keyPath, setFocusedContent]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath, dictionaryKey]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n } else {\n setDisplayedChildren(children);\n }\n }, [editedValue, focusedContent, children]);\n\n return (\n <ContentSelector onPress={handleSelect} isSelecting={isSelected} {...props}>\n {displayedChildren}\n </ContentSelector>\n );\n};\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return <>{children}</>;\n};\n"],"mappings":";AAoEI,SAqBK,UArBL;AAlEJ,SAAyB,qBAAqB;AAC9C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AAKnC,MAAM,gCAAiE,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,mBAAmB;AACjE,QAAM,EAAE,sBAAsB,IAAI,wBAAwB;AAE1D,QAAM,cAAc;AAAA,IAClB,MAAM,sBAAsB,eAAe,OAAO;AAAA,IAClD,CAAC,eAAe,SAAS,qBAAqB;AAAA,EAChD;AAEA,QAAM,CAAC,mBAAmB,oBAAoB,IAC5C,SAAoB,QAAQ;AAE9B,QAAM,eAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,SAAS,iBAAiB;AAAA,EAC5C;AAEA,QAAM,aAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,SAAS,aAAa;AAAA,EACzC;AAEA,YAAU,MAAM;AAEd,QAAI,eAAe,OAAO,gBAAgB,UAAU;AAClD,2BAAqB,WAAW;AAAA,IAClC,OAAO;AACL,2BAAqB,QAAQ;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,aAAa,gBAAgB,QAAQ,CAAC;AAE1C,SACE,oBAAC,mBAAgB,SAAS,cAAc,aAAa,YAAa,GAAG,OAClE,6BACH;AAEJ;AAEO,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,QAAM,EAAE,cAAc,IAAI,mBAAmB;AAE7C,MAAI,WAAW,CAAC,eAAe;AAC7B,WACE,oBAAC,iCAA+B,GAAG,OAChC,UACH;AAAA,EAEJ;AAEA,SAAO,gCAAG,UAAS;AACrB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n type Dictionary,\n type Plugins,\n getDictionary as getDictionaryCore,\n} from '@intlayer/core';\nimport {\n type DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n reactNodePlugins,\n} from './plugins';\nimport type { Locales } from '@intlayer/config/client';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends
|
|
1
|
+
{"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n type Dictionary,\n type Plugins,\n getDictionary as getDictionaryCore,\n} from '@intlayer/core';\nimport {\n type DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n reactNodePlugins,\n} from './plugins';\nimport type { Locales, LocalesValues } from '@intlayer/config/client';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = Locales,\n>(\n dictionary: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n reactNodePlugins,\n markdownPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getDictionaryCore(\n dictionary,\n locale,\n plugins\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":"AACA;AAAA,EAGE,iBAAiB;AAAA,OACZ;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,MAAM,gBAAgB,CAI3B,YACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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, LocalesValues } from 'intlayer';\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\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":"AAEA;AAAA,EAGE,eAAe;AAAA,OACV;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,MAAM,cAAc,CACzB,KACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO,gBAAgB,KAAK,QAAQ,OAAO;AAG7C;","names":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IntlayerProvider,
|
|
3
|
+
IntlayerProviderContent,
|
|
3
4
|
IntlayerClientContext,
|
|
4
5
|
useIntlayer,
|
|
5
6
|
useIntlayerAsync,
|
|
@@ -17,6 +18,7 @@ import { MarkdownProvider } from "./markdown/index.mjs";
|
|
|
17
18
|
export {
|
|
18
19
|
IntlayerClientContext,
|
|
19
20
|
IntlayerProvider,
|
|
21
|
+
IntlayerProviderContent,
|
|
20
22
|
MarkdownProvider,
|
|
21
23
|
getBrowserLocale,
|
|
22
24
|
localeCookie,
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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> {}\n}\n\nexport {\n IntlayerProvider,\n IntlayerProviderContent,\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":"AAMA;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;","names":[]}
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NodeType
|
|
3
3
|
} from "@intlayer/core";
|
|
4
|
-
import { createElement } from "react";
|
|
5
4
|
import { renderIntlayerEditor } from "./editor/index.mjs";
|
|
6
5
|
import { renderMarkdown } from "./markdown/renderMarkdown.mjs";
|
|
6
|
+
import { renderReactElement } from "./reactElement/renderReactElement.mjs";
|
|
7
7
|
const intlayerNodePlugins = {
|
|
8
8
|
canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
|
|
9
9
|
transform: (_node, {
|
|
@@ -12,42 +12,9 @@ const intlayerNodePlugins = {
|
|
|
12
12
|
...rest
|
|
13
13
|
}) => renderIntlayerEditor(rest)
|
|
14
14
|
};
|
|
15
|
-
const createReactElement = (element) => {
|
|
16
|
-
if (typeof element === "string") {
|
|
17
|
-
return element;
|
|
18
|
-
}
|
|
19
|
-
const convertChildrenAsArray = (element2) => {
|
|
20
|
-
if (element2?.props && typeof element2.props.children === "object") {
|
|
21
|
-
const childrenResult = [];
|
|
22
|
-
const { children } = element2.props;
|
|
23
|
-
Object.keys(children ?? {}).forEach((key) => {
|
|
24
|
-
childrenResult.push(
|
|
25
|
-
createReactElement((children ?? {})[key])
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
...element2,
|
|
30
|
-
props: { ...element2.props, children: childrenResult }
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
...element2,
|
|
35
|
-
props: { ...element2.props, children: element2.props.children }
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
const fixedElement = convertChildrenAsArray(
|
|
39
|
-
element
|
|
40
|
-
);
|
|
41
|
-
const { type, props } = fixedElement;
|
|
42
|
-
return createElement(
|
|
43
|
-
type ?? "div",
|
|
44
|
-
props,
|
|
45
|
-
...props.children
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
15
|
const reactNodePlugins = {
|
|
49
16
|
canHandle: (node) => typeof node === "object" && typeof node.ref !== "undefined" && typeof node.props !== "undefined" && typeof node.key !== "undefined",
|
|
50
|
-
transform:
|
|
17
|
+
transform: renderReactElement
|
|
51
18
|
};
|
|
52
19
|
const markdownPlugin = {
|
|
53
20
|
canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Markdown,
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +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
|
|
1
|
+
{"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/import/no-cycle */\n/* 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 { ReactNode } from 'react';\nimport { renderIntlayerEditor } from './editor';\nimport type { IntlayerNode } from './IntlayerNode';\nimport { renderMarkdown } from './markdown/renderMarkdown';\nimport { renderReactElement } from './reactElement/renderReactElement';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n 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> = T extends {\n ref: any;\n props: any;\n key: any;\n}\n ? ReactNode\n : never;\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: renderReactElement,\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownCond<T> = 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> {\n reactNode: ReactNodeCond<T>;\n intlayerNode: IntlayerNodeCond<T>;\n markdown: MarkdownCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `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":"AAEA;AAAA,EAKE;AAAA,OACK;AAEP,SAAS,4BAA4B;AAErC,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AAW5B,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,MACG,qBAAqB,IAAI;AAChC;AAeO,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,SAAS;AAAA,EAC1D,WAAW,CAAC,SAA0B,eAAe,KAAK,SAAS,QAAQ,CAAC;AAC9E;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
const renderReactElement = (element) => {
|
|
3
|
+
if (typeof element === "string") {
|
|
4
|
+
return element;
|
|
5
|
+
}
|
|
6
|
+
const convertChildrenAsArray = (element2) => {
|
|
7
|
+
if (element2?.props && typeof element2.props.children === "object") {
|
|
8
|
+
const childrenResult = [];
|
|
9
|
+
const { children } = element2.props;
|
|
10
|
+
Object.keys(children ?? {}).forEach((key) => {
|
|
11
|
+
childrenResult.push(
|
|
12
|
+
renderReactElement((children ?? {})[key])
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
...element2,
|
|
17
|
+
props: { ...element2.props, children: childrenResult }
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...element2,
|
|
22
|
+
props: { ...element2.props, children: element2.props.children }
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const fixedElement = convertChildrenAsArray(
|
|
26
|
+
element
|
|
27
|
+
);
|
|
28
|
+
const { type, props } = fixedElement;
|
|
29
|
+
return createElement(
|
|
30
|
+
type ?? "div",
|
|
31
|
+
props,
|
|
32
|
+
...props.children
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
renderReactElement
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=renderReactElement.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/reactElement/renderReactElement.ts"],"sourcesContent":["import { type ReactElement, type ReactNode, createElement } from 'react';\n\n// This function recursively creates React elements from a given JSON-like structure\nexport const renderReactElement = (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 renderReactElement((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"],"mappings":"AAAA,SAA4C,qBAAqB;AAG1D,MAAM,qBAAqB,CAAC,YAA0B;AAC3D,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,SAAO;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA,GAAI,MAAM;AAAA,EACZ;AACF;","names":["element"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { type
|
|
1
|
+
{"version":3,"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { type LocalesValues, 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 =\n createServerContext<LocalesValues>(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?: LocalesValues;\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":"AAiCE;AAjCF,SAA6B,wBAAwB;AAErD,SAAS,qBAAqB,wBAAwB;AAEtD,MAAM,EAAE,cAAc,IAAI,iBAAiB,EAAE;AAKtC,MAAM,wBACX,oBAAmC,aAAa;AAK3C,MAAM,cAAc,MAAM,iBAAiB,qBAAqB;AAKhE,MAAM,SAAS,iBAAiB,qBAAqB;AASrD,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,QAAAA,UAAS;AACX,MACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAAOA,SACpC,UACH;","names":["locale"]}
|
package/dist/esm/server/t.mjs
CHANGED
|
@@ -2,9 +2,7 @@ import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
|
|
|
2
2
|
import { getServerContext } from "./serverContext.mjs";
|
|
3
3
|
import { getTranslation } from "@intlayer/core";
|
|
4
4
|
const t = (multilangContent, locale) => {
|
|
5
|
-
const currentLocale = getServerContext(
|
|
6
|
-
IntlayerServerContext
|
|
7
|
-
);
|
|
5
|
+
const currentLocale = getServerContext(IntlayerServerContext);
|
|
8
6
|
const localeTarget = locale ?? currentLocale;
|
|
9
7
|
return getTranslation(multilangContent, localeTarget);
|
|
10
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/t.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/t.ts"],"sourcesContent":["import type { LocalesValues } 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?: LocalesValues\n) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":"AACA,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AACjC,SAA+B,sBAAsB;AAuB9C,MAAM,IAAI,CACf,kBACA,WACG;AACH,QAAM,gBAAgB,iBAAgC,qBAAqB;AAC3E,QAAM,eAAe,UAAU;AAE/B,SAAO,eAAwB,kBAAkB,YAAY;AAC/D;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
|
|
2
2
|
import { getServerContext } from "./serverContext.mjs";
|
|
3
3
|
import { getDictionary } from "../getDictionary.mjs";
|
|
4
|
-
const useDictionary = (dictionary, locale
|
|
4
|
+
const useDictionary = (dictionary, locale) => {
|
|
5
5
|
const localeTarget = locale ?? getServerContext(IntlayerServerContext);
|
|
6
6
|
return getDictionary(dictionary, localeTarget);
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { LocalesValues } 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?: LocalesValues\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n return getDictionary<T, LocalesValues>(dictionary, localeTarget);\n};\n"],"mappings":"AAEA,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAOvB,MAAM,gBAAgB,CAC3B,YACA,WACG;AACH,QAAM,eACJ,UAAU,iBAAgC,qBAAqB;AAEjE,SAAO,cAAgC,YAAY,YAAY;AACjE;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IntlayerServerContext } from "./IntlayerServerProvider.mjs";
|
|
2
2
|
import { getServerContext } from "./serverContext.mjs";
|
|
3
3
|
import { getIntlayer } from "../getIntlayer.mjs";
|
|
4
|
-
const useIntlayer = (key, locale
|
|
4
|
+
const useIntlayer = (key, locale) => {
|
|
5
5
|
const localeTarget = locale ?? getServerContext(IntlayerServerContext);
|
|
6
6
|
return getIntlayer(key, localeTarget);
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { LocalesValues } 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 = <T extends DictionaryKeys, K extends LocalesValues>(\n key: T,\n locale?: K\n) => {\n const localeTarget =\n locale ?? getServerContext<LocalesValues>(IntlayerServerContext);\n\n return getIntlayer(key, localeTarget);\n};\n"],"mappings":"AACA,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAEjC,SAAS,mBAAmB;AAOrB,MAAM,cAAc,CACzB,KACA,WACG;AACH,QAAM,eACJ,UAAU,iBAAgC,qBAAqB;AAEjE,SAAO,YAAY,KAAK,YAAY;AACtC;","names":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
import { type FC, type PropsWithChildren } from 'react';
|
|
3
3
|
type IntlayerValue = {
|
|
4
|
-
locale:
|
|
5
|
-
setLocale: (newLocale:
|
|
4
|
+
locale: LocalesValues;
|
|
5
|
+
setLocale: (newLocale: LocalesValues) => void;
|
|
6
|
+
disableEditor?: boolean;
|
|
6
7
|
};
|
|
7
8
|
/**
|
|
8
9
|
* Context that store the current locale on the client side
|
|
@@ -13,9 +14,14 @@ export declare const IntlayerClientContext: import("react").Context<IntlayerValu
|
|
|
13
14
|
*/
|
|
14
15
|
export declare const useIntlayerContext: () => IntlayerValue;
|
|
15
16
|
export type IntlayerProviderProps = PropsWithChildren & {
|
|
16
|
-
locale?:
|
|
17
|
-
setLocale?: (locale:
|
|
17
|
+
locale?: LocalesValues;
|
|
18
|
+
setLocale?: (locale: LocalesValues) => void;
|
|
19
|
+
disableEditor?: boolean;
|
|
18
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Provider that store the current locale on the client side
|
|
23
|
+
*/
|
|
24
|
+
export declare const IntlayerProviderContent: FC<IntlayerProviderProps>;
|
|
19
25
|
export declare const IntlayerProvider: FC<IntlayerProviderProps>;
|
|
20
26
|
export {};
|
|
21
27
|
//# sourceMappingURL=IntlayerProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","sourceRoot":"","sources":["../../../src/client/IntlayerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAK/E,OAAO,EACL,KAAK,EAAE,EACP,KAAK,iBAAiB,EAKvB,MAAM,OAAO,CAAC;AAKf,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,wCAIhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAA0C,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG;IACtD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,qBAAqB,CA6C7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAMtD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type IntlayerProviderProps, IntlayerClientContext, useIntlayerContext, IntlayerProvider, } from './IntlayerProvider';
|
|
1
|
+
export { type IntlayerProviderProps, IntlayerClientContext, IntlayerProviderContent, useIntlayerContext, IntlayerProvider, } from './IntlayerProvider';
|
|
2
2
|
export { useIntlayer } from './useIntlayer';
|
|
3
3
|
export { useIntlayerAsync } from './useIntlayerAsync';
|
|
4
4
|
export { useDictionary } from './useDictionary';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
|
@@ -3,7 +3,7 @@ import type { LanguageContent } from '@intlayer/core';
|
|
|
3
3
|
* On the client side, hook to get the translation content based on the locale
|
|
4
4
|
*/
|
|
5
5
|
export declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
|
|
6
|
-
locale:
|
|
6
|
+
locale: import("intlayer").LocalesValues;
|
|
7
7
|
content: Content;
|
|
8
8
|
t: <Content_1 = string>(languageContent: LanguageContent<Content_1>) => Content_1;
|
|
9
9
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type Dictionary } from '@intlayer/core';
|
|
1
|
+
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
import { DeepTransformContent, type Dictionary } from '@intlayer/core';
|
|
3
3
|
/**
|
|
4
4
|
* On the server side, Hook that transform a dictionary and return the content
|
|
5
5
|
*
|
|
6
6
|
* If the locale is not provided, it will use the locale from the client context
|
|
7
7
|
*/
|
|
8
|
-
export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?:
|
|
8
|
+
export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => DeepTransformContent<T["content"]>;
|
|
9
9
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKvE;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,cACpC,CAAC,WACJ,aAAa,KAQV,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAC9C,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Locales } from '@intlayer/config/client';
|
|
2
|
-
import {
|
|
2
|
+
import type { DictionaryKeys } from '@intlayer/core';
|
|
3
3
|
import { IntlayerDictionaryTypesConnector } from 'intlayer';
|
|
4
|
+
import type { DeepTransformContent } from '../plugins';
|
|
4
5
|
/**
|
|
5
6
|
* On the client side, Hook that picking one dictionary by its key and return the content
|
|
6
7
|
*
|
|
7
8
|
* If the locale is not provided, it will use the locale from the client context
|
|
8
9
|
*/
|
|
9
|
-
export declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: Locales) =>
|
|
10
|
+
export declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: Locales) => DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>;
|
|
10
11
|
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIrD,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,OAC7C,CAAC,WACG,OAAO,KACf,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAWrE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
2
|
import { type DictionaryKeys } from '@intlayer/core';
|
|
3
3
|
/**
|
|
4
4
|
* On the client side, Hook that picking one dictionary by its key and return the content
|
|
@@ -8,7 +8,7 @@ import { type DictionaryKeys } from '@intlayer/core';
|
|
|
8
8
|
*
|
|
9
9
|
* If the locale is not provided, it will use the locale from the client context
|
|
10
10
|
*/
|
|
11
|
-
export declare const useIntlayerAsync: <T extends DictionaryKeys>(key: T, locale?:
|
|
11
|
+
export declare const useIntlayerAsync: <T extends DictionaryKeys>(key: T, locale?: LocalesValues, isRenderEditor?: boolean) => import("@intlayer/core").DeepTransformContent<import("intlayer").IntlayerDictionaryTypesConnector[T]["content"], import("@intlayer/core").IInterpreterPluginState> & {
|
|
12
12
|
isLoading: boolean;
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=useIntlayerAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayerAsync.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayerAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useIntlayerAsync.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayerAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,cAAc,OAClD,CAAC,WACG,aAAa,+BA8B6B,qKAA0B;IAC3E,SAAS,EAAE,OAAO,CAAC;CAEtB,CAAC"}
|