ynotsoft-dynamic-form 1.0.87 → 1.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dynamic-form.js
CHANGED
|
@@ -4064,7 +4064,7 @@ function $f({ field: e, formValues: t, handleChange: n, handleBlur: r, error: o,
|
|
|
4064
4064
|
value: E[e.valueId || "key"] || E.key,
|
|
4065
4065
|
label: E[e.labelId || "value"] || E.value
|
|
4066
4066
|
}));
|
|
4067
|
-
l(C);
|
|
4067
|
+
l(C), n(`${e.name}_count`, C.length);
|
|
4068
4068
|
} catch (p) {
|
|
4069
4069
|
console.error("Failed to load options for SelectField:", p), l(e.options || []);
|
|
4070
4070
|
} finally {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
`)},xa=function(){var e=parseInt(document.body.getAttribute(yt)||"0",10);return isFinite(e)?e:0},tu=function(){f.useEffect(function(){return document.body.setAttribute(yt,(xa()+1).toString()),function(){var e=xa()-1;e<=0?document.body.removeAttribute(yt):document.body.setAttribute(yt,e.toString())}},[])},nu=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;tu();var a=f.useMemo(function(){return Zd(o)},[o]);return f.createElement(Jd,{styles:eu(a,!t,o,n?"":"!important")})},Er=!1;if(typeof window<"u")try{var vn=Object.defineProperty({},"passive",{get:function(){return Er=!0,!0}});window.addEventListener("test",vn,vn),window.removeEventListener("test",vn,vn)}catch{Er=!1}var wt=Er?{passive:!1}:!1,ru=function(e){return e.tagName==="TEXTAREA"},Sa=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!ru(e)&&n[t]==="visible")},ou=function(e){return Sa(e,"overflowY")},au=function(e){return Sa(e,"overflowX")},Ca=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ea(e,r);if(o){var a=ka(e,r),s=a[1],i=a[2];if(s>i)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},su=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},iu=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ea=function(e,t){return e==="v"?ou(t):au(t)},ka=function(e,t){return e==="v"?su(t):iu(t)},cu=function(e,t){return e==="h"&&t==="rtl"?-1:1},lu=function(e,t,n,r,o){var a=cu(e,window.getComputedStyle(t).direction),s=a*r,i=n.target,l=t.contains(i),d=!1,u=s>0,p=0,g=0;do{if(!i)break;var m=ka(e,i),w=m[0],h=m[1],v=m[2],k=h-v-a*w;(w||k)&&Ea(e,i)&&(p+=k,g+=w);var C=i.parentNode;i=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!l&&i!==document.body||l&&(t.contains(i)||t===i));return(u&&Math.abs(p)<1||!u&&Math.abs(g)<1)&&(d=!0),d},yn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Na=function(e){return[e.deltaX,e.deltaY]},Aa=function(e){return e&&"current"in e?e.current:e},du=function(e,t){return e[0]===t[0]&&e[1]===t[1]},uu=function(e){return`
|
|
58
58
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
59
59
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
60
|
-
`)},fu=0,xt=[];function pu(e){var t=f.useRef([]),n=f.useRef([0,0]),r=f.useRef(),o=f.useState(fu++)[0],a=f.useState(wa)[0],s=f.useRef(e);f.useEffect(function(){s.current=e},[e]),f.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=Dd([e.lockRef.current],(e.shards||[]).map(Aa),!0).filter(Boolean);return h.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var i=f.useCallback(function(h,v){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!s.current.allowPinchZoom;var k=yn(h),C=n.current,E="deltaX"in h?h.deltaX:C[0]-k[0],y="deltaY"in h?h.deltaY:C[1]-k[1],T,D=h.target,M=Math.abs(E)>Math.abs(y)?"h":"v";if("touches"in h&&M==="h"&&D.type==="range")return!1;var P=Ca(M,D);if(!P)return!0;if(P?T=M:(T=M==="v"?"h":"v",P=Ca(M,D)),!P)return!1;if(!r.current&&"changedTouches"in h&&(E||y)&&(r.current=T),!T)return!0;var W=r.current||T;return lu(W,v,h,W==="h"?E:y)},[]),l=f.useCallback(function(h){var v=h;if(!(!xt.length||xt[xt.length-1]!==a)){var k="deltaY"in v?Na(v):yn(v),C=t.current.filter(function(T){return T.name===v.type&&(T.target===v.target||v.target===T.shadowParent)&&du(T.delta,k)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var E=(s.current.shards||[]).map(Aa).filter(Boolean).filter(function(T){return T.contains(v.target)}),y=E.length>0?i(v,E[0]):!s.current.noIsolation;y&&v.cancelable&&v.preventDefault()}}},[]),d=f.useCallback(function(h,v,k,C){var E={name:h,delta:v,target:k,should:C,shadowParent:mu(k)};t.current.push(E),setTimeout(function(){t.current=t.current.filter(function(y){return y!==E})},1)},[]),u=f.useCallback(function(h){n.current=yn(h),r.current=void 0},[]),p=f.useCallback(function(h){d(h.type,Na(h),h.target,i(h,e.lockRef.current))},[]),g=f.useCallback(function(h){d(h.type,yn(h),h.target,i(h,e.lockRef.current))},[]);f.useEffect(function(){return xt.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:g}),document.addEventListener("wheel",l,wt),document.addEventListener("touchmove",l,wt),document.addEventListener("touchstart",u,wt),function(){xt=xt.filter(function(h){return h!==a}),document.removeEventListener("wheel",l,wt),document.removeEventListener("touchmove",l,wt),document.removeEventListener("touchstart",u,wt)}},[]);var m=e.removeScrollBar,w=e.inert;return f.createElement(f.Fragment,null,w?f.createElement(a,{styles:uu(o)}):null,m?f.createElement(nu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function mu(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const hu=Ud(ya,pu);var kr=f.forwardRef(function(e,t){return f.createElement(bn,We({},e,{ref:t,sideCar:hu}))});kr.classNames=bn.classNames;var gu=[" ","Enter","ArrowUp","ArrowDown"],bu=[" ","Enter"],it="Select",[wn,xn,vu]=go(it),[St]=at(it,[vu,fn]),Sn=fn(),[yu,Je]=St(it),[wu,xu]=St(it),Ta=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:a,value:s,defaultValue:i,onValueChange:l,dir:d,name:u,autoComplete:p,disabled:g,required:m,form:w}=e,h=Sn(t),[v,k]=f.useState(null),[C,E]=f.useState(null),[y,T]=f.useState(!1),D=Zn(d),[M,P]=$t({prop:r,defaultProp:o??!1,onChange:a,caller:it}),[W,V]=$t({prop:s,defaultProp:i,onChange:l,caller:it}),H=f.useRef(null),G=v?w||!!v.closest("form"):!0,[x,A]=f.useState(new Set),_=Array.from(x).map(O=>O.props.value).join(";");return c.jsx(la,{...h,children:c.jsxs(yu,{required:m,scope:t,trigger:v,onTriggerChange:k,valueNode:C,onValueNodeChange:E,valueNodeHasChildren:y,onValueNodeHasChildrenChange:T,contentId:It(),value:W,onValueChange:V,open:M,onOpenChange:P,dir:D,triggerPointerDownPosRef:H,disabled:g,children:[c.jsx(wn.Provider,{scope:t,children:c.jsx(wu,{scope:e.__scopeSelect,onNativeOptionAdd:f.useCallback(O=>{A(N=>new Set(N).add(O))},[]),onNativeOptionRemove:f.useCallback(O=>{A(N=>{const S=new Set(N);return S.delete(O),S})},[]),children:n})}),G?c.jsxs(Za,{"aria-hidden":!0,required:m,tabIndex:-1,name:u,autoComplete:p,value:W,onChange:O=>V(O.target.value),disabled:g,form:w,children:[W===void 0?c.jsx("option",{value:""}):null,Array.from(x)]},_):null]})})};Ta.displayName=it;var Pa="SelectTrigger",_a=f.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,a=Sn(n),s=Je(Pa,n),i=s.disabled||r,l=se(t,s.onTriggerChange),d=xn(n),u=f.useRef("touch"),[p,g,m]=es(h=>{const v=d().filter(E=>!E.disabled),k=v.find(E=>E.value===s.value),C=ts(v,h,k);C!==void 0&&s.onValueChange(C.value)}),w=h=>{i||(s.onOpenChange(!0),m()),h&&(s.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return c.jsx(vr,{asChild:!0,...a,children:c.jsx(Ne.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:i,"data-disabled":i?"":void 0,"data-placeholder":Ja(s.value)?"":void 0,...o,ref:l,onClick:Q(o.onClick,h=>{h.currentTarget.focus(),u.current!=="mouse"&&w(h)}),onPointerDown:Q(o.onPointerDown,h=>{u.current=h.pointerType;const v=h.target;v.hasPointerCapture(h.pointerId)&&v.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(w(h),h.preventDefault())}),onKeyDown:Q(o.onKeyDown,h=>{const v=p.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&g(h.key),!(v&&h.key===" ")&&gu.includes(h.key)&&(w(),h.preventDefault())})})})});_a.displayName=Pa;var Oa="SelectValue",Ma=f.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:a,placeholder:s="",...i}=e,l=Je(Oa,n),{onValueNodeHasChildrenChange:d}=l,u=a!==void 0,p=se(t,l.onValueNodeChange);return he(()=>{d(u)},[d,u]),c.jsx(Ne.span,{...i,ref:p,style:{pointerEvents:"none"},children:Ja(l.value)?c.jsx(c.Fragment,{children:s}):a})});Ma.displayName=Oa;var Su="SelectIcon",Ia=f.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ne.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Ia.displayName=Su;var Cu="SelectPortal",Da=e=>c.jsx(yr,{asChild:!0,...e});Da.displayName=Cu;var ct="SelectContent",La=f.forwardRef((e,t)=>{const n=Je(ct,e.__scopeSelect),[r,o]=f.useState();if(he(()=>{o(new DocumentFragment)},[]),!n.open){const a=r;return a?Jt.createPortal(c.jsx(Fa,{scope:e.__scopeSelect,children:c.jsx(wn.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),a):null}return c.jsx($a,{...e,ref:t})});La.displayName=ct;var Oe=10,[Fa,et]=St(ct),Eu="SelectContentImpl",ku=Se("SelectContent.RemoveScroll"),$a=f.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:s,side:i,sideOffset:l,align:d,alignOffset:u,arrowPadding:p,collisionBoundary:g,collisionPadding:m,sticky:w,hideWhenDetached:h,avoidCollisions:v,...k}=e,C=Je(ct,n),[E,y]=f.useState(null),[T,D]=f.useState(null),M=se(t,L=>y(L)),[P,W]=f.useState(null),[V,H]=f.useState(null),G=xn(n),[x,A]=f.useState(!1),_=f.useRef(!1);f.useEffect(()=>{if(E)return ha(E)},[E]),So();const O=f.useCallback(L=>{const[te,...ce]=G().map(oe=>oe.ref.current),[Z]=ce.slice(-1),ne=document.activeElement;for(const oe of L)if(oe===ne||(oe?.scrollIntoView({block:"nearest"}),oe===te&&T&&(T.scrollTop=0),oe===Z&&T&&(T.scrollTop=T.scrollHeight),oe?.focus(),document.activeElement!==ne))return},[G,T]),N=f.useCallback(()=>O([P,E]),[O,P,E]);f.useEffect(()=>{x&&N()},[x,N]);const{onOpenChange:S,triggerPointerDownPosRef:R}=C;f.useEffect(()=>{if(E){let L={x:0,y:0};const te=Z=>{L={x:Math.abs(Math.round(Z.pageX)-(R.current?.x??0)),y:Math.abs(Math.round(Z.pageY)-(R.current?.y??0))}},ce=Z=>{L.x<=10&&L.y<=10?Z.preventDefault():E.contains(Z.target)||S(!1),document.removeEventListener("pointermove",te),R.current=null};return R.current!==null&&(document.addEventListener("pointermove",te),document.addEventListener("pointerup",ce,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",te),document.removeEventListener("pointerup",ce,{capture:!0})}}},[E,S,R]),f.useEffect(()=>{const L=()=>S(!1);return window.addEventListener("blur",L),window.addEventListener("resize",L),()=>{window.removeEventListener("blur",L),window.removeEventListener("resize",L)}},[S]);const[Y,j]=es(L=>{const te=G().filter(ne=>!ne.disabled),ce=te.find(ne=>ne.ref.current===document.activeElement),Z=ts(te,L,ce);Z&&setTimeout(()=>Z.ref.current.focus())}),xe=f.useCallback((L,te,ce)=>{const Z=!_.current&&!ce;(C.value!==void 0&&C.value===te||Z)&&(W(L),Z&&(_.current=!0))},[C.value]),q=f.useCallback(()=>E?.focus(),[E]),ee=f.useCallback((L,te,ce)=>{const Z=!_.current&&!ce;(C.value!==void 0&&C.value===te||Z)&&H(L)},[C.value]),J=r==="popper"?Nr:Ra,ge=J===Nr?{side:i,sideOffset:l,align:d,alignOffset:u,arrowPadding:p,collisionBoundary:g,collisionPadding:m,sticky:w,hideWhenDetached:h,avoidCollisions:v}:{};return c.jsx(Fa,{scope:n,content:E,viewport:T,onViewportChange:D,itemRefCallback:xe,selectedItem:P,onItemLeave:q,itemTextRefCallback:ee,focusSelectedItem:N,selectedItemText:V,position:r,isPositioned:x,searchRef:Y,children:c.jsx(kr,{as:ku,allowPinchZoom:!0,children:c.jsx(or,{asChild:!0,trapped:C.open,onMountAutoFocus:L=>{L.preventDefault()},onUnmountAutoFocus:Q(o,L=>{C.trigger?.focus({preventScroll:!0}),L.preventDefault()}),children:c.jsx(er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:L=>L.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:c.jsx(J,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:L=>L.preventDefault(),...k,...ge,onPlaced:()=>A(!0),ref:M,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Q(k.onKeyDown,L=>{const te=L.ctrlKey||L.altKey||L.metaKey;if(L.key==="Tab"&&L.preventDefault(),!te&&L.key.length===1&&j(L.key),["ArrowUp","ArrowDown","Home","End"].includes(L.key)){let Z=G().filter(ne=>!ne.disabled).map(ne=>ne.ref.current);if(["ArrowUp","End"].includes(L.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(L.key)){const ne=L.target,oe=Z.indexOf(ne);Z=Z.slice(oe+1)}setTimeout(()=>O(Z)),L.preventDefault()}})})})})})})});$a.displayName=Eu;var Nu="SelectItemAlignedPosition",Ra=f.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,a=Je(ct,n),s=et(ct,n),[i,l]=f.useState(null),[d,u]=f.useState(null),p=se(t,M=>u(M)),g=xn(n),m=f.useRef(!1),w=f.useRef(!0),{viewport:h,selectedItem:v,selectedItemText:k,focusSelectedItem:C}=s,E=f.useCallback(()=>{if(a.trigger&&a.valueNode&&i&&d&&h&&v&&k){const M=a.trigger.getBoundingClientRect(),P=d.getBoundingClientRect(),W=a.valueNode.getBoundingClientRect(),V=k.getBoundingClientRect();if(a.dir!=="rtl"){const ne=V.left-P.left,oe=W.left-ne,fe=M.left-oe,Te=M.width+fe,De=Math.max(Te,P.width),ut=window.innerWidth-Oe,ft=mo(oe,[Oe,Math.max(Oe,ut-De)]);i.style.minWidth=Te+"px",i.style.left=ft+"px"}else{const ne=P.right-V.right,oe=window.innerWidth-W.right-ne,fe=window.innerWidth-M.right-oe,Te=M.width+fe,De=Math.max(Te,P.width),ut=window.innerWidth-Oe,ft=mo(oe,[Oe,Math.max(Oe,ut-De)]);i.style.minWidth=Te+"px",i.style.right=ft+"px"}const H=g(),G=window.innerHeight-Oe*2,x=h.scrollHeight,A=window.getComputedStyle(d),_=parseInt(A.borderTopWidth,10),O=parseInt(A.paddingTop,10),N=parseInt(A.borderBottomWidth,10),S=parseInt(A.paddingBottom,10),R=_+O+x+S+N,Y=Math.min(v.offsetHeight*5,R),j=window.getComputedStyle(h),xe=parseInt(j.paddingTop,10),q=parseInt(j.paddingBottom,10),ee=M.top+M.height/2-Oe,J=G-ee,ge=v.offsetHeight/2,L=v.offsetTop+ge,te=_+O+L,ce=R-te;if(te<=ee){const ne=H.length>0&&v===H[H.length-1].ref.current;i.style.bottom="0px";const oe=d.clientHeight-h.offsetTop-h.offsetHeight,fe=Math.max(J,ge+(ne?q:0)+oe+N),Te=te+fe;i.style.height=Te+"px"}else{const ne=H.length>0&&v===H[0].ref.current;i.style.top="0px";const fe=Math.max(ee,_+h.offsetTop+(ne?xe:0)+ge)+ce;i.style.height=fe+"px",h.scrollTop=te-ee+h.offsetTop}i.style.margin=`${Oe}px 0`,i.style.minHeight=Y+"px",i.style.maxHeight=G+"px",r?.(),requestAnimationFrame(()=>m.current=!0)}},[g,a.trigger,a.valueNode,i,d,h,v,k,a.dir,r]);he(()=>E(),[E]);const[y,T]=f.useState();he(()=>{d&&T(window.getComputedStyle(d).zIndex)},[d]);const D=f.useCallback(M=>{M&&w.current===!0&&(E(),C?.(),w.current=!1)},[E,C]);return c.jsx(Tu,{scope:n,contentWrapper:i,shouldExpandOnScrollRef:m,onScrollButtonChange:D,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:y},children:c.jsx(Ne.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ra.displayName=Nu;var Au="SelectPopperPosition",Nr=f.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Oe,...a}=e,s=Sn(n);return c.jsx(da,{...s,...a,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Nr.displayName=Au;var[Tu,Ar]=St(ct,{}),Tr="SelectViewport",Wa=f.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,a=et(Tr,n),s=Ar(Tr,n),i=se(t,a.onViewportChange),l=f.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(wn.Slot,{scope:n,children:c.jsx(Ne.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Q(o.onScroll,d=>{const u=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:g}=s;if(g?.current&&p){const m=Math.abs(l.current-u.scrollTop);if(m>0){const w=window.innerHeight-Oe*2,h=parseFloat(p.style.minHeight),v=parseFloat(p.style.height),k=Math.max(h,v);if(k<w){const C=k+m,E=Math.min(w,C),y=C-E;p.style.height=E+"px",p.style.bottom==="0px"&&(u.scrollTop=y>0?y:0,p.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});Wa.displayName=Tr;var za="SelectGroup",[Pu,_u]=St(za),Ba=f.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=It();return c.jsx(Pu,{scope:n,id:o,children:c.jsx(Ne.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Ba.displayName=za;var Ha="SelectLabel",Ua=f.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_u(Ha,n);return c.jsx(Ne.div,{id:o.id,...r,ref:t})});Ua.displayName=Ha;var Cn="SelectItem",[Ou,ja]=St(Cn),Va=f.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...s}=e,i=Je(Cn,n),l=et(Cn,n),d=i.value===r,[u,p]=f.useState(a??""),[g,m]=f.useState(!1),w=se(t,C=>l.itemRefCallback?.(C,r,o)),h=It(),v=f.useRef("touch"),k=()=>{o||(i.onValueChange(r),i.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(Ou,{scope:n,value:r,disabled:o,textId:h,isSelected:d,onItemTextChange:f.useCallback(C=>{p(E=>E||(C?.textContent??"").trim())},[]),children:c.jsx(wn.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:c.jsx(Ne.div,{role:"option","aria-labelledby":h,"data-highlighted":g?"":void 0,"aria-selected":d&&g,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...s,ref:w,onFocus:Q(s.onFocus,()=>m(!0)),onBlur:Q(s.onBlur,()=>m(!1)),onClick:Q(s.onClick,()=>{v.current!=="mouse"&&k()}),onPointerUp:Q(s.onPointerUp,()=>{v.current==="mouse"&&k()}),onPointerDown:Q(s.onPointerDown,C=>{v.current=C.pointerType}),onPointerMove:Q(s.onPointerMove,C=>{v.current=C.pointerType,o?l.onItemLeave?.():v.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Q(s.onPointerLeave,C=>{C.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:Q(s.onKeyDown,C=>{l.searchRef?.current!==""&&C.key===" "||(bu.includes(C.key)&&k(),C.key===" "&&C.preventDefault())})})})})});Va.displayName=Cn;var Rt="SelectItemText",Ga=f.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...a}=e,s=Je(Rt,n),i=et(Rt,n),l=ja(Rt,n),d=xu(Rt,n),[u,p]=f.useState(null),g=se(t,k=>p(k),l.onItemTextChange,k=>i.itemTextRefCallback?.(k,l.value,l.disabled)),m=u?.textContent,w=f.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:m},l.value),[l.disabled,l.value,m]),{onNativeOptionAdd:h,onNativeOptionRemove:v}=d;return he(()=>(h(w),()=>v(w)),[h,v,w]),c.jsxs(c.Fragment,{children:[c.jsx(Ne.span,{id:l.textId,...a,ref:g}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Jt.createPortal(a.children,s.valueNode):null]})});Ga.displayName=Rt;var Ya="SelectItemIndicator",Mu=f.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return ja(Ya,n).isSelected?c.jsx(Ne.span,{"aria-hidden":!0,...r,ref:t}):null});Mu.displayName=Ya;var Pr="SelectScrollUpButton",qa=f.forwardRef((e,t)=>{const n=et(Pr,e.__scopeSelect),r=Ar(Pr,e.__scopeSelect),[o,a]=f.useState(!1),s=se(t,r.onScrollButtonChange);return he(()=>{if(n.viewport&&n.isPositioned){let i=function(){const d=l.scrollTop>0;a(d)};const l=n.viewport;return i(),l.addEventListener("scroll",i),()=>l.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),o?c.jsx(Ka,{...e,ref:s,onAutoScroll:()=>{const{viewport:i,selectedItem:l}=n;i&&l&&(i.scrollTop=i.scrollTop-l.offsetHeight)}}):null});qa.displayName=Pr;var _r="SelectScrollDownButton",Iu=f.forwardRef((e,t)=>{const n=et(_r,e.__scopeSelect),r=Ar(_r,e.__scopeSelect),[o,a]=f.useState(!1),s=se(t,r.onScrollButtonChange);return he(()=>{if(n.viewport&&n.isPositioned){let i=function(){const d=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<d;a(u)};const l=n.viewport;return i(),l.addEventListener("scroll",i),()=>l.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),o?c.jsx(Ka,{...e,ref:s,onAutoScroll:()=>{const{viewport:i,selectedItem:l}=n;i&&l&&(i.scrollTop=i.scrollTop+l.offsetHeight)}}):null});Iu.displayName=_r;var Ka=f.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,a=et("SelectScrollButton",n),s=f.useRef(null),i=xn(n),l=f.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return f.useEffect(()=>()=>l(),[l]),he(()=>{i().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[i]),c.jsx(Ne.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Q(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Q(o.onPointerMove,()=>{a.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Q(o.onPointerLeave,()=>{l()})})}),Du="SelectSeparator",Xa=f.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ne.div,{"aria-hidden":!0,...r,ref:t})});Xa.displayName=Du;var Or="SelectArrow",Qa=f.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Sn(n),a=Je(Or,n),s=et(Or,n);return a.open&&s.position==="popper"?c.jsx(ua,{...o,...r,ref:t}):null});Qa.displayName=Or;var Lu="SelectBubbleInput",Za=f.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=f.useRef(null),a=se(r,o),s=fa(t);return f.useEffect(()=>{const i=o.current;if(!i)return;const l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==t&&u){const p=new Event("change",{bubbles:!0});u.call(i,t),i.dispatchEvent(p)}},[s,t]),c.jsx(Ne.select,{...n,style:{...pa,...n.style},ref:a,defaultValue:t})});Za.displayName=Lu;function Ja(e){return e===""||e===void 0}function es(e){const t=Ke(e),n=f.useRef(""),r=f.useRef(0),o=f.useCallback(s=>{const i=n.current+s;t(i),(function l(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>l(""),1e3))})(i)},[t]),a=f.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return f.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,a]}function ts(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let s=Fu(e,Math.max(a,0));o.length===1&&(s=s.filter(d=>d!==n));const l=s.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Fu(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $u=Ta,Ru=_a,Wu=Ma,zu=Ia,Bu=Da,Hu=La,Uu=Wa,ju=Ba,Vu=Ua,Gu=Va,Yu=Ga,qu=qa,Ku=Xa,ns=Qa;function Xu({field:e,formValues:t,handleChange:n,handleBlur:r,error:o,apiClient:a}){const s=t[e.name]||"",i=typeof e.disabled=="function"?e.disabled(t):e.disabled,[l,d]=B.useState(e.options||[]),[u,p]=B.useState(!1);return B.useEffect(()=>{(async()=>{if(!e.optionsUrl||!a){e.options&&d(e.options);return}p(!0);try{let m=e.optionsUrl,w={};if(e.queryParams){const E=typeof e.queryParams=="function"?e.queryParams(t):e.queryParams;typeof E=="string"?m+=E.startsWith("?")?E:`?${E}`:w={params:E}}const h=await a(m,w),v=h.data||h,C=(Array.isArray(v)?v:[]).map(E=>({value:E[e.valueId||"key"]||E.key,label:E[e.labelId||"value"]||E.value}));d(C)}catch(m){console.error("Failed to load options for SelectField:",m),d(e.options||[])}finally{p(!1)}})()},[e.optionsUrl,e.options,a,e.valueId,e.labelId,JSON.stringify(typeof e.queryParams=="function"?e.queryParams(t):e.queryParams)]),c.jsxs(c.Fragment,{children:[c.jsxs($u,{value:s,onValueChange:g=>n(e.name,g),disabled:i,children:[c.jsxs(Ru,{id:e.name,onBlur:()=>r(e.name),className:`inline-flex items-center justify-between w-full h-10 rounded-md border px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 bg-background transition-all
|
|
60
|
+
`)},fu=0,xt=[];function pu(e){var t=f.useRef([]),n=f.useRef([0,0]),r=f.useRef(),o=f.useState(fu++)[0],a=f.useState(wa)[0],s=f.useRef(e);f.useEffect(function(){s.current=e},[e]),f.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=Dd([e.lockRef.current],(e.shards||[]).map(Aa),!0).filter(Boolean);return h.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var i=f.useCallback(function(h,v){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!s.current.allowPinchZoom;var k=yn(h),C=n.current,E="deltaX"in h?h.deltaX:C[0]-k[0],y="deltaY"in h?h.deltaY:C[1]-k[1],T,D=h.target,M=Math.abs(E)>Math.abs(y)?"h":"v";if("touches"in h&&M==="h"&&D.type==="range")return!1;var P=Ca(M,D);if(!P)return!0;if(P?T=M:(T=M==="v"?"h":"v",P=Ca(M,D)),!P)return!1;if(!r.current&&"changedTouches"in h&&(E||y)&&(r.current=T),!T)return!0;var W=r.current||T;return lu(W,v,h,W==="h"?E:y)},[]),l=f.useCallback(function(h){var v=h;if(!(!xt.length||xt[xt.length-1]!==a)){var k="deltaY"in v?Na(v):yn(v),C=t.current.filter(function(T){return T.name===v.type&&(T.target===v.target||v.target===T.shadowParent)&&du(T.delta,k)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var E=(s.current.shards||[]).map(Aa).filter(Boolean).filter(function(T){return T.contains(v.target)}),y=E.length>0?i(v,E[0]):!s.current.noIsolation;y&&v.cancelable&&v.preventDefault()}}},[]),d=f.useCallback(function(h,v,k,C){var E={name:h,delta:v,target:k,should:C,shadowParent:mu(k)};t.current.push(E),setTimeout(function(){t.current=t.current.filter(function(y){return y!==E})},1)},[]),u=f.useCallback(function(h){n.current=yn(h),r.current=void 0},[]),p=f.useCallback(function(h){d(h.type,Na(h),h.target,i(h,e.lockRef.current))},[]),g=f.useCallback(function(h){d(h.type,yn(h),h.target,i(h,e.lockRef.current))},[]);f.useEffect(function(){return xt.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:g}),document.addEventListener("wheel",l,wt),document.addEventListener("touchmove",l,wt),document.addEventListener("touchstart",u,wt),function(){xt=xt.filter(function(h){return h!==a}),document.removeEventListener("wheel",l,wt),document.removeEventListener("touchmove",l,wt),document.removeEventListener("touchstart",u,wt)}},[]);var m=e.removeScrollBar,w=e.inert;return f.createElement(f.Fragment,null,w?f.createElement(a,{styles:uu(o)}):null,m?f.createElement(nu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function mu(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const hu=Ud(ya,pu);var kr=f.forwardRef(function(e,t){return f.createElement(bn,We({},e,{ref:t,sideCar:hu}))});kr.classNames=bn.classNames;var gu=[" ","Enter","ArrowUp","ArrowDown"],bu=[" ","Enter"],it="Select",[wn,xn,vu]=go(it),[St]=at(it,[vu,fn]),Sn=fn(),[yu,Je]=St(it),[wu,xu]=St(it),Ta=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:a,value:s,defaultValue:i,onValueChange:l,dir:d,name:u,autoComplete:p,disabled:g,required:m,form:w}=e,h=Sn(t),[v,k]=f.useState(null),[C,E]=f.useState(null),[y,T]=f.useState(!1),D=Zn(d),[M,P]=$t({prop:r,defaultProp:o??!1,onChange:a,caller:it}),[W,V]=$t({prop:s,defaultProp:i,onChange:l,caller:it}),H=f.useRef(null),G=v?w||!!v.closest("form"):!0,[x,A]=f.useState(new Set),_=Array.from(x).map(O=>O.props.value).join(";");return c.jsx(la,{...h,children:c.jsxs(yu,{required:m,scope:t,trigger:v,onTriggerChange:k,valueNode:C,onValueNodeChange:E,valueNodeHasChildren:y,onValueNodeHasChildrenChange:T,contentId:It(),value:W,onValueChange:V,open:M,onOpenChange:P,dir:D,triggerPointerDownPosRef:H,disabled:g,children:[c.jsx(wn.Provider,{scope:t,children:c.jsx(wu,{scope:e.__scopeSelect,onNativeOptionAdd:f.useCallback(O=>{A(N=>new Set(N).add(O))},[]),onNativeOptionRemove:f.useCallback(O=>{A(N=>{const S=new Set(N);return S.delete(O),S})},[]),children:n})}),G?c.jsxs(Za,{"aria-hidden":!0,required:m,tabIndex:-1,name:u,autoComplete:p,value:W,onChange:O=>V(O.target.value),disabled:g,form:w,children:[W===void 0?c.jsx("option",{value:""}):null,Array.from(x)]},_):null]})})};Ta.displayName=it;var Pa="SelectTrigger",_a=f.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,a=Sn(n),s=Je(Pa,n),i=s.disabled||r,l=se(t,s.onTriggerChange),d=xn(n),u=f.useRef("touch"),[p,g,m]=es(h=>{const v=d().filter(E=>!E.disabled),k=v.find(E=>E.value===s.value),C=ts(v,h,k);C!==void 0&&s.onValueChange(C.value)}),w=h=>{i||(s.onOpenChange(!0),m()),h&&(s.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return c.jsx(vr,{asChild:!0,...a,children:c.jsx(Ne.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:i,"data-disabled":i?"":void 0,"data-placeholder":Ja(s.value)?"":void 0,...o,ref:l,onClick:Q(o.onClick,h=>{h.currentTarget.focus(),u.current!=="mouse"&&w(h)}),onPointerDown:Q(o.onPointerDown,h=>{u.current=h.pointerType;const v=h.target;v.hasPointerCapture(h.pointerId)&&v.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(w(h),h.preventDefault())}),onKeyDown:Q(o.onKeyDown,h=>{const v=p.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&g(h.key),!(v&&h.key===" ")&&gu.includes(h.key)&&(w(),h.preventDefault())})})})});_a.displayName=Pa;var Oa="SelectValue",Ma=f.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:a,placeholder:s="",...i}=e,l=Je(Oa,n),{onValueNodeHasChildrenChange:d}=l,u=a!==void 0,p=se(t,l.onValueNodeChange);return he(()=>{d(u)},[d,u]),c.jsx(Ne.span,{...i,ref:p,style:{pointerEvents:"none"},children:Ja(l.value)?c.jsx(c.Fragment,{children:s}):a})});Ma.displayName=Oa;var Su="SelectIcon",Ia=f.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ne.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Ia.displayName=Su;var Cu="SelectPortal",Da=e=>c.jsx(yr,{asChild:!0,...e});Da.displayName=Cu;var ct="SelectContent",La=f.forwardRef((e,t)=>{const n=Je(ct,e.__scopeSelect),[r,o]=f.useState();if(he(()=>{o(new DocumentFragment)},[]),!n.open){const a=r;return a?Jt.createPortal(c.jsx(Fa,{scope:e.__scopeSelect,children:c.jsx(wn.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),a):null}return c.jsx($a,{...e,ref:t})});La.displayName=ct;var Oe=10,[Fa,et]=St(ct),Eu="SelectContentImpl",ku=Se("SelectContent.RemoveScroll"),$a=f.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:s,side:i,sideOffset:l,align:d,alignOffset:u,arrowPadding:p,collisionBoundary:g,collisionPadding:m,sticky:w,hideWhenDetached:h,avoidCollisions:v,...k}=e,C=Je(ct,n),[E,y]=f.useState(null),[T,D]=f.useState(null),M=se(t,L=>y(L)),[P,W]=f.useState(null),[V,H]=f.useState(null),G=xn(n),[x,A]=f.useState(!1),_=f.useRef(!1);f.useEffect(()=>{if(E)return ha(E)},[E]),So();const O=f.useCallback(L=>{const[te,...ce]=G().map(oe=>oe.ref.current),[Z]=ce.slice(-1),ne=document.activeElement;for(const oe of L)if(oe===ne||(oe?.scrollIntoView({block:"nearest"}),oe===te&&T&&(T.scrollTop=0),oe===Z&&T&&(T.scrollTop=T.scrollHeight),oe?.focus(),document.activeElement!==ne))return},[G,T]),N=f.useCallback(()=>O([P,E]),[O,P,E]);f.useEffect(()=>{x&&N()},[x,N]);const{onOpenChange:S,triggerPointerDownPosRef:R}=C;f.useEffect(()=>{if(E){let L={x:0,y:0};const te=Z=>{L={x:Math.abs(Math.round(Z.pageX)-(R.current?.x??0)),y:Math.abs(Math.round(Z.pageY)-(R.current?.y??0))}},ce=Z=>{L.x<=10&&L.y<=10?Z.preventDefault():E.contains(Z.target)||S(!1),document.removeEventListener("pointermove",te),R.current=null};return R.current!==null&&(document.addEventListener("pointermove",te),document.addEventListener("pointerup",ce,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",te),document.removeEventListener("pointerup",ce,{capture:!0})}}},[E,S,R]),f.useEffect(()=>{const L=()=>S(!1);return window.addEventListener("blur",L),window.addEventListener("resize",L),()=>{window.removeEventListener("blur",L),window.removeEventListener("resize",L)}},[S]);const[Y,j]=es(L=>{const te=G().filter(ne=>!ne.disabled),ce=te.find(ne=>ne.ref.current===document.activeElement),Z=ts(te,L,ce);Z&&setTimeout(()=>Z.ref.current.focus())}),xe=f.useCallback((L,te,ce)=>{const Z=!_.current&&!ce;(C.value!==void 0&&C.value===te||Z)&&(W(L),Z&&(_.current=!0))},[C.value]),q=f.useCallback(()=>E?.focus(),[E]),ee=f.useCallback((L,te,ce)=>{const Z=!_.current&&!ce;(C.value!==void 0&&C.value===te||Z)&&H(L)},[C.value]),J=r==="popper"?Nr:Ra,ge=J===Nr?{side:i,sideOffset:l,align:d,alignOffset:u,arrowPadding:p,collisionBoundary:g,collisionPadding:m,sticky:w,hideWhenDetached:h,avoidCollisions:v}:{};return c.jsx(Fa,{scope:n,content:E,viewport:T,onViewportChange:D,itemRefCallback:xe,selectedItem:P,onItemLeave:q,itemTextRefCallback:ee,focusSelectedItem:N,selectedItemText:V,position:r,isPositioned:x,searchRef:Y,children:c.jsx(kr,{as:ku,allowPinchZoom:!0,children:c.jsx(or,{asChild:!0,trapped:C.open,onMountAutoFocus:L=>{L.preventDefault()},onUnmountAutoFocus:Q(o,L=>{C.trigger?.focus({preventScroll:!0}),L.preventDefault()}),children:c.jsx(er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:L=>L.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:c.jsx(J,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:L=>L.preventDefault(),...k,...ge,onPlaced:()=>A(!0),ref:M,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Q(k.onKeyDown,L=>{const te=L.ctrlKey||L.altKey||L.metaKey;if(L.key==="Tab"&&L.preventDefault(),!te&&L.key.length===1&&j(L.key),["ArrowUp","ArrowDown","Home","End"].includes(L.key)){let Z=G().filter(ne=>!ne.disabled).map(ne=>ne.ref.current);if(["ArrowUp","End"].includes(L.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(L.key)){const ne=L.target,oe=Z.indexOf(ne);Z=Z.slice(oe+1)}setTimeout(()=>O(Z)),L.preventDefault()}})})})})})})});$a.displayName=Eu;var Nu="SelectItemAlignedPosition",Ra=f.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,a=Je(ct,n),s=et(ct,n),[i,l]=f.useState(null),[d,u]=f.useState(null),p=se(t,M=>u(M)),g=xn(n),m=f.useRef(!1),w=f.useRef(!0),{viewport:h,selectedItem:v,selectedItemText:k,focusSelectedItem:C}=s,E=f.useCallback(()=>{if(a.trigger&&a.valueNode&&i&&d&&h&&v&&k){const M=a.trigger.getBoundingClientRect(),P=d.getBoundingClientRect(),W=a.valueNode.getBoundingClientRect(),V=k.getBoundingClientRect();if(a.dir!=="rtl"){const ne=V.left-P.left,oe=W.left-ne,fe=M.left-oe,Te=M.width+fe,De=Math.max(Te,P.width),ut=window.innerWidth-Oe,ft=mo(oe,[Oe,Math.max(Oe,ut-De)]);i.style.minWidth=Te+"px",i.style.left=ft+"px"}else{const ne=P.right-V.right,oe=window.innerWidth-W.right-ne,fe=window.innerWidth-M.right-oe,Te=M.width+fe,De=Math.max(Te,P.width),ut=window.innerWidth-Oe,ft=mo(oe,[Oe,Math.max(Oe,ut-De)]);i.style.minWidth=Te+"px",i.style.right=ft+"px"}const H=g(),G=window.innerHeight-Oe*2,x=h.scrollHeight,A=window.getComputedStyle(d),_=parseInt(A.borderTopWidth,10),O=parseInt(A.paddingTop,10),N=parseInt(A.borderBottomWidth,10),S=parseInt(A.paddingBottom,10),R=_+O+x+S+N,Y=Math.min(v.offsetHeight*5,R),j=window.getComputedStyle(h),xe=parseInt(j.paddingTop,10),q=parseInt(j.paddingBottom,10),ee=M.top+M.height/2-Oe,J=G-ee,ge=v.offsetHeight/2,L=v.offsetTop+ge,te=_+O+L,ce=R-te;if(te<=ee){const ne=H.length>0&&v===H[H.length-1].ref.current;i.style.bottom="0px";const oe=d.clientHeight-h.offsetTop-h.offsetHeight,fe=Math.max(J,ge+(ne?q:0)+oe+N),Te=te+fe;i.style.height=Te+"px"}else{const ne=H.length>0&&v===H[0].ref.current;i.style.top="0px";const fe=Math.max(ee,_+h.offsetTop+(ne?xe:0)+ge)+ce;i.style.height=fe+"px",h.scrollTop=te-ee+h.offsetTop}i.style.margin=`${Oe}px 0`,i.style.minHeight=Y+"px",i.style.maxHeight=G+"px",r?.(),requestAnimationFrame(()=>m.current=!0)}},[g,a.trigger,a.valueNode,i,d,h,v,k,a.dir,r]);he(()=>E(),[E]);const[y,T]=f.useState();he(()=>{d&&T(window.getComputedStyle(d).zIndex)},[d]);const D=f.useCallback(M=>{M&&w.current===!0&&(E(),C?.(),w.current=!1)},[E,C]);return c.jsx(Tu,{scope:n,contentWrapper:i,shouldExpandOnScrollRef:m,onScrollButtonChange:D,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:y},children:c.jsx(Ne.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ra.displayName=Nu;var Au="SelectPopperPosition",Nr=f.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Oe,...a}=e,s=Sn(n);return c.jsx(da,{...s,...a,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Nr.displayName=Au;var[Tu,Ar]=St(ct,{}),Tr="SelectViewport",Wa=f.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,a=et(Tr,n),s=Ar(Tr,n),i=se(t,a.onViewportChange),l=f.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(wn.Slot,{scope:n,children:c.jsx(Ne.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Q(o.onScroll,d=>{const u=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:g}=s;if(g?.current&&p){const m=Math.abs(l.current-u.scrollTop);if(m>0){const w=window.innerHeight-Oe*2,h=parseFloat(p.style.minHeight),v=parseFloat(p.style.height),k=Math.max(h,v);if(k<w){const C=k+m,E=Math.min(w,C),y=C-E;p.style.height=E+"px",p.style.bottom==="0px"&&(u.scrollTop=y>0?y:0,p.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});Wa.displayName=Tr;var za="SelectGroup",[Pu,_u]=St(za),Ba=f.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=It();return c.jsx(Pu,{scope:n,id:o,children:c.jsx(Ne.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Ba.displayName=za;var Ha="SelectLabel",Ua=f.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_u(Ha,n);return c.jsx(Ne.div,{id:o.id,...r,ref:t})});Ua.displayName=Ha;var Cn="SelectItem",[Ou,ja]=St(Cn),Va=f.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...s}=e,i=Je(Cn,n),l=et(Cn,n),d=i.value===r,[u,p]=f.useState(a??""),[g,m]=f.useState(!1),w=se(t,C=>l.itemRefCallback?.(C,r,o)),h=It(),v=f.useRef("touch"),k=()=>{o||(i.onValueChange(r),i.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(Ou,{scope:n,value:r,disabled:o,textId:h,isSelected:d,onItemTextChange:f.useCallback(C=>{p(E=>E||(C?.textContent??"").trim())},[]),children:c.jsx(wn.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:c.jsx(Ne.div,{role:"option","aria-labelledby":h,"data-highlighted":g?"":void 0,"aria-selected":d&&g,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...s,ref:w,onFocus:Q(s.onFocus,()=>m(!0)),onBlur:Q(s.onBlur,()=>m(!1)),onClick:Q(s.onClick,()=>{v.current!=="mouse"&&k()}),onPointerUp:Q(s.onPointerUp,()=>{v.current==="mouse"&&k()}),onPointerDown:Q(s.onPointerDown,C=>{v.current=C.pointerType}),onPointerMove:Q(s.onPointerMove,C=>{v.current=C.pointerType,o?l.onItemLeave?.():v.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Q(s.onPointerLeave,C=>{C.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:Q(s.onKeyDown,C=>{l.searchRef?.current!==""&&C.key===" "||(bu.includes(C.key)&&k(),C.key===" "&&C.preventDefault())})})})})});Va.displayName=Cn;var Rt="SelectItemText",Ga=f.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...a}=e,s=Je(Rt,n),i=et(Rt,n),l=ja(Rt,n),d=xu(Rt,n),[u,p]=f.useState(null),g=se(t,k=>p(k),l.onItemTextChange,k=>i.itemTextRefCallback?.(k,l.value,l.disabled)),m=u?.textContent,w=f.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:m},l.value),[l.disabled,l.value,m]),{onNativeOptionAdd:h,onNativeOptionRemove:v}=d;return he(()=>(h(w),()=>v(w)),[h,v,w]),c.jsxs(c.Fragment,{children:[c.jsx(Ne.span,{id:l.textId,...a,ref:g}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Jt.createPortal(a.children,s.valueNode):null]})});Ga.displayName=Rt;var Ya="SelectItemIndicator",Mu=f.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return ja(Ya,n).isSelected?c.jsx(Ne.span,{"aria-hidden":!0,...r,ref:t}):null});Mu.displayName=Ya;var Pr="SelectScrollUpButton",qa=f.forwardRef((e,t)=>{const n=et(Pr,e.__scopeSelect),r=Ar(Pr,e.__scopeSelect),[o,a]=f.useState(!1),s=se(t,r.onScrollButtonChange);return he(()=>{if(n.viewport&&n.isPositioned){let i=function(){const d=l.scrollTop>0;a(d)};const l=n.viewport;return i(),l.addEventListener("scroll",i),()=>l.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),o?c.jsx(Ka,{...e,ref:s,onAutoScroll:()=>{const{viewport:i,selectedItem:l}=n;i&&l&&(i.scrollTop=i.scrollTop-l.offsetHeight)}}):null});qa.displayName=Pr;var _r="SelectScrollDownButton",Iu=f.forwardRef((e,t)=>{const n=et(_r,e.__scopeSelect),r=Ar(_r,e.__scopeSelect),[o,a]=f.useState(!1),s=se(t,r.onScrollButtonChange);return he(()=>{if(n.viewport&&n.isPositioned){let i=function(){const d=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<d;a(u)};const l=n.viewport;return i(),l.addEventListener("scroll",i),()=>l.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),o?c.jsx(Ka,{...e,ref:s,onAutoScroll:()=>{const{viewport:i,selectedItem:l}=n;i&&l&&(i.scrollTop=i.scrollTop+l.offsetHeight)}}):null});Iu.displayName=_r;var Ka=f.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,a=et("SelectScrollButton",n),s=f.useRef(null),i=xn(n),l=f.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return f.useEffect(()=>()=>l(),[l]),he(()=>{i().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[i]),c.jsx(Ne.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Q(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Q(o.onPointerMove,()=>{a.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Q(o.onPointerLeave,()=>{l()})})}),Du="SelectSeparator",Xa=f.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ne.div,{"aria-hidden":!0,...r,ref:t})});Xa.displayName=Du;var Or="SelectArrow",Qa=f.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Sn(n),a=Je(Or,n),s=et(Or,n);return a.open&&s.position==="popper"?c.jsx(ua,{...o,...r,ref:t}):null});Qa.displayName=Or;var Lu="SelectBubbleInput",Za=f.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=f.useRef(null),a=se(r,o),s=fa(t);return f.useEffect(()=>{const i=o.current;if(!i)return;const l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==t&&u){const p=new Event("change",{bubbles:!0});u.call(i,t),i.dispatchEvent(p)}},[s,t]),c.jsx(Ne.select,{...n,style:{...pa,...n.style},ref:a,defaultValue:t})});Za.displayName=Lu;function Ja(e){return e===""||e===void 0}function es(e){const t=Ke(e),n=f.useRef(""),r=f.useRef(0),o=f.useCallback(s=>{const i=n.current+s;t(i),(function l(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>l(""),1e3))})(i)},[t]),a=f.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return f.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,a]}function ts(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let s=Fu(e,Math.max(a,0));o.length===1&&(s=s.filter(d=>d!==n));const l=s.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Fu(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $u=Ta,Ru=_a,Wu=Ma,zu=Ia,Bu=Da,Hu=La,Uu=Wa,ju=Ba,Vu=Ua,Gu=Va,Yu=Ga,qu=qa,Ku=Xa,ns=Qa;function Xu({field:e,formValues:t,handleChange:n,handleBlur:r,error:o,apiClient:a}){const s=t[e.name]||"",i=typeof e.disabled=="function"?e.disabled(t):e.disabled,[l,d]=B.useState(e.options||[]),[u,p]=B.useState(!1);return B.useEffect(()=>{(async()=>{if(!e.optionsUrl||!a){e.options&&d(e.options);return}p(!0);try{let m=e.optionsUrl,w={};if(e.queryParams){const E=typeof e.queryParams=="function"?e.queryParams(t):e.queryParams;typeof E=="string"?m+=E.startsWith("?")?E:`?${E}`:w={params:E}}const h=await a(m,w),v=h.data||h,C=(Array.isArray(v)?v:[]).map(E=>({value:E[e.valueId||"key"]||E.key,label:E[e.labelId||"value"]||E.value}));d(C),n(`${e.name}_count`,C.length)}catch(m){console.error("Failed to load options for SelectField:",m),d(e.options||[])}finally{p(!1)}})()},[e.optionsUrl,e.options,a,e.valueId,e.labelId,JSON.stringify(typeof e.queryParams=="function"?e.queryParams(t):e.queryParams)]),c.jsxs(c.Fragment,{children:[c.jsxs($u,{value:s,onValueChange:g=>n(e.name,g),disabled:i,children:[c.jsxs(Ru,{id:e.name,onBlur:()=>r(e.name),className:`inline-flex items-center justify-between w-full h-10 rounded-md border px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 bg-background transition-all
|
|
61
61
|
${o?"border-red-500 focus-visible:ring-red-500":"border-input focus-visible:ring-blue-500"}
|
|
62
62
|
${i?"cursor-not-allowed opacity-50":""}
|
|
63
63
|
`,children:[c.jsx(Wu,{placeholder:u?"Loading...":e.placeholder||`Select ${e.label?.toLowerCase()||""}`}),c.jsx(zu,{className:"ml-2 text-gray-500 flex items-center",children:u?c.jsx(po,{className:"w-4 h-4 animate-spin"}):c.jsx(en,{className:"w-4 h-4"})})]}),c.jsx(Bu,{children:c.jsxs(Hu,{className:"bg-white border border-gray-200 rounded-md shadow-lg z-50 min-w-[var(--radix-select-trigger-width)]",position:"popper",sideOffset:5,children:[c.jsx(qu,{className:"flex items-center justify-center h-6 text-gray-500 bg-gray-50",children:c.jsx(ns,{className:"fill-white stroke-gray-200"})}),c.jsxs(Uu,{className:"p-1",children:[e.groupLabel&&c.jsx(ju,{children:c.jsx(Vu,{className:"px-2 py-1 text-xs text-gray-500 uppercase tracking-wide",children:e.groupLabel})}),l.map(g=>c.jsx(Gu,{value:g.value,className:`relative flex items-center px-3 py-2 text-sm rounded cursor-pointer select-none
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ynotsoft-dynamic-form",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.88",
|
|
4
4
|
"description": "DynamicForm React component library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/dynamic-form.umd.cjs",
|
|
@@ -70,4 +70,4 @@
|
|
|
70
70
|
"lucide-react": "^0.554.0",
|
|
71
71
|
"tailwind-merge": "^3.4.0"
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|