UNPKG

@react-form-builder/core

Version:

React JSON Schema Form Builder to create complex, validated, reusable forms with no deep React knowledge required

60 lines (59 loc) 2.71 kB
import { jsx as o } from "react/jsx-runtime"; import v from "clsx"; import { useContext as D, useMemo as E, useLayoutEffect as w, useEffect as P, Fragment as V } from "react"; import { useComponentData as F } from "../../utils/contexts/ComponentDataContext.js"; import { useStore as I } from "../../utils/contexts/StoreContext.js"; import { namedObserver as g } from "../../utils/namedObserver.js"; import { reactMajor as M } from "../../utils/reactVersion.js"; import { cfDisableWrapperStyles as j, cfDisableStyles as k } from "../define/utils/integratedComponentFeatures.js"; import { useViewerProps as R } from "../form-viewer/components/ViewerPropsContext.js"; import { getCellInfoPropertiesContext as T } from "../properties-context/getCellInfoPropertiesContext.js"; import { CellInfoContext as L } from "../table/CellInfoContext.js"; import { TooltipWrapper as O } from "../tooltip/TooltipWrapper.js"; import { Erroneous as h } from "../validation/components/Erroneous.js"; import { DefaultWrapper as U } from "./DefaultWrapper.js"; const q = () => { const t = F(), n = I(), { componentWrapper: C } = R(), i = D(L), e = E(() => { if (!i) return t.componentState; const b = T(t, i, n); return n.componentStateFactory(t, n, b); }, [t, n, i]), { flatCss: d, flatWrapperCss: y } = e; w(() => { e.applyStyles("css", d); }, [e, d]), w(() => { e.applyStyles("wrapperCss", y); }, [e, y]), P(() => (e.onDidMount(), () => { e.onWillUnmount(); }), [e]); const { key: s, ...r } = e.get, { kind: l, component: p } = t.model, c = !t.model.isFeatureEnabled(j), x = v(r.className, c && e.wrapperClassName), a = c ? e.wrapperStyle : void 0, f = C ?? U, S = t.store.tooltipProps ? O : V, N = C ?? p, u = !t.model.isFeatureEnabled(k) ? x : void 0, m = M >= 19 ? e.setRef : void 0; if (l === "container") return /* @__PURE__ */ o( N, { ref: m, ...r, className: u, ...a }, s ); if (l === "repeater") return /* @__PURE__ */ o(S, { children: /* @__PURE__ */ o(f, { children: /* @__PURE__ */ o(h, { children: /* @__PURE__ */ o( p, { ref: m, ...r, wrapperClassName: u, ...a }, s ) }) }) }); if (l === "template") return /* @__PURE__ */ o(f, { className: u, ...a, children: /* @__PURE__ */ o(p, { ref: m, ...r }, s) }); const W = c ? e.wrapperClassName : void 0; return /* @__PURE__ */ o(S, { children: /* @__PURE__ */ o(f, { className: W, ...a, children: /* @__PURE__ */ o(h, { children: /* @__PURE__ */ o(p, { ref: m, ...r }, s) }) }) }); }, te = g("ComponentViewer", q); export { te as ComponentViewer }; //# sourceMappingURL=ComponentViewer.js.map