@progress/kendo-react-form
Version:
React Form is a small and fast package for form state management with zero dependencies. KendoReact Form package
9 lines (8 loc) • 2.26 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2026 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("react"),a=require("@progress/kendo-react-common"),_=require("./FormContext.js"),o=require("./utils.js");function M(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const e=M(G),c={rows:"0px",cols:"32px"},N=e.forwardRef((t,s)=>{const r={size:void 0,...t},n=e.useRef(null),S=e.useRef(null);e.useImperativeHandle(S,()=>({element:n.current,props:r})),e.useImperativeHandle(s,()=>S.current);const u=e.useContext(_.FormContext),{className:F,style:j,horizontal:v,size:R,cols:l,gutters:i=c,...O}=r,p=a.useUnstyled(),g=p&&p.uForm,[h,w]=e.useState(void 0),[T,b]=e.useState(void 0),C=e.useMemo(()=>{if(v)return"horizontal";if(v===!1)return"vertical"},[v]),z=e.useMemo(()=>a.classNames(a.uForm.form({c:g,size:R,orientation:C}),F),[F,g,C,R]);return e.useEffect(()=>{if(!l&&!i){w(void 0);return}if(!i){b(void 0);return}const E=()=>{let f=0;if(n.current?f=o.innerWidth(n.current):typeof window!="undefined"&&(f=window.innerWidth),l){const y=o.calculateColumns(l,f);w(o.generateColumnClass(y))}if(i){const y=o.calculateGutters(i,f);b(y?{gap:o.generateGuttersStyling(y,c)}:{gap:o.generateGuttersStyling(c,c)})}};E();let m;const d=n.current;return d&&typeof window!="undefined"&&"ResizeObserver"in window&&(m=new ResizeObserver(E),m.observe(d)),()=>{m&&d&&m.unobserve(d)}},[l,i]),e.createElement("form",{ref:n,...O,id:t.id||(u?u.id:void 0),style:t.style,className:z,onSubmit:u?u.onSubmit:void 0},l?e.createElement("div",{className:a.classNames(a.uForm.formLayout({c:g}),h),style:T},t.children):t.children)});N.displayName="KendoReactFormElement";exports.DEFAULT_FORM_GUTTERS=c;exports.FormElement=N;