react-intlayer 8.4.0-canary.0 → 8.4.1
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/format/useIntl.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useI18n.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +1 -1
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
- package/dist/cjs/server/format/useIntl.cjs.map +1 -1
- package/dist/cjs/server/useDictionary.cjs.map +1 -1
- package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
- package/dist/esm/client/format/useIntl.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useI18n.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs +1 -1
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
- package/dist/esm/server/format/useIntl.mjs.map +1 -1
- package/dist/esm/server/useDictionary.mjs.map +1 -1
- package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
- package/dist/types/client/format/useIntl.d.ts +2 -58
- package/dist/types/client/format/useIntl.d.ts.map +1 -1
- package/dist/types/client/format/useList.d.ts +5 -1
- package/dist/types/client/format/useList.d.ts.map +1 -1
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useI18n.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/html/HTMLRenderer.d.ts +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
- package/dist/types/server/format/useIntl.d.ts +2 -58
- package/dist/types/server/format/useIntl.d.ts.map +1 -1
- package/dist/types/server/useDictionary.d.ts.map +1 -1
- package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["'use client';\n\nimport { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext);\n const currentLocale = locale ?? contextLocale;\n\n return useMemo(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":"yOAmCA,MAAa,EAAW,GAA2B,CACjD,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAC7D,EAAgB,GAAU,EAEhC,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,
|
|
1
|
+
{"version":3,"file":"useIntl.cjs","names":["IntlayerClientContext"],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["'use client';\n\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext);\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":"yOAmCA,MAAa,EAAW,GAA2B,CACjD,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAC7D,EAAgB,GAAU,EAEhC,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,UAA2C,EAAc,CAAE,CAAC,EAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","configuration","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","configuration","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\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 useDictionaryAsync = async <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L) as any;\n};\n"],"mappings":"wRAkBA,MAAa,EAAqB,MAIhC,EACA,IACe,CACf,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAE7D,GAAA,EAAA,EAAA,aAEF,GACA,GACAC,EAAAA,SAAe,qBAAqB,cACtC,CAAC,EAAe,EAAO,CACxB,CAUD,OAAOC,EAAAA,cARY,MAAA,EAAA,EAAA,SACjB,SACG,MAAM,EACL,MACG,CACP,CAAC,EAAmB,EAAa,CAClC,CAEsC,EAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":"0TAmBA,MAAa,GAIX,EACA,EACA,IACG,CACH,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAC7D,GAAA,EAAA,EAAA,aAEF,GACA,GACAC,EAAAA,SAAe,qBAAqB,cACtC,CAAC,EAAe,EAAO,CACxB,CAOD,OAAOC,EAAAA,cALYC,EAAAA,eACjB,GAAG,OAAO,EAAI,CAAC,GAAG,IACjB,EAA0B,MAAiB,CAC7C,CAEgC,EAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayer } from '@intlayer/core/interpreter';\nimport type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type {
|
|
1
|
+
{"version":3,"file":"useI18n.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayer } from '@intlayer/core/interpreter';\nimport type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { GetSubPath } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * // For attributes like `aria-label`, use `.value` to get the plain string\n * const ariaLabel = t('button.ariaLabel').value; // 'Close modal'\n * ```\n */\nexport const useI18n = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n namespace: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n // Get the dictionary content for the namespace\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const dictionaryContent: DeepTransformContent<DictionaryRegistryContent<T>> =\n useMemo(\n () => getIntlayer<T, L>(namespace, localeTarget as L),\n [namespace, localeTarget]\n );\n\n // Return the translation function\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n ): GetSubPath<DeepTransformContent<DictionaryRegistryContent<T>>, P> => {\n if (!path) {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":"sOAgCA,MAAa,GAIX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAC7D,GAAA,EAAA,EAAA,aACE,GAAU,EAChB,CAAC,EAAe,EAAO,CACxB,CAIK,GAAA,EAAA,EAAA,cAAA,EAAA,EAAA,aAEsB,EAAW,EAAkB,CACrD,CAAC,EAAW,EAAa,CAC1B,CA2BH,MAtBE,IAEsE,CACtE,GAAI,CAAC,EAEH,OAAO,EAGT,IAAM,EAAa,EAAgB,MAAM,IAAI,CACzC,EAAe,EAEnB,IAAK,IAAM,KAAO,EAEhB,GADA,EAAU,IAAU,GAChB,IAAY,IAAA,GAEd,OAAO,EAIX,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that picks one dictionary by its key and returns its content.\n *\n * If the locale is not provided, it will use the locale from the client context.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The dictionary content for the specified locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? (currentLocale as L);\n\n return getIntlayer<T, L>(key, localeTarget);\n }, [key, currentLocale, locale]);\n};\n"],"mappings":"8NA+BA,MAAa,GAIX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,IAAA,EAAA,EAAA,YAA6BA,EAAAA,sBAAsB,CAEnE,OAAA,EAAA,EAAA,aAGSC,EAAAA,YAAkB,EAFJ,GAAW,EAEW,CAC1C,CAAC,EAAK,EAAe,EAAO,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./processor.cjs`),t=require(`./MarkdownProvider.cjs`);let n=require(`react/jsx-runtime`);const r=(t,{components:n,wrapper:r,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>e.compiler(t,{components:n,forceBlock:i,forceInline:a,wrapper:r,forceWrapper:!!r,preserveFrontmatter:o,tagfilter:s}),i=({components:e,wrapper:n,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>{let c=t.useMarkdownContext();return t=>c?c.renderMarkdown(t,{forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s},e,n):r(t,{components:e,wrapper:n,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s})},a=({children:r=``,components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l,renderMarkdown:u})=>{let d=t.useMarkdownContext();return u?(0,n.jsx)(n.Fragment,{children:u(r,{components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l})}):d?(0,n.jsx)(n.Fragment,{children:d.renderMarkdown(r,{forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l},i,a)}):(0,n.jsx)(n.Fragment,{children:e.compiler(r,{components:i,forceBlock:o,forceInline:s,wrapper:a,forceWrapper:!!a,preserveFrontmatter:c,tagfilter:l})})};exports.MarkdownRenderer=a,exports.renderMarkdown=r,exports.useMarkdownRenderer=i;
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./processor.cjs`),t=require(`./MarkdownProvider.cjs`);let n=require(`react/jsx-runtime`);const r=(t,{components:n,wrapper:r,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>e.compiler(t,{components:n,forceBlock:i,forceInline:a,wrapper:r,forceWrapper:!!r,preserveFrontmatter:o,tagfilter:s}),i=({components:e,wrapper:n,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>{let c=t.useMarkdownContext();return t=>c?c.renderMarkdown(t,{forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s},e,n):r(t,{components:e,wrapper:n,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s})},a=({children:r=``,components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l,renderMarkdown:u})=>{let d=t.useMarkdownContext();return u?(0,n.jsx)(n.Fragment,{children:u(r,{components:i,wrapper:a,forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l})}):d?(0,n.jsx)(n.Fragment,{children:d.renderMarkdown(r,{forceBlock:o,forceInline:s,preserveFrontmatter:c,tagfilter:l},i,a)}):(0,n.jsx)(n.Fragment,{children:e.compiler(r,{components:i,forceBlock:o,forceInline:s,wrapper:a,forceWrapper:!!a,preserveFrontmatter:c,tagfilter:l})})};exports.MarkdownRenderer=a,exports.renderMarkdown=r,exports.useMarkdownRenderer=i;
|
|
2
2
|
//# sourceMappingURL=MarkdownRenderer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.cjs","names":["compiler","useMarkdownContext"],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type { FC, HTMLAttributes, JSX, ReactNode } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\nimport { compiler, type MarkdownRendererOptions } from './processor';\n\n/**\n * Props for rendering markdown content.\n *\n * @example\n * ```tsx\n * const props: RenderMarkdownProps = {\n * components: {\n * h1: ({ children }) => <h1 className=\"text-3xl\">{children}</h1>,\n * p: ({ children }) => <p className=\"text-gray-700\">{children}</p>,\n * },\n * wrapper: ({ children }) => <article>{children}</article>,\n * options: {\n * forceBlock: true,\n * preserveFrontmatter: false,\n * tagfilter: true,\n * },\n * };\n * ```\n */\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n * Only used if not wrapped in a MarkdownProvider.\n *\n * @example\n * ```tsx\n * components={{\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * a: ({ href, children }) => <Link to={href}>{children}</Link>,\n * }}\n * ```\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n *\n * @example\n * ```tsx\n * wrapper={({ children }) => <div className=\"markdown-content\">{children}</div>}\n * ```\n */\n wrapper?: FC<HTMLAttributes<HTMLElement>>;\n};\n\n/**\n * Renders markdown content to JSX with the provided components and options.\n *\n * This function does not use context from MarkdownProvider. Use `useMarkdownRenderer`\n * hook if you want to leverage provider context.\n *\n * @param content - The markdown string to render\n * @param props - Configuration options for rendering\n * @param props.components - Component overrides for HTML tags\n * @param props.wrapper - Wrapper component for multiple children\n * @returns JSX element representing the rendered markdown\n *\n * @example\n * ```tsx\n * import { renderMarkdown } from '@intlayer/react-intlayer/markdown';\n *\n * const markdown = '# Hello World\\n\\nThis is **bold** text.';\n * const jsx = renderMarkdown(markdown, {\n * components: {\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * },\n * forceBlock: true,\n * });\n * ```\n */\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownRendererOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compiler(content, internalOptions);\n};\n\n/**\n * Hook that returns a function to render markdown content.\n *\n * This hook considers the configuration from the `MarkdownProvider` context if available,\n * falling back to the provided props or default behavior.\n *\n * @param props - Optional configuration that will override context values\n * @param props.components - Component overrides for HTML tags (overrides context)\n * @param props.wrapper - Wrapper component (overrides context)\n * @returns A function that takes markdown content and returns JSX\n *\n * @example\n * ```tsx\n * import { useMarkdownRenderer } from '@intlayer/react-intlayer/markdown';\n *\n * function MyComponent() {\n * const renderMarkdown = useMarkdownRenderer({\n * components: {\n * h1: ({ children }) => <h1 className=\"custom\">{children}</h1>,\n * },\n * });\n *\n * return (\n * <div>\n * {renderMarkdown('# Hello\\n\\nThis is **markdown**')}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With MarkdownProvider context\n * function App() {\n * return (\n * <MarkdownProvider\n * components={{ h1: CustomHeading }}\n * forceBlock={true}\n * >\n * <MyComponent />\n * </MarkdownProvider>\n * );\n * }\n * ```\n */\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\n/**\n * Props for the MarkdownRenderer component.\n *\n * @example\n * ```tsx\n * const props: MarkdownRendererProps = {\n * children: '# Hello World\\n\\nThis is **bold** text.',\n * components: {\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * },\n * wrapper: ({ children }) => <article>{children}</article>,\n * forceBlock: true,\n * };\n * ```\n */\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render as a string.\n *\n * @example\n * ```tsx\n * <MarkdownRenderer>\n * {`# Title\\n\\nParagraph with **bold** text.`}\n * </MarkdownRenderer>\n * ```\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n *\n * @param markdown - The markdown string to render\n * @param options - Optional rendering options\n * @returns React node representing the rendered markdown\n *\n * @example\n * ```tsx\n * <MarkdownRenderer\n * renderMarkdown={(md, opts) => {\n * // Custom rendering logic\n * return <div dangerouslySetInnerHTML={{ __html: customParser(md) }} />;\n * }}\n * >\n * {markdownContent}\n * </MarkdownRenderer>\n * ```\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: FC;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ReactNode;\n};\n\n/**\n * React component that renders markdown content to JSX.\n *\n * This component uses the `renderMarkdown` function from the `MarkdownProvider` context\n * if available. Otherwise, it falls back to the default compiler with provided components\n * and options. You can also provide a custom `renderMarkdown` function prop to override\n * all rendering behavior.\n *\n * @example\n * ```tsx\n * import { MarkdownRenderer } from '@intlayer/react-intlayer/markdown';\n *\n * function MyComponent() {\n * return (\n * <MarkdownRenderer>\n * {`# Hello World\n *\n * This is a paragraph with **bold** and *italic* text.\n *\n * - List item 1\n * - List item 2`}\n * </MarkdownRenderer>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom components\n * <MarkdownRenderer\n * components={{\n * h1: ({ children }) => <h1 className=\"text-4xl font-bold\">{children}</h1>,\n * a: ({ href, children }) => (\n * <a href={href} className=\"text-blue-500 hover:underline\">\n * {children}\n * </a>\n * ),\n * }}\n * forceBlock={true}\n * >\n * {markdownContent}\n * </MarkdownRenderer>\n * ```\n *\n * @example\n * ```tsx\n * // With MarkdownProvider context\n * function App() {\n * return (\n * <MarkdownProvider\n * components={{ h1: CustomHeading }}\n * forceBlock={true}\n * >\n * <MarkdownRenderer>\n * {markdownContent}\n * </MarkdownRenderer>\n * </MarkdownProvider>\n * );\n * }\n * ```\n */\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (renderMarkdown) {\n return (\n <>\n {renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n // Map public options to internal processor options\n const internalOptions: MarkdownRendererOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return <>{compiler(children, internalOptions)}</>;\n};\n"],"mappings":"0NA+EA,MAAa,GACX,EACA,CACE,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAapBA,EAAAA,SAAS,EAViC,CAC/C,aACA,aACA,cACA,UACA,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAEwC,CAgD9B,GAAuB,CAClC,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAAK,CAC9B,IAAM,EAAUC,EAAAA,oBAAoB,CAEpC,MAAQ,IACF,EACK,EAAQ,eACb,EACA,CACE,aACA,cACA,sBACA,YACD,CACD,EACA,EACD,CAGI,EAAe,EAAS,CAC7B,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,EA6HO,GAA+C,CAC1D,WAAW,GACX,aACA,UACA,aACA,cACA,sBACA,YACA,oBACI,CACJ,IAAM,EAAUA,EAAAA,oBAAoB,CA8CpC,OA5CI,GAEA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SACG,EAAe,EAAU,CACxB,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,CACD,CAAA,CAIH,GAEA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SACG,EAAQ,eACP,EACA,CACE,aACA,cACA,sBACA,YACD,CACD,EACA,EACD,CACA,CAAA,EAeA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAAGD,EAAAA,SAAS,EAV8B,CAC/C,aACA,aACA,cACA,UACA,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAE4C,CAAI,CAAA"}
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.cjs","names":["compiler","useMarkdownContext"],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC, HTMLAttributes, JSX, ReactNode } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\nimport { compiler, type MarkdownRendererOptions } from './processor';\n\n/**\n * Props for rendering markdown content.\n *\n * @example\n * ```tsx\n * const props: RenderMarkdownProps = {\n * components: {\n * h1: ({ children }) => <h1 className=\"text-3xl\">{children}</h1>,\n * p: ({ children }) => <p className=\"text-gray-700\">{children}</p>,\n * },\n * wrapper: ({ children }) => <article>{children}</article>,\n * options: {\n * forceBlock: true,\n * preserveFrontmatter: false,\n * tagfilter: true,\n * },\n * };\n * ```\n */\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n * Only used if not wrapped in a MarkdownProvider.\n *\n * @example\n * ```tsx\n * components={{\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * a: ({ href, children }) => <Link to={href}>{children}</Link>,\n * }}\n * ```\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n *\n * @example\n * ```tsx\n * wrapper={({ children }) => <div className=\"markdown-content\">{children}</div>}\n * ```\n */\n wrapper?: FC<HTMLAttributes<HTMLElement>>;\n};\n\n/**\n * Renders markdown content to JSX with the provided components and options.\n *\n * This function does not use context from MarkdownProvider. Use `useMarkdownRenderer`\n * hook if you want to leverage provider context.\n *\n * @param content - The markdown string to render\n * @param props - Configuration options for rendering\n * @param props.components - Component overrides for HTML tags\n * @param props.wrapper - Wrapper component for multiple children\n * @returns JSX element representing the rendered markdown\n *\n * @example\n * ```tsx\n * import { renderMarkdown } from '@intlayer/react-intlayer/markdown';\n *\n * const markdown = '# Hello World\\n\\nThis is **bold** text.';\n * const jsx = renderMarkdown(markdown, {\n * components: {\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * },\n * forceBlock: true,\n * });\n * ```\n */\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownRendererOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compiler(content, internalOptions);\n};\n\n/**\n * Hook that returns a function to render markdown content.\n *\n * This hook considers the configuration from the `MarkdownProvider` context if available,\n * falling back to the provided props or default behavior.\n *\n * @param props - Optional configuration that will override context values\n * @param props.components - Component overrides for HTML tags (overrides context)\n * @param props.wrapper - Wrapper component (overrides context)\n * @returns A function that takes markdown content and returns JSX\n *\n * @example\n * ```tsx\n * import { useMarkdownRenderer } from '@intlayer/react-intlayer/markdown';\n *\n * function MyComponent() {\n * const renderMarkdown = useMarkdownRenderer({\n * components: {\n * h1: ({ children }) => <h1 className=\"custom\">{children}</h1>,\n * },\n * });\n *\n * return (\n * <div>\n * {renderMarkdown('# Hello\\n\\nThis is **markdown**')}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With MarkdownProvider context\n * function App() {\n * return (\n * <MarkdownProvider\n * components={{ h1: CustomHeading }}\n * forceBlock={true}\n * >\n * <MyComponent />\n * </MarkdownProvider>\n * );\n * }\n * ```\n */\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\n/**\n * Props for the MarkdownRenderer component.\n *\n * @example\n * ```tsx\n * const props: MarkdownRendererProps = {\n * children: '# Hello World\\n\\nThis is **bold** text.',\n * components: {\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * },\n * wrapper: ({ children }) => <article>{children}</article>,\n * forceBlock: true,\n * };\n * ```\n */\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render as a string.\n *\n * @example\n * ```tsx\n * <MarkdownRenderer>\n * {`# Title\\n\\nParagraph with **bold** text.`}\n * </MarkdownRenderer>\n * ```\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n *\n * @param markdown - The markdown string to render\n * @param options - Optional rendering options\n * @returns React node representing the rendered markdown\n *\n * @example\n * ```tsx\n * <MarkdownRenderer\n * renderMarkdown={(md, opts) => {\n * // Custom rendering logic\n * return <div dangerouslySetInnerHTML={{ __html: customParser(md) }} />;\n * }}\n * >\n * {markdownContent}\n * </MarkdownRenderer>\n * ```\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: FC;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ReactNode;\n};\n\n/**\n * React component that renders markdown content to JSX.\n *\n * This component uses the `renderMarkdown` function from the `MarkdownProvider` context\n * if available. Otherwise, it falls back to the default compiler with provided components\n * and options. You can also provide a custom `renderMarkdown` function prop to override\n * all rendering behavior.\n *\n * @example\n * ```tsx\n * import { MarkdownRenderer } from '@intlayer/react-intlayer/markdown';\n *\n * function MyComponent() {\n * return (\n * <MarkdownRenderer>\n * {`# Hello World\n *\n * This is a paragraph with **bold** and *italic* text.\n *\n * - List item 1\n * - List item 2`}\n * </MarkdownRenderer>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom components\n * <MarkdownRenderer\n * components={{\n * h1: ({ children }) => <h1 className=\"text-4xl font-bold\">{children}</h1>,\n * a: ({ href, children }) => (\n * <a href={href} className=\"text-blue-500 hover:underline\">\n * {children}\n * </a>\n * ),\n * }}\n * forceBlock={true}\n * >\n * {markdownContent}\n * </MarkdownRenderer>\n * ```\n *\n * @example\n * ```tsx\n * // With MarkdownProvider context\n * function App() {\n * return (\n * <MarkdownProvider\n * components={{ h1: CustomHeading }}\n * forceBlock={true}\n * >\n * <MarkdownRenderer>\n * {markdownContent}\n * </MarkdownRenderer>\n * </MarkdownProvider>\n * );\n * }\n * ```\n */\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (renderMarkdown) {\n return (\n <>\n {renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n // Map public options to internal processor options\n const internalOptions: MarkdownRendererOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return <>{compiler(children, internalOptions)}</>;\n};\n"],"mappings":"uOAiFA,MAAa,GACX,EACA,CACE,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAapBA,EAAAA,SAAS,EAViC,CAC/C,aACA,aACA,cACA,UACA,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAEwC,CAgD9B,GAAuB,CAClC,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAAK,CAC9B,IAAM,EAAUC,EAAAA,oBAAoB,CAEpC,MAAQ,IACF,EACK,EAAQ,eACb,EACA,CACE,aACA,cACA,sBACA,YACD,CACD,EACA,EACD,CAGI,EAAe,EAAS,CAC7B,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,EA6HO,GAA+C,CAC1D,WAAW,GACX,aACA,UACA,aACA,cACA,sBACA,YACA,oBACI,CACJ,IAAM,EAAUA,EAAAA,oBAAoB,CA8CpC,OA5CI,GAEA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SACG,EAAe,EAAU,CACxB,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,CACD,CAAA,CAIH,GAEA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SACG,EAAQ,eACP,EACA,CACE,aACA,cACA,sBACA,YACD,CACD,EACA,EACD,CACA,CAAA,EAeA,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAAGD,EAAAA,SAAS,EAV8B,CAC/C,aACA,aACA,cACA,UACA,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAE4C,CAAI,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./MarkdownProvider.cjs`);let n=require(`@intlayer/config/built`);n=e.__toESM(n);let r=require(`react`),i=require(`react/jsx-runtime`);const a=e=>{let{children:n,options:r,components:i}=e,a=t.useMarkdownContext();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})},o=(0,r.lazy)(()=>Promise.resolve().then(()=>require(`./MarkdownMetadataRendererInternal.cjs`)).then(e=>({default:e.MarkdownMetadataRendererInternal}))),s=e=>{let{editor:t}=n.default??{},a=t?.enabled??!1;return typeof window<`u`&&a?(0,i.jsx)(r.Suspense,{fallback:null,children:(0,i.jsx)(o,{...e})}):null};exports.MarkdownMetadataRenderer=s,exports.MarkdownRendererPlugin=a;
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./MarkdownProvider.cjs`);let n=require(`@intlayer/config/built`);n=e.__toESM(n);let r=require(`react`),i=require(`react/jsx-runtime`);const a=e=>{let{children:n,options:r,components:i}=e,a=t.useMarkdownContext();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})},o=(0,r.lazy)(()=>Promise.resolve().then(()=>require(`./MarkdownMetadataRendererInternal.cjs`)).then(e=>({default:e.MarkdownMetadataRendererInternal}))),s=e=>{let{editor:t}=n.default??{},a=t?.enabled??!1;return typeof window<`u`&&a?(0,i.jsx)(r.Suspense,{fallback:null,children:(0,i.jsx)(o,{...e})}):null};exports.MarkdownMetadataRenderer=s,exports.MarkdownRendererPlugin=a;
|
|
2
2
|
//# sourceMappingURL=MarkdownRendererPlugin.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext","configuration","Suspense"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext","configuration","Suspense"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { type FC, lazy, type ReactNode, Suspense } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FC<MarkdownRendererPluginProps> = (\n props\n): ReactNode => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n const contentToRender = children;\n\n return renderMarkdown(contentToRender, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n });\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nconst DynamicMarkdownMetadataRendererInternal = lazy(() =>\n import('./MarkdownMetadataRendererInternal').then((module) => ({\n default: module.MarkdownMetadataRendererInternal,\n }))\n);\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = (\n props\n): ReactNode => {\n const { editor } = configuration ?? {};\n const isEnabled = editor?.enabled ?? false;\n\n if (typeof window !== 'undefined' && isEnabled) {\n return (\n <Suspense fallback={null}>\n <DynamicMarkdownMetadataRendererInternal {...props} />\n </Suspense>\n );\n }\n\n return null;\n};\n"],"mappings":"sRAqBA,MAAa,EACX,GACc,CACd,GAAM,CAAE,WAAU,UAAS,cAAe,EACpC,EAAUA,EAAAA,oBAAoB,CAIpC,OAHuB,GAAS,iBAAoB,GAAO,IACnC,EAEe,EAAS,CAC9C,GAAI,GAAS,YAAc,EAAE,CAC7B,GAAI,GAAc,EAAE,CACrB,CAAC,EAOE,GAAA,EAAA,EAAA,UAAA,QAAA,SAAA,CAAA,SAAA,QACJ,yCAAA,CAAA,CAA6C,KAAM,IAAY,CAC7D,QAAS,EAAO,iCACjB,EAAE,CACJ,CAEY,EACX,GACc,CACd,GAAM,CAAE,UAAWC,EAAAA,SAAiB,EAAE,CAChC,EAAY,GAAQ,SAAW,GAUrC,OARI,OAAO,OAAW,KAAe,GAEjC,EAAA,EAAA,KAACC,EAAAA,SAAD,CAAU,SAAU,eAClB,EAAA,EAAA,KAAC,EAAD,CAAyC,GAAI,EAAS,CAAA,CAC7C,CAAA,CAIR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.cjs","names":["getServerContext","IntlayerServerContext","configuration"],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ??\n currentLocale ??\n configuration?.internationalization?.defaultLocale\n );\n};\n"],"mappings":"0SAkCA,MAAa,EAAW,
|
|
1
|
+
{"version":3,"file":"useIntl.cjs","names":["getServerContext","IntlayerServerContext","configuration"],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues): WrappedIntl => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ??\n currentLocale ??\n configuration?.internationalization?.defaultLocale\n );\n};\n"],"mappings":"0SAkCA,MAAa,EAAW,GAAwC,CAC9D,IAAM,EAAgBA,EAAAA,iBAAgCC,EAAAA,sBAAsB,CAE5E,OAAA,EAAA,EAAA,UACE,GACE,GACAC,EAAAA,SAAe,sBAAsB,cACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.cjs","names":["getDictionary","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"useDictionary.cjs","names":["getDictionary","getServerContext","IntlayerServerContext"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\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 = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":"sLAca,GAIX,EACA,EACA,IAOOA,EAAAA,cAAoB,EAJzB,GACAC,EAAAA,iBAAgCC,EAAAA,sBAAsB,EACtD,EAEuD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.cjs","names":["getServerContext","IntlayerServerContext","configuration","useDictionary"],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.cjs","names":["getServerContext","IntlayerServerContext","configuration","useDictionary"],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\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 useDictionaryAsync = async <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n configuration?.internationalization.defaultLocale;\n\n const dictionary = await (dictionaryPromise as any)[localeTarget]?.();\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":"2RAgBA,MAAa,EAAqB,MAIhC,EACA,EACA,IACG,CACH,IAAM,EACJ,GACAA,EAAAA,iBAAgCC,EAAAA,sBAAsB,EACtD,GACAC,EAAAA,SAAe,qBAAqB,cAItC,OAAOC,EAAAA,cAFY,MAAO,EAA0B,MAAiB,CAE9B,EAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.cjs","names":["getServerContext","IntlayerServerContext","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.cjs","names":["getServerContext","IntlayerServerContext","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 useDictionaryDynamic = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: string,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n configuration?.internationalization.defaultLocale;\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":"6TAiBA,MAAa,GAIX,EACA,EACA,EACA,IACG,CACH,IAAM,EACJ,GACAA,EAAAA,iBAAgCC,EAAAA,sBAAsB,EACtD,GACAC,EAAAA,SAAe,qBAAqB,cAOtC,OAAOC,EAAAA,cALYC,EAAAA,eACjB,GAAG,OAAO,EAAI,CAAC,GAAG,IACjB,EAA0B,MAAiB,CAC7C,CAEsC,EAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["'use client';\n\nimport { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext);\n const currentLocale = locale ?? contextLocale;\n\n return useMemo(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":"kLAmCA,MAAa,EAAW,GAA2B,CACjD,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAC7D,EAAgB,GAAU,EAEhC,OAAO,
|
|
1
|
+
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/client/format/useIntl.ts"],"sourcesContent":["'use client';\n\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from '../IntlayerProvider';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext);\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":"kLAmCA,MAAa,EAAW,GAA2B,CACjD,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAC7D,EAAgB,GAAU,EAEhC,OAAO,MAA2B,EAAS,EAAc,CAAE,CAAC,EAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\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 useDictionaryAsync = async <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L) as any;\n};\n"],"mappings":"sNAkBA,MAAa,EAAqB,MAIhC,EACA,IACe,CACf,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAE7D,EAAe,MAEjB,GACA,GACA,GAAe,qBAAqB,cACtC,CAAC,EAAe,EAAO,CACxB,CAUD,OAAO,EARY,MAAM,EACvB,SACG,MAAM,EACL,MACG,CACP,CAAC,EAAmB,EAAa,CAClC,CAEsC,EAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () =>\n locale ??\n currentLocale ??\n configuration?.internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":"4QAmBA,MAAa,GAIX,EACA,EACA,IACG,CACH,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAC7D,EAAe,MAEjB,GACA,GACA,GAAe,qBAAqB,cACtC,CAAC,EAAe,EAAO,CACxB,CAOD,OAAO,EALY,EACjB,GAAG,OAAO,EAAI,CAAC,GAAG,IACjB,EAA0B,MAAiB,CAC7C,CAEgC,EAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.mjs","names":[],"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayer } from '@intlayer/core/interpreter';\nimport type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type {
|
|
1
|
+
{"version":3,"file":"useI18n.mjs","names":[],"sources":["../../../src/client/useI18n.ts"],"sourcesContent":["'use client';\n\nimport { getIntlayer } from '@intlayer/core/interpreter';\nimport type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { GetSubPath } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Hook that provides a translation function `t()` for accessing nested content by key.\n * This hook mimics the pattern found in libraries like i18next, next-intl, and vue-i18n.\n *\n * @param namespace - The dictionary key to scope translations to\n * @param locale - Optional locale override. If not provided, uses the current context locale\n * @returns A translation function `t(key)` that returns the translated content for the given key\n *\n * @example\n * ```tsx\n * const t = useI18n('IndexPage');\n * const title = t('title'); // Returns translated string for 'IndexPage.title'\n * const nestedContent = t('section.subtitle'); // Returns 'IndexPage.section.subtitle'\n * // For attributes like `aria-label`, use `.value` to get the plain string\n * const ariaLabel = t('button.ariaLabel').value; // 'Close modal'\n * ```\n */\nexport const useI18n = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n namespace: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n // Get the dictionary content for the namespace\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const dictionaryContent: DeepTransformContent<DictionaryRegistryContent<T>> =\n useMemo(\n () => getIntlayer<T, L>(namespace, localeTarget as L),\n [namespace, localeTarget]\n );\n\n // Return the translation function\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const t = <P extends ValidDotPathsFor<T>>(\n path: P\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n ): GetSubPath<DeepTransformContent<DictionaryRegistryContent<T>>, P> => {\n if (!path) {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return dictionaryContent as any;\n }\n\n const pathArray = (path as string).split('.');\n let current: any = dictionaryContent;\n\n for (const key of pathArray) {\n current = current?.[key];\n if (current === undefined) {\n // Return the whole dictionary as fallback if path is not found\n return dictionaryContent as any;\n }\n }\n\n return current;\n };\n\n return t;\n};\n"],"mappings":"qLAgCA,MAAa,GAIX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAC7D,EAAe,MACb,GAAU,EAChB,CAAC,EAAe,EAAO,CACxB,CAIK,EACJ,MACQ,EAAkB,EAAW,EAAkB,CACrD,CAAC,EAAW,EAAa,CAC1B,CA2BH,MAtBE,IAEsE,CACtE,GAAI,CAAC,EAEH,OAAO,EAGT,IAAM,EAAa,EAAgB,MAAM,IAAI,CACzC,EAAe,EAEnB,IAAK,IAAM,KAAO,EAEhB,GADA,EAAU,IAAU,GAChB,IAAY,IAAA,GAEd,OAAO,EAIX,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that picks one dictionary by its key and returns its content.\n *\n * If the locale is not provided, it will use the locale from the client context.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The dictionary content for the specified locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n\n return useMemo(() => {\n const localeTarget = locale ?? (currentLocale as L);\n\n return getIntlayer<T, L>(key, localeTarget);\n }, [key, currentLocale, locale]);\n};\n"],"mappings":"6KA+BA,MAAa,GAIX,EACA,IACG,CACH,GAAM,CAAE,OAAQ,GAAkB,EAAW,EAAsB,CAEnE,OAAO,MAGE,EAAkB,EAFJ,GAAW,EAEW,CAC1C,CAAC,EAAK,EAAe,EAAO,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{compiler as e}from"./processor.mjs";import{useMarkdownContext as t}from"./MarkdownProvider.mjs";import{Fragment as n,jsx as r}from"react/jsx-runtime";const i=(t,{components:n,wrapper:r,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>e(t,{components:n,forceBlock:i,forceInline:a,wrapper:r,forceWrapper:!!r,preserveFrontmatter:o,tagfilter:s}),a=({components:e,wrapper:n,forceBlock:r,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>{let c=t();return t=>c?c.renderMarkdown(t,{forceBlock:r,forceInline:a,preserveFrontmatter:o,tagfilter:s},e,n):i(t,{components:e,wrapper:n,forceBlock:r,forceInline:a,preserveFrontmatter:o,tagfilter:s})},o=({children:i=``,components:a,wrapper:o,forceBlock:s,forceInline:c,preserveFrontmatter:l,tagfilter:u,renderMarkdown:d})=>{let f=t();return d?r(n,{children:d(i,{components:a,wrapper:o,forceBlock:s,forceInline:c,preserveFrontmatter:l,tagfilter:u})}):f?r(n,{children:f.renderMarkdown(i,{forceBlock:s,forceInline:c,preserveFrontmatter:l,tagfilter:u},a,o)}):r(n,{children:e(i,{components:a,forceBlock:s,forceInline:c,wrapper:o,forceWrapper:!!o,preserveFrontmatter:l,tagfilter:u})})};export{o as MarkdownRenderer,i as renderMarkdown,a as useMarkdownRenderer};
|
|
1
|
+
"use client";import{compiler as e}from"./processor.mjs";import{useMarkdownContext as t}from"./MarkdownProvider.mjs";import{Fragment as n,jsx as r}from"react/jsx-runtime";const i=(t,{components:n,wrapper:r,forceBlock:i,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>e(t,{components:n,forceBlock:i,forceInline:a,wrapper:r,forceWrapper:!!r,preserveFrontmatter:o,tagfilter:s}),a=({components:e,wrapper:n,forceBlock:r,forceInline:a,preserveFrontmatter:o,tagfilter:s}={})=>{let c=t();return t=>c?c.renderMarkdown(t,{forceBlock:r,forceInline:a,preserveFrontmatter:o,tagfilter:s},e,n):i(t,{components:e,wrapper:n,forceBlock:r,forceInline:a,preserveFrontmatter:o,tagfilter:s})},o=({children:i=``,components:a,wrapper:o,forceBlock:s,forceInline:c,preserveFrontmatter:l,tagfilter:u,renderMarkdown:d})=>{let f=t();return d?r(n,{children:d(i,{components:a,wrapper:o,forceBlock:s,forceInline:c,preserveFrontmatter:l,tagfilter:u})}):f?r(n,{children:f.renderMarkdown(i,{forceBlock:s,forceInline:c,preserveFrontmatter:l,tagfilter:u},a,o)}):r(n,{children:e(i,{components:a,forceBlock:s,forceInline:c,wrapper:o,forceWrapper:!!o,preserveFrontmatter:l,tagfilter:u})})};export{o as MarkdownRenderer,i as renderMarkdown,a as useMarkdownRenderer};
|
|
2
2
|
//# sourceMappingURL=MarkdownRenderer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.mjs","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type { FC, HTMLAttributes, JSX, ReactNode } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\nimport { compiler, type MarkdownRendererOptions } from './processor';\n\n/**\n * Props for rendering markdown content.\n *\n * @example\n * ```tsx\n * const props: RenderMarkdownProps = {\n * components: {\n * h1: ({ children }) => <h1 className=\"text-3xl\">{children}</h1>,\n * p: ({ children }) => <p className=\"text-gray-700\">{children}</p>,\n * },\n * wrapper: ({ children }) => <article>{children}</article>,\n * options: {\n * forceBlock: true,\n * preserveFrontmatter: false,\n * tagfilter: true,\n * },\n * };\n * ```\n */\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n * Only used if not wrapped in a MarkdownProvider.\n *\n * @example\n * ```tsx\n * components={{\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * a: ({ href, children }) => <Link to={href}>{children}</Link>,\n * }}\n * ```\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n *\n * @example\n * ```tsx\n * wrapper={({ children }) => <div className=\"markdown-content\">{children}</div>}\n * ```\n */\n wrapper?: FC<HTMLAttributes<HTMLElement>>;\n};\n\n/**\n * Renders markdown content to JSX with the provided components and options.\n *\n * This function does not use context from MarkdownProvider. Use `useMarkdownRenderer`\n * hook if you want to leverage provider context.\n *\n * @param content - The markdown string to render\n * @param props - Configuration options for rendering\n * @param props.components - Component overrides for HTML tags\n * @param props.wrapper - Wrapper component for multiple children\n * @returns JSX element representing the rendered markdown\n *\n * @example\n * ```tsx\n * import { renderMarkdown } from '@intlayer/react-intlayer/markdown';\n *\n * const markdown = '# Hello World\\n\\nThis is **bold** text.';\n * const jsx = renderMarkdown(markdown, {\n * components: {\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * },\n * forceBlock: true,\n * });\n * ```\n */\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownRendererOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compiler(content, internalOptions);\n};\n\n/**\n * Hook that returns a function to render markdown content.\n *\n * This hook considers the configuration from the `MarkdownProvider` context if available,\n * falling back to the provided props or default behavior.\n *\n * @param props - Optional configuration that will override context values\n * @param props.components - Component overrides for HTML tags (overrides context)\n * @param props.wrapper - Wrapper component (overrides context)\n * @returns A function that takes markdown content and returns JSX\n *\n * @example\n * ```tsx\n * import { useMarkdownRenderer } from '@intlayer/react-intlayer/markdown';\n *\n * function MyComponent() {\n * const renderMarkdown = useMarkdownRenderer({\n * components: {\n * h1: ({ children }) => <h1 className=\"custom\">{children}</h1>,\n * },\n * });\n *\n * return (\n * <div>\n * {renderMarkdown('# Hello\\n\\nThis is **markdown**')}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With MarkdownProvider context\n * function App() {\n * return (\n * <MarkdownProvider\n * components={{ h1: CustomHeading }}\n * forceBlock={true}\n * >\n * <MyComponent />\n * </MarkdownProvider>\n * );\n * }\n * ```\n */\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\n/**\n * Props for the MarkdownRenderer component.\n *\n * @example\n * ```tsx\n * const props: MarkdownRendererProps = {\n * children: '# Hello World\\n\\nThis is **bold** text.',\n * components: {\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * },\n * wrapper: ({ children }) => <article>{children}</article>,\n * forceBlock: true,\n * };\n * ```\n */\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render as a string.\n *\n * @example\n * ```tsx\n * <MarkdownRenderer>\n * {`# Title\\n\\nParagraph with **bold** text.`}\n * </MarkdownRenderer>\n * ```\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n *\n * @param markdown - The markdown string to render\n * @param options - Optional rendering options\n * @returns React node representing the rendered markdown\n *\n * @example\n * ```tsx\n * <MarkdownRenderer\n * renderMarkdown={(md, opts) => {\n * // Custom rendering logic\n * return <div dangerouslySetInnerHTML={{ __html: customParser(md) }} />;\n * }}\n * >\n * {markdownContent}\n * </MarkdownRenderer>\n * ```\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: FC;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ReactNode;\n};\n\n/**\n * React component that renders markdown content to JSX.\n *\n * This component uses the `renderMarkdown` function from the `MarkdownProvider` context\n * if available. Otherwise, it falls back to the default compiler with provided components\n * and options. You can also provide a custom `renderMarkdown` function prop to override\n * all rendering behavior.\n *\n * @example\n * ```tsx\n * import { MarkdownRenderer } from '@intlayer/react-intlayer/markdown';\n *\n * function MyComponent() {\n * return (\n * <MarkdownRenderer>\n * {`# Hello World\n *\n * This is a paragraph with **bold** and *italic* text.\n *\n * - List item 1\n * - List item 2`}\n * </MarkdownRenderer>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom components\n * <MarkdownRenderer\n * components={{\n * h1: ({ children }) => <h1 className=\"text-4xl font-bold\">{children}</h1>,\n * a: ({ href, children }) => (\n * <a href={href} className=\"text-blue-500 hover:underline\">\n * {children}\n * </a>\n * ),\n * }}\n * forceBlock={true}\n * >\n * {markdownContent}\n * </MarkdownRenderer>\n * ```\n *\n * @example\n * ```tsx\n * // With MarkdownProvider context\n * function App() {\n * return (\n * <MarkdownProvider\n * components={{ h1: CustomHeading }}\n * forceBlock={true}\n * >\n * <MarkdownRenderer>\n * {markdownContent}\n * </MarkdownRenderer>\n * </MarkdownProvider>\n * );\n * }\n * ```\n */\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (renderMarkdown) {\n return (\n <>\n {renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n // Map public options to internal processor options\n const internalOptions: MarkdownRendererOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return <>{compiler(children, internalOptions)}</>;\n};\n"],"mappings":"6JA+EA,MAAa,GACX,EACA,CACE,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAapB,EAAS,EAViC,CAC/C,aACA,aACA,cACA,UACA,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAEwC,CAgD9B,GAAuB,CAClC,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAAK,CAC9B,IAAM,EAAU,GAAoB,CAEpC,MAAQ,IACF,EACK,EAAQ,eACb,EACA,CACE,aACA,cACA,sBACA,YACD,CACD,EACA,EACD,CAGI,EAAe,EAAS,CAC7B,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,EA6HO,GAA+C,CAC1D,WAAW,GACX,aACA,UACA,aACA,cACA,sBACA,YACA,oBACI,CACJ,IAAM,EAAU,GAAoB,CA8CpC,OA5CI,EAEA,EAAA,EAAA,CAAA,SACG,EAAe,EAAU,CACxB,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,CACD,CAAA,CAIH,EAEA,EAAA,EAAA,CAAA,SACG,EAAQ,eACP,EACA,CACE,aACA,cACA,sBACA,YACD,CACD,EACA,EACD,CACA,CAAA,CAeA,EAAA,EAAA,CAAA,SAAG,EAAS,EAV8B,CAC/C,aACA,aACA,cACA,UACA,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAE4C,CAAI,CAAA"}
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.mjs","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["'use client';\n\nimport type { FC, HTMLAttributes, JSX, ReactNode } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\nimport { compiler, type MarkdownRendererOptions } from './processor';\n\n/**\n * Props for rendering markdown content.\n *\n * @example\n * ```tsx\n * const props: RenderMarkdownProps = {\n * components: {\n * h1: ({ children }) => <h1 className=\"text-3xl\">{children}</h1>,\n * p: ({ children }) => <p className=\"text-gray-700\">{children}</p>,\n * },\n * wrapper: ({ children }) => <article>{children}</article>,\n * options: {\n * forceBlock: true,\n * preserveFrontmatter: false,\n * tagfilter: true,\n * },\n * };\n * ```\n */\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n * Only used if not wrapped in a MarkdownProvider.\n *\n * @example\n * ```tsx\n * components={{\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * a: ({ href, children }) => <Link to={href}>{children}</Link>,\n * }}\n * ```\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n *\n * @example\n * ```tsx\n * wrapper={({ children }) => <div className=\"markdown-content\">{children}</div>}\n * ```\n */\n wrapper?: FC<HTMLAttributes<HTMLElement>>;\n};\n\n/**\n * Renders markdown content to JSX with the provided components and options.\n *\n * This function does not use context from MarkdownProvider. Use `useMarkdownRenderer`\n * hook if you want to leverage provider context.\n *\n * @param content - The markdown string to render\n * @param props - Configuration options for rendering\n * @param props.components - Component overrides for HTML tags\n * @param props.wrapper - Wrapper component for multiple children\n * @returns JSX element representing the rendered markdown\n *\n * @example\n * ```tsx\n * import { renderMarkdown } from '@intlayer/react-intlayer/markdown';\n *\n * const markdown = '# Hello World\\n\\nThis is **bold** text.';\n * const jsx = renderMarkdown(markdown, {\n * components: {\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * },\n * forceBlock: true,\n * });\n * ```\n */\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownRendererOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compiler(content, internalOptions);\n};\n\n/**\n * Hook that returns a function to render markdown content.\n *\n * This hook considers the configuration from the `MarkdownProvider` context if available,\n * falling back to the provided props or default behavior.\n *\n * @param props - Optional configuration that will override context values\n * @param props.components - Component overrides for HTML tags (overrides context)\n * @param props.wrapper - Wrapper component (overrides context)\n * @returns A function that takes markdown content and returns JSX\n *\n * @example\n * ```tsx\n * import { useMarkdownRenderer } from '@intlayer/react-intlayer/markdown';\n *\n * function MyComponent() {\n * const renderMarkdown = useMarkdownRenderer({\n * components: {\n * h1: ({ children }) => <h1 className=\"custom\">{children}</h1>,\n * },\n * });\n *\n * return (\n * <div>\n * {renderMarkdown('# Hello\\n\\nThis is **markdown**')}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With MarkdownProvider context\n * function App() {\n * return (\n * <MarkdownProvider\n * components={{ h1: CustomHeading }}\n * forceBlock={true}\n * >\n * <MyComponent />\n * </MarkdownProvider>\n * );\n * }\n * ```\n */\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\n/**\n * Props for the MarkdownRenderer component.\n *\n * @example\n * ```tsx\n * const props: MarkdownRendererProps = {\n * children: '# Hello World\\n\\nThis is **bold** text.',\n * components: {\n * h1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n * },\n * wrapper: ({ children }) => <article>{children}</article>,\n * forceBlock: true,\n * };\n * ```\n */\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render as a string.\n *\n * @example\n * ```tsx\n * <MarkdownRenderer>\n * {`# Title\\n\\nParagraph with **bold** text.`}\n * </MarkdownRenderer>\n * ```\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n *\n * @param markdown - The markdown string to render\n * @param options - Optional rendering options\n * @returns React node representing the rendered markdown\n *\n * @example\n * ```tsx\n * <MarkdownRenderer\n * renderMarkdown={(md, opts) => {\n * // Custom rendering logic\n * return <div dangerouslySetInnerHTML={{ __html: customParser(md) }} />;\n * }}\n * >\n * {markdownContent}\n * </MarkdownRenderer>\n * ```\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: FC;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ReactNode;\n};\n\n/**\n * React component that renders markdown content to JSX.\n *\n * This component uses the `renderMarkdown` function from the `MarkdownProvider` context\n * if available. Otherwise, it falls back to the default compiler with provided components\n * and options. You can also provide a custom `renderMarkdown` function prop to override\n * all rendering behavior.\n *\n * @example\n * ```tsx\n * import { MarkdownRenderer } from '@intlayer/react-intlayer/markdown';\n *\n * function MyComponent() {\n * return (\n * <MarkdownRenderer>\n * {`# Hello World\n *\n * This is a paragraph with **bold** and *italic* text.\n *\n * - List item 1\n * - List item 2`}\n * </MarkdownRenderer>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom components\n * <MarkdownRenderer\n * components={{\n * h1: ({ children }) => <h1 className=\"text-4xl font-bold\">{children}</h1>,\n * a: ({ href, children }) => (\n * <a href={href} className=\"text-blue-500 hover:underline\">\n * {children}\n * </a>\n * ),\n * }}\n * forceBlock={true}\n * >\n * {markdownContent}\n * </MarkdownRenderer>\n * ```\n *\n * @example\n * ```tsx\n * // With MarkdownProvider context\n * function App() {\n * return (\n * <MarkdownProvider\n * components={{ h1: CustomHeading }}\n * forceBlock={true}\n * >\n * <MarkdownRenderer>\n * {markdownContent}\n * </MarkdownRenderer>\n * </MarkdownProvider>\n * );\n * }\n * ```\n */\nexport const MarkdownRenderer: FC<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (renderMarkdown) {\n return (\n <>\n {renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n // Map public options to internal processor options\n const internalOptions: MarkdownRendererOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return <>{compiler(children, internalOptions)}</>;\n};\n"],"mappings":"0KAiFA,MAAa,GACX,EACA,CACE,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAapB,EAAS,EAViC,CAC/C,aACA,aACA,cACA,UACA,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAEwC,CAgD9B,GAAuB,CAClC,aACA,UACA,aACA,cACA,sBACA,aACuB,EAAE,GAAK,CAC9B,IAAM,EAAU,GAAoB,CAEpC,MAAQ,IACF,EACK,EAAQ,eACb,EACA,CACE,aACA,cACA,sBACA,YACD,CACD,EACA,EACD,CAGI,EAAe,EAAS,CAC7B,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,EA6HO,GAA+C,CAC1D,WAAW,GACX,aACA,UACA,aACA,cACA,sBACA,YACA,oBACI,CACJ,IAAM,EAAU,GAAoB,CA8CpC,OA5CI,EAEA,EAAA,EAAA,CAAA,SACG,EAAe,EAAU,CACxB,aACA,UACA,aACA,cACA,sBACA,YACD,CAAC,CACD,CAAA,CAIH,EAEA,EAAA,EAAA,CAAA,SACG,EAAQ,eACP,EACA,CACE,aACA,cACA,sBACA,YACD,CACD,EACA,EACD,CACA,CAAA,CAeA,EAAA,EAAA,CAAA,SAAG,EAAS,EAV8B,CAC/C,aACA,aACA,cACA,UACA,aAAc,CAAC,CAAC,EAChB,sBACA,YACD,CAE4C,CAAI,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useMarkdownContext as e}from"./MarkdownProvider.mjs";import t from"@intlayer/config/built";import{Suspense as n,lazy as r}from"react";import{jsx as i}from"react/jsx-runtime";const a=t=>{let{children:n,options:r,components:i}=t,a=e();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})},o=r(()=>import(`./MarkdownMetadataRendererInternal.mjs`).then(e=>({default:e.MarkdownMetadataRendererInternal}))),s=e=>{let{editor:r}=t??{},a=r?.enabled??!1;return typeof window<`u`&&a?i(n,{fallback:null,children:i(o,{...e})}):null};export{s as MarkdownMetadataRenderer,a as MarkdownRendererPlugin};
|
|
1
|
+
"use client";import{useMarkdownContext as e}from"./MarkdownProvider.mjs";import t from"@intlayer/config/built";import{Suspense as n,lazy as r}from"react";import{jsx as i}from"react/jsx-runtime";const a=t=>{let{children:n,options:r,components:i}=t,a=e();return(a?.renderMarkdown??(e=>e))(n,r,{...a?.components??{},...i??{}})},o=r(()=>import(`./MarkdownMetadataRendererInternal.mjs`).then(e=>({default:e.MarkdownMetadataRendererInternal}))),s=e=>{let{editor:r}=t??{},a=r?.enabled??!1;return typeof window<`u`&&a?i(n,{fallback:null,children:i(o,{...e})}):null};export{s as MarkdownMetadataRenderer,a as MarkdownRendererPlugin};
|
|
2
2
|
//# sourceMappingURL=MarkdownRendererPlugin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport configuration from '@intlayer/config/built';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { type FC, lazy, type ReactNode, Suspense } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FC<MarkdownRendererPluginProps> = (\n props\n): ReactNode => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n const contentToRender = children;\n\n return renderMarkdown(contentToRender, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n });\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nconst DynamicMarkdownMetadataRendererInternal = lazy(() =>\n import('./MarkdownMetadataRendererInternal').then((module) => ({\n default: module.MarkdownMetadataRendererInternal,\n }))\n);\n\nexport const MarkdownMetadataRenderer: FC<MarkdownMetadataRendererProps> = (\n props\n): ReactNode => {\n const { editor } = configuration ?? {};\n const isEnabled = editor?.enabled ?? false;\n\n if (typeof window !== 'undefined' && isEnabled) {\n return (\n <Suspense fallback={null}>\n <DynamicMarkdownMetadataRendererInternal {...props} />\n </Suspense>\n );\n }\n\n return null;\n};\n"],"mappings":"kMAqBA,MAAa,EACX,GACc,CACd,GAAM,CAAE,WAAU,UAAS,cAAe,EACpC,EAAU,GAAoB,CAIpC,OAHuB,GAAS,iBAAoB,GAAO,IACnC,EAEe,EAAS,CAC9C,GAAI,GAAS,YAAc,EAAE,CAC7B,GAAI,GAAc,EAAE,CACrB,CAAC,EAOE,EAA0C,MAC9C,OAAO,0CAAsC,KAAM,IAAY,CAC7D,QAAS,EAAO,iCACjB,EAAE,CACJ,CAEY,EACX,GACc,CACd,GAAM,CAAE,UAAW,GAAiB,EAAE,CAChC,EAAY,GAAQ,SAAW,GAUrC,OARI,OAAO,OAAW,KAAe,EAEjC,EAAC,EAAD,CAAU,SAAU,cAClB,EAAC,EAAD,CAAyC,GAAI,EAAS,CAAA,CAC7C,CAAA,CAIR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ??\n currentLocale ??\n configuration?.internationalization?.defaultLocale\n );\n};\n"],"mappings":"yNAkCA,MAAa,EAAW,
|
|
1
|
+
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../../src/server/format/useIntl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from '../IntlayerServerProvider';\nimport { getServerContext } from '../serverContext';\n\n/**\n * React client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass 'en-US' as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n *\n * @example\n * ```tsx\n * const intl = useIntl();\n *\n * // You can still override the locale if needed\n * const date = new intl.DateTimeFormat({ locale: 'fr-FR' }).format(new Date());\n * // or\n * const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());\n * ```\n */\nexport const useIntl = (locale?: LocalesValues): WrappedIntl => {\n const currentLocale = getServerContext<LocalesValues>(IntlayerServerContext);\n\n return bindIntl(\n locale ??\n currentLocale ??\n configuration?.internationalization?.defaultLocale\n );\n};\n"],"mappings":"yNAkCA,MAAa,EAAW,GAAwC,CAC9D,IAAM,EAAgB,EAAgC,EAAsB,CAE5E,OAAO,EACL,GACE,GACA,GAAe,sBAAsB,cACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\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 = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":"iLAcA,MAAa,GAIX,EACA,EACA,IAOO,EAAoB,EAJzB,GACA,EAAgC,EAAsB,EACtD,EAEuD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\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 useDictionaryAsync = async <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n configuration?.internationalization.defaultLocale;\n\n const dictionary = await (dictionaryPromise as any)[localeTarget]?.();\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":"sNAgBA,MAAa,EAAqB,MAIhC,EACA,EACA,IACG,CACH,IAAM,EACJ,GACA,EAAgC,EAAsB,EACtD,GACA,GAAe,qBAAqB,cAItC,OAAO,EAFY,MAAO,EAA0B,MAAiB,CAE9B,EAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\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 useDictionaryDynamic = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: string,\n locale?: L,\n fallbackLocale?: DeclaredLocales\n) => {\n const localeTarget =\n locale ??\n getServerContext<LocalesValues>(IntlayerServerContext) ??\n fallbackLocale ??\n configuration?.internationalization.defaultLocale;\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n );\n\n return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":"4QAiBA,MAAa,GAIX,EACA,EACA,EACA,IACG,CACH,IAAM,EACJ,GACA,EAAgC,EAAsB,EACtD,GACA,GAAe,qBAAqB,cAOtC,OAAO,EALY,EACjB,GAAG,OAAO,EAAI,CAAC,GAAG,IACjB,EAA0B,MAAiB,CAC7C,CAEsC,EAAkB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { WrappedIntl } from "@intlayer/core/formatters";
|
|
2
3
|
|
|
3
4
|
//#region src/client/format/useIntl.d.ts
|
|
4
5
|
/**
|
|
@@ -29,64 +30,7 @@ import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
|
29
30
|
* const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
declare const useIntl: (locale?: LocalesValues) =>
|
|
33
|
-
Collator: {
|
|
34
|
-
new (locales?: LocalesValues, options?: Intl.CollatorOptions): Intl.Collator;
|
|
35
|
-
new (options?: Intl.CollatorOptions & {
|
|
36
|
-
locale?: LocalesValues;
|
|
37
|
-
}): Intl.Collator;
|
|
38
|
-
};
|
|
39
|
-
NumberFormat: {
|
|
40
|
-
new (locales?: LocalesValues, options?: Intl.NumberFormatOptions): Intl.NumberFormat;
|
|
41
|
-
new (options?: Intl.NumberFormatOptions & {
|
|
42
|
-
locale?: LocalesValues;
|
|
43
|
-
}): Intl.NumberFormat;
|
|
44
|
-
};
|
|
45
|
-
DateTimeFormat: {
|
|
46
|
-
new (locales?: LocalesValues, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
47
|
-
new (options?: Intl.DateTimeFormatOptions & {
|
|
48
|
-
locale?: LocalesValues;
|
|
49
|
-
}): Intl.DateTimeFormat;
|
|
50
|
-
};
|
|
51
|
-
getCanonicalLocales: typeof Intl.getCanonicalLocales;
|
|
52
|
-
readonly PluralRules: {
|
|
53
|
-
new (locales?: LocalesValues, options?: Intl.PluralRulesOptions): Intl.PluralRules;
|
|
54
|
-
new (options?: Intl.PluralRulesOptions & {
|
|
55
|
-
locale?: LocalesValues;
|
|
56
|
-
}): Intl.PluralRules;
|
|
57
|
-
};
|
|
58
|
-
readonly RelativeTimeFormat: {
|
|
59
|
-
new (locales?: LocalesValues, options?: Intl.RelativeTimeFormatOptions): Intl.RelativeTimeFormat;
|
|
60
|
-
new (options?: Intl.RelativeTimeFormatOptions & {
|
|
61
|
-
locale?: LocalesValues;
|
|
62
|
-
}): Intl.RelativeTimeFormat;
|
|
63
|
-
};
|
|
64
|
-
readonly Locale: {
|
|
65
|
-
new (locales?: LocalesValues, options?: Intl.LocaleOptions): Intl.Locale;
|
|
66
|
-
new (options?: Intl.LocaleOptions & {
|
|
67
|
-
locale?: LocalesValues;
|
|
68
|
-
}): Intl.Locale;
|
|
69
|
-
};
|
|
70
|
-
readonly DisplayNames: {
|
|
71
|
-
new (locales?: LocalesValues, options?: Intl.DisplayNamesOptions): Intl.DisplayNames;
|
|
72
|
-
new (options?: Intl.DisplayNamesOptions & {
|
|
73
|
-
locale?: LocalesValues;
|
|
74
|
-
}): Intl.DisplayNames;
|
|
75
|
-
};
|
|
76
|
-
readonly ListFormat: {
|
|
77
|
-
new (locales?: LocalesValues, options?: Intl.ListFormatOptions): Intl.ListFormat;
|
|
78
|
-
new (options?: Intl.ListFormatOptions & {
|
|
79
|
-
locale?: LocalesValues;
|
|
80
|
-
}): Intl.ListFormat;
|
|
81
|
-
};
|
|
82
|
-
supportedValuesOf: typeof Intl.supportedValuesOf;
|
|
83
|
-
readonly Segmenter: {
|
|
84
|
-
new (locales?: LocalesValues, options?: Intl.SegmenterOptions): Intl.Segmenter;
|
|
85
|
-
new (options?: Intl.SegmenterOptions & {
|
|
86
|
-
locale?: LocalesValues;
|
|
87
|
-
}): Intl.Segmenter;
|
|
88
|
-
};
|
|
89
|
-
};
|
|
33
|
+
declare const useIntl: (locale?: LocalesValues) => WrappedIntl;
|
|
90
34
|
//#endregion
|
|
91
35
|
export { useIntl };
|
|
92
36
|
//# sourceMappingURL=useIntl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../../src/client/format/useIntl.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../../src/client/format/useIntl.ts"],"mappings":";;;;;;AAmCA;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,OAAA,GAAW,MAAA,GAAS,aAAA,KAAa,WAAA"}
|
|
@@ -22,7 +22,11 @@ import * as intlayer from "intlayer";
|
|
|
22
22
|
* // "1, 2 und 3"
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
declare const useList: () => (values: (string | number)[], options?:
|
|
25
|
+
declare const useList: () => (values: (string | number)[], options?: {
|
|
26
|
+
localeMatcher?: "lookup" | "best fit";
|
|
27
|
+
type?: "conjunction" | "disjunction" | "unit";
|
|
28
|
+
style?: "long" | "short" | "narrow";
|
|
29
|
+
} & {
|
|
26
30
|
locale?: intlayer.LocalesValues;
|
|
27
31
|
}) => string;
|
|
28
32
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../../src/client/format/useList.ts"],"mappings":";;;;;;AA2BA;;;;;;;;;;;;;;;;;;cAAa,OAAA,SAAO,MAAA,uBAAA,OAAA,
|
|
1
|
+
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../../src/client/format/useList.ts"],"mappings":";;;;;;AA2BA;;;;;;;;;;;;;;;;;;cAAa,OAAA,SAAO,MAAA,uBAAA,OAAA;;;;;WAWnB,QAAA,CAAA,aAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/client/useDictionaryAsync.ts"],"mappings":";;;;;;AAkBA;;;cAAa,kBAAA,aACD,UAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,MAAA,GAAS,CAAA,KACR,OAAA,CAAQ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;AAmBA;cAAa,oBAAA,aACD,UAAA,YACA,cAAA,EAEV,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,aAAA,KAAa,2BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.d.ts","names":[],"sources":["../../../src/client/useI18n.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"useI18n.d.ts","names":[],"sources":["../../../src/client/useI18n.ts"],"mappings":";;;;;;;;AAgCA;;;;;;;;;;;;;;;cAAa,OAAA,aACD,cAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,SAAA,EAAW,CAAA,EACX,MAAA,GAAS,CAAA,gBAkBY,gBAAA,CAAiB,CAAA,GAAE,IAAA,EAChC,CAAA,KAEL,UAAA,CAAW,oBAAA,CAAqB,yBAAA,CAA0B,CAAA,IAAK,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;;;;;;AA+BA;;;;;;;;;;;;;;;cAAa,WAAA,aACD,cAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,CAAA,KAAC,2BAAA,CAAA,oBAAA,CAAA,oCAAA,CAAA,yBAAA,CAAA,CAAA,GAAA,yBAAA,EAAA,CAAA"}
|
|
@@ -11,7 +11,6 @@ declare const defaultHTMLComponents: {} & {
|
|
|
11
11
|
small?: FC<react.DetailedHTMLProps<react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
12
12
|
sub?: FC<react.DetailedHTMLProps<react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
13
13
|
sup?: FC<react.DetailedHTMLProps<react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
14
|
-
slot?: FC<react.DetailedHTMLProps<react.SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>>;
|
|
15
14
|
html?: FC<react.DetailedHTMLProps<react.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>>;
|
|
16
15
|
head?: FC<react.DetailedHTMLProps<react.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>>;
|
|
17
16
|
body?: FC<react.DetailedHTMLProps<react.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>>;
|
|
@@ -104,6 +103,7 @@ declare const defaultHTMLComponents: {} & {
|
|
|
104
103
|
bdo?: FC<react.DetailedHTMLProps<react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
105
104
|
data?: FC<react.DetailedHTMLProps<react.DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>>;
|
|
106
105
|
template?: FC<react.DetailedHTMLProps<react.HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>>;
|
|
106
|
+
slot?: FC<react.DetailedHTMLProps<react.SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>>;
|
|
107
107
|
} & {
|
|
108
108
|
[key: string]: FC<any>;
|
|
109
109
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"mappings":";;;;;;;;;AA6BA;;;;;;;;;;;;;;;;KAAY,mBAAA,GAAsB,uBAAA;EAwBO;;AA4BzC;;;;;;;;;;;EAtCE,UAAA,GAAa,cAAA;EA6Dd;;;;;;;;;EAnDC,OAAA,GAAU,EAAA,CAAG,cAAA,CAAe,WAAA;AAAA;;;;;;;;;AAkG9B;;;;;;;;;;;;;;;;;cAtEa,cAAA,GACX,OAAA;EACA,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAOG,mBAAA,KACF,GAAA,CAAI,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GP;;;;;;;;;;;;;;;;cAnDa,mBAAA;EAAuB,UAAA;EAAA,OAAA;EAAA,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAOjC,mBAAA,MAGO,OAAA,kDAAe,QAAA,CAAA,SAAA,IAAA,OAAA,sCAAA,KAAA,CAAA,WAAA,GAAA,KAAA,CAAA,YAAA,mBAAA,KAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,SAAA,KAAA,GAAA,CAAA,OAAA;;;;;;;;;AAmJzB;;;;;;;KA1GY,qBAAA,GAAwB,mBAAA;;;;;;;;;;;EAWlC,QAAA;;;;;;;;;;;;;;;;;;;;;EAqBA,cAAA,IACE,QAAA,UACA,OAAA;IACE,UAAA,GAAa,cAAA;IACb,OAAA,GAAU,EAAA;IACV,UAAA;IACA,WAAA;IACA,mBAAA;IACA,SAAA;EAAA,MAEC,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgEM,gBAAA,EAAkB,EAAA,CAAG,qBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRendererPlugin.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"MarkdownRendererPlugin.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"mappings":";;;;;;;KAYK,2BAAA;EACH,aAAA;EACA,OAAA,EAAS,OAAA;EACT,MAAA,GAAS,aAAA;EACT,QAAA;EACA,OAAA,GAAU,uBAAA;EACV,UAAA,GAAa,cAAA;AAAA;AAAA,cAGF,sBAAA,EAAwB,EAAA,CAAG,2BAAA;AAAA,KAcnC,6BAAA,GAAgC,2BAAA;EACnC,eAAA,EAAiB,OAAA;AAAA;AAAA,cASN,wBAAA,EAA0B,EAAA,CAAG,6BAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { WrappedIntl } from "@intlayer/core/formatters";
|
|
2
3
|
|
|
3
4
|
//#region src/server/format/useIntl.d.ts
|
|
4
5
|
/**
|
|
@@ -29,64 +30,7 @@ import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
|
29
30
|
* const date2 = new intl.DateTimeFormat('fr-FR').format(new Date());
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
declare const useIntl: (locale?: LocalesValues) =>
|
|
33
|
-
Collator: {
|
|
34
|
-
new (locales?: LocalesValues, options?: Intl.CollatorOptions): Intl.Collator;
|
|
35
|
-
new (options?: Intl.CollatorOptions & {
|
|
36
|
-
locale?: LocalesValues;
|
|
37
|
-
}): Intl.Collator;
|
|
38
|
-
};
|
|
39
|
-
NumberFormat: {
|
|
40
|
-
new (locales?: LocalesValues, options?: Intl.NumberFormatOptions): Intl.NumberFormat;
|
|
41
|
-
new (options?: Intl.NumberFormatOptions & {
|
|
42
|
-
locale?: LocalesValues;
|
|
43
|
-
}): Intl.NumberFormat;
|
|
44
|
-
};
|
|
45
|
-
DateTimeFormat: {
|
|
46
|
-
new (locales?: LocalesValues, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
47
|
-
new (options?: Intl.DateTimeFormatOptions & {
|
|
48
|
-
locale?: LocalesValues;
|
|
49
|
-
}): Intl.DateTimeFormat;
|
|
50
|
-
};
|
|
51
|
-
getCanonicalLocales: typeof Intl.getCanonicalLocales;
|
|
52
|
-
readonly PluralRules: {
|
|
53
|
-
new (locales?: LocalesValues, options?: Intl.PluralRulesOptions): Intl.PluralRules;
|
|
54
|
-
new (options?: Intl.PluralRulesOptions & {
|
|
55
|
-
locale?: LocalesValues;
|
|
56
|
-
}): Intl.PluralRules;
|
|
57
|
-
};
|
|
58
|
-
readonly RelativeTimeFormat: {
|
|
59
|
-
new (locales?: LocalesValues, options?: Intl.RelativeTimeFormatOptions): Intl.RelativeTimeFormat;
|
|
60
|
-
new (options?: Intl.RelativeTimeFormatOptions & {
|
|
61
|
-
locale?: LocalesValues;
|
|
62
|
-
}): Intl.RelativeTimeFormat;
|
|
63
|
-
};
|
|
64
|
-
readonly Locale: {
|
|
65
|
-
new (locales?: LocalesValues, options?: Intl.LocaleOptions): Intl.Locale;
|
|
66
|
-
new (options?: Intl.LocaleOptions & {
|
|
67
|
-
locale?: LocalesValues;
|
|
68
|
-
}): Intl.Locale;
|
|
69
|
-
};
|
|
70
|
-
readonly DisplayNames: {
|
|
71
|
-
new (locales?: LocalesValues, options?: Intl.DisplayNamesOptions): Intl.DisplayNames;
|
|
72
|
-
new (options?: Intl.DisplayNamesOptions & {
|
|
73
|
-
locale?: LocalesValues;
|
|
74
|
-
}): Intl.DisplayNames;
|
|
75
|
-
};
|
|
76
|
-
readonly ListFormat: {
|
|
77
|
-
new (locales?: LocalesValues, options?: Intl.ListFormatOptions): Intl.ListFormat;
|
|
78
|
-
new (options?: Intl.ListFormatOptions & {
|
|
79
|
-
locale?: LocalesValues;
|
|
80
|
-
}): Intl.ListFormat;
|
|
81
|
-
};
|
|
82
|
-
supportedValuesOf: typeof Intl.supportedValuesOf;
|
|
83
|
-
readonly Segmenter: {
|
|
84
|
-
new (locales?: LocalesValues, options?: Intl.SegmenterOptions): Intl.Segmenter;
|
|
85
|
-
new (options?: Intl.SegmenterOptions & {
|
|
86
|
-
locale?: LocalesValues;
|
|
87
|
-
}): Intl.Segmenter;
|
|
88
|
-
};
|
|
89
|
-
};
|
|
33
|
+
declare const useIntl: (locale?: LocalesValues) => WrappedIntl;
|
|
90
34
|
//#endregion
|
|
91
35
|
export { useIntl };
|
|
92
36
|
//# sourceMappingURL=useIntl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../../src/server/format/useIntl.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../../src/server/format/useIntl.ts"],"mappings":";;;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,OAAA,GAAW,MAAA,GAAS,aAAA,KAAgB,WAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/server/useDictionary.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/server/useDictionary.ts"],"mappings":";;;;;;;;;;AAcA;cAAa,aAAA,aACD,UAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,EACT,cAAA,GAAiB,eAAA,KAAe,2BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"mappings":";;;;;;;;;;AAgBA;cAAa,kBAAA,aACD,UAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,MAAA,GAAS,CAAA,EACT,cAAA,GAAiB,eAAA,KAAe,OAAA,CAAA,2BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;;AAiBA;cAAa,oBAAA,aACD,UAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,UACA,MAAA,GAAS,CAAA,EACT,cAAA,GAAiB,eAAA,KAAe,2BAAA,CAAA,oBAAA,CAAA,CAAA,aAAA,yBAAA,EAAA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intlayer",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -115,14 +115,14 @@
|
|
|
115
115
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
116
116
|
},
|
|
117
117
|
"dependencies": {
|
|
118
|
-
"@intlayer/api": "8.4.
|
|
119
|
-
"@intlayer/config": "8.4.
|
|
120
|
-
"@intlayer/core": "8.4.
|
|
121
|
-
"@intlayer/dictionaries-entry": "8.4.
|
|
122
|
-
"@intlayer/editor": "8.4.
|
|
123
|
-
"@intlayer/editor-react": "8.4.
|
|
124
|
-
"@intlayer/types": "8.4.
|
|
125
|
-
"intlayer": "8.4.
|
|
118
|
+
"@intlayer/api": "8.4.1",
|
|
119
|
+
"@intlayer/config": "8.4.1",
|
|
120
|
+
"@intlayer/core": "8.4.1",
|
|
121
|
+
"@intlayer/dictionaries-entry": "8.4.1",
|
|
122
|
+
"@intlayer/editor": "8.4.1",
|
|
123
|
+
"@intlayer/editor-react": "8.4.1",
|
|
124
|
+
"@intlayer/types": "8.4.1",
|
|
125
|
+
"intlayer": "8.4.1"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
128
|
"@craco/types": "7.1.0",
|