UNPKG

@progress/kendo-react-form

Version:

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

50 lines (49 loc) 1.47 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 v, classNames as F, uForm as N } from "@progress/kendo-react-common"; import { FormContext as R } from "./FormContext.mjs"; const h = e.forwardRef((t, f) => { const s = { size: "medium", ...t }, n = e.useRef(null), m = e.useRef(null); e.useImperativeHandle(m, () => ({ element: n.current, props: s })), e.useImperativeHandle(f, () => m.current); const o = e.useContext(R), { className: l, style: p, horizontal: r, size: a, ...d } = s, i = v(), c = i && i.uForm, u = e.useMemo(() => { if (r) return "horizontal"; if (r === !1) return "vertical"; }, [r]), y = e.useMemo( () => F( N.form({ c, size: a, orientation: u }), l ), [l, c, u, a] ); return /* @__PURE__ */ e.createElement( "form", { ref: n, ...d, id: t.id || (o ? o.id : void 0), style: t.style, className: y, onSubmit: o ? o.onSubmit : void 0 }, t.children ); }); h.displayName = "KendoReactFormElement"; export { h as FormElement };