UNPKG

@progress/kendo-react-form

Version:

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

47 lines (46 loc) 1.76 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 y, uForm as b } from "@progress/kendo-react-common"; import { innerWidth as N, calculateColSpan as h, generateColSpanClass as E } from "./utils.mjs"; const F = e.forwardRef((n, S) => { const t = e.useRef(null), l = e.useRef(null); e.useImperativeHandle(l, () => ({ element: t.current, props: n })), e.useImperativeHandle(S, () => l.current); const { className: c, style: W, colSpan: o, ...v } = n, i = R(), u = i && i.uForm, [f, m] = e.useState(void 0), d = e.useRef(null); e.useEffect(() => { t.current && (d.current = t.current.closest("form")); }, []), e.useEffect(() => { let r; const s = d.current, p = () => { let a = 0; if (s ? a = N(s) : typeof window != "undefined" && (a = window.innerWidth), o !== void 0) { const C = h(o, a); m(E(C)); } else m(void 0); }; return p(), s && typeof window != "undefined" && "ResizeObserver" in window && (r = new ResizeObserver(p), r.observe(s)), () => { r && s && r.unobserve(s); }; }, [o]); const w = e.useMemo( () => y( b.separator({ c: u }), f, c ), [c, u, f] ); return /* @__PURE__ */ e.createElement("span", { ref: t, ...v, style: n.style, className: w }); }); F.displayName = "KendoReactFormSeparator"; export { F as FormSeparator };