UNPKG

react-intlayer

Version:

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

54 lines 2.3 kB
import { NodeType, type DeepTransformContent as DeepTransformContentCore, type IInterpreterPluginState as IInterpreterPluginStateCore, type Plugins } from '@intlayer/core'; import type { ReactNode } from 'react'; import { type IntlayerNode } from './IntlayerNode'; /** --------------------------------------------- * INTLAYER NODE PLUGIN * --------------------------------------------- */ export type IntlayerNodeCond<T> = T extends number | string ? IntlayerNode<T> : never; /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */ export declare const intlayerNodePlugins: Plugins; /** --------------------------------------------- * REACT NODE PLUGIN * --------------------------------------------- */ export type ReactNodeCond<T> = T extends { props: any; key: any; } ? ReactNode : never; /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */ export declare const reactNodePlugins: Plugins; /** * MARKDOWN PLUGIN */ export 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. */ export declare const markdownStringPlugin: Plugins; export type MarkdownCond<T> = T extends { nodeType: NodeType | string; [NodeType.Markdown]: infer M; metadata?: infer U; } ? IntlayerNode<DeepTransformContent<M>, { metadata: DeepTransformContent<U>; }> : never; export declare const markdownPlugin: Plugins; /** --------------------------------------------- * PLUGINS RESULT * --------------------------------------------- */ export 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. */ export type IInterpreterPluginState = IInterpreterPluginStateCore & { reactNode: true; intlayerNode: true; markdown: true; }; export type DeepTransformContent<T> = DeepTransformContentCore<T, IInterpreterPluginState>; //# sourceMappingURL=plugins.d.ts.map