UNPKG

@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) 1.65 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react"),d=require("@progress/kendo-react-common"),f=require("./utils.js");function F(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const t=F(R),S=e=>{const{className:n,style:s,dir:o,colSpan:i,children:w}=e,a=t.useRef(null),C=d.useUnstyled(),p=e.unstyled||C,m=p&&p.uForm,[b,y]=t.useState(void 0),l=t.useRef(null);t.useEffect(()=>{a.current&&(l.current=a.current.closest("form"))},[]),t.useEffect(()=>{let c;const r=l==null?void 0:l.current,v=()=>{let u=0;if(r?u=f.innerWidth(r):typeof window!="undefined"&&(u=window.innerWidth),i!==void 0){const O=f.calculateColSpan(i,u);y(f.generateColSpanClass(O))}else y(void 0)};return v(),r&&typeof window!="undefined"&&"ResizeObserver"in window&&(c=new ResizeObserver(v),c.observe(r)),()=>{c&&r&&c.unobserve(r)}},[i]);const g=t.useMemo(()=>d.classNames(d.uForm.field({c:m,isRtl:o==="rtl"}),b,n),[m,n,o,b]);return t.createElement("div",{ref:a,className:g,style:s},w)};S.displayName="KendoReactFieldWrapper";exports.FieldWrapper=S;