UNPKG

react-intlayer

Version:

Easily internationalize i18n your React applications with type-safe multilingual content management.

60 lines (58 loc) 2.55 kB
import { IntlayerNode } from "./IntlayerNode.js"; import { DeepTransformContent as DeepTransformContent$1, IInterpreterPluginState as IInterpreterPluginState$1, Plugins } from "@intlayer/core"; import { ReactNode } from "react"; import { DeclaredLocales, LocalesValues, NodeType } from "@intlayer/types"; //#region src/plugins.d.ts /** --------------------------------------------- * INTLAYER NODE PLUGIN * --------------------------------------------- */ type IntlayerNodeCond<T> = T extends number | string ? IntlayerNode<T> : never; /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */ declare const intlayerNodePlugins: Plugins; /** --------------------------------------------- * REACT NODE PLUGIN * --------------------------------------------- */ type ReactNodeCond<T> = T extends { props: any; key: any; } ? ReactNode : never; /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */ declare const reactNodePlugins: Plugins; /** * MARKDOWN PLUGIN */ type MarkdownStringCond<T> = T extends string ? IntlayerNode<string, { metadata: DeepTransformContent<string>; }> : never; /** Markdown string plugin. Replaces string node with a component that render the markdown. */ declare const markdownStringPlugin: Plugins; type MarkdownCond<T> = T extends { nodeType: NodeType | string; [NodeType.Markdown]: infer M; metadata?: infer U; } ? IntlayerNode<DeepTransformContent<M>, { metadata: DeepTransformContent<U>; }> : never; declare const markdownPlugin: Plugins; /** --------------------------------------------- * PLUGINS RESULT * --------------------------------------------- */ interface IInterpreterPluginReact<T> { reactNode: ReactNodeCond<T>; intlayerNode: IntlayerNodeCond<T>; markdown: MarkdownCond<T>; } /** * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution. * * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions. */ type IInterpreterPluginState = IInterpreterPluginState$1 & { reactNode: true; intlayerNode: true; markdown: true; }; type DeepTransformContent<T, L extends LocalesValues = DeclaredLocales> = DeepTransformContent$1<T, IInterpreterPluginState, L>; //#endregion export { DeepTransformContent, IInterpreterPluginReact, IInterpreterPluginState, IntlayerNodeCond, MarkdownCond, MarkdownStringCond, ReactNodeCond, intlayerNodePlugins, markdownPlugin, markdownStringPlugin, reactNodePlugins }; //# sourceMappingURL=plugins.d.ts.map