UNPKG

react-intlayer

Version:

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

41 lines (39 loc) 1.41 kB
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); let react = require("react"); //#region src/reactElement/renderReactElement.ts const renderReactElement = (element) => { if (typeof element === "string") return element; const convertChildrenAsArray = (element$1) => { if (element$1?.props && typeof element$1.props.children === "object") { const childrenResult = []; const { children } = element$1.props; Object.keys(children ?? {}).forEach((key) => { const childElement = renderReactElement(children?.[key]); if (typeof childElement === "object" && childElement !== null && "type" in childElement) childrenResult.push((0, react.createElement)(childElement.type, { ...childElement.props, key }, ...Array.isArray(childElement.props?.children) ? childElement.props.children : [childElement.props?.children])); else childrenResult.push(childElement); }); return { ...element$1, props: { ...element$1.props, children: childrenResult } }; } return { ...element$1, props: { ...element$1.props, children: element$1.props?.children ?? [] } }; }; const { type, props } = convertChildrenAsArray(element); return (0, react.createElement)(type ?? "span", props, ...props.children); }; //#endregion exports.renderReactElement = renderReactElement; //# sourceMappingURL=renderReactElement.cjs.map