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