UNPKG

@progress/kendo-react-form

Version:

React Form is a small and fast package for form state management with zero dependencies. KendoReact Form package

46 lines (45 loc) 1.68 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import * as e from "react"; import { useUnstyled as R, classNames as b, uForm as F } from "@progress/kendo-react-common"; import { innerWidth as N, calculateColSpan as W, generateColSpanClass as h } from "./utils.mjs"; const E = (i) => { const { className: a, style: v, dir: c, colSpan: l, children: w } = i, o = e.useRef(null), C = R(), d = i.unstyled || C, u = d && d.uForm, [f, m] = e.useState(void 0), n = e.useRef(null); e.useEffect(() => { o.current && (n.current = o.current.closest("form")); }, []), e.useEffect(() => { let t; const s = n == null ? void 0 : n.current, p = () => { let r = 0; if (s ? r = N(s) : typeof window != "undefined" && (r = window.innerWidth), l !== void 0) { const S = W(l, r); m(h(S)); } else m(void 0); }; return p(), s && typeof window != "undefined" && "ResizeObserver" in window && (t = new ResizeObserver(p), t.observe(s)), () => { t && s && t.unobserve(s); }; }, [l]); const y = e.useMemo( () => b( F.field({ c: u, isRtl: c === "rtl" }), f, a ), [u, a, c, f] ); return /* @__PURE__ */ e.createElement("div", { ref: o, className: y, style: v }, w); }; E.displayName = "KendoReactFieldWrapper"; export { E as FieldWrapper };