UNPKG

react-intlayer

Version:

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

26 lines (24 loc) 1.09 kB
import { isValidElement } from "react"; import { Fragment as Fragment$1, jsx } from "react/jsx-runtime"; //#region src/IntlayerNode.tsx const renderIntlayerNode = ({ children, value, additionalProps }) => { const element = isValidElement(children) ? children : /* @__PURE__ */ jsx(Fragment$1, { children }); return new Proxy(element, { get(target, prop, receiver) { if (prop === "value") return value; if (prop === Symbol.toPrimitive) return () => value ?? ""; if (prop === "toString") return () => String(value ?? ""); if (prop === "valueOf") return () => value; if (additionalProps && prop in additionalProps) return additionalProps[prop]; if (value !== null && value !== void 0 && typeof prop === "string" && prop !== "constructor" && !(prop in target)) { const valObj = Object(value); if (prop in valObj) { const valProp = valObj[prop]; return typeof valProp === "function" ? valProp.bind(value) : valProp; } } return Reflect.get(target, prop, receiver); } }); }; //#endregion export { renderIntlayerNode }; //# sourceMappingURL=IntlayerNode.mjs.map