| 1 |
- import{a as e,n as t}from"./react-dom-stZKkA6x.js";import{Tr as n,bt as r}from"./jsx-runtime-dm82oUI8.js";var i=e(t()),a=e=>typeof e==`object`&&!!e&&e.nodeType===1,o=(e,t)=>(!t||e!==`hidden`)&&e!==`visible`&&e!==`clip`,s=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){let n=getComputedStyle(e,null);return o(n.overflowY,t)||o(n.overflowX,t)||(e=>{let t=(e=>{if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch{return null}})(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)})(e)}return!1},c=(e,t,n,r,i,a,o,s)=>a<e&&o>t||a>e&&o<t?0:a<=e&&s<=n||o>=t&&s>=n?a-e-r:o>t&&s<n||a<e&&s>n?o-t+i:0,l=e=>e.parentElement??(e.getRootNode().host||null),u=(e,t)=>{if(typeof document>`u`)return[];let{scrollMode:n,block:r,inline:i,boundary:o,skipOverflowHiddenElements:u}=t,d=typeof o==`function`?o:e=>e!==o;if(!a(e))throw TypeError(`Invalid target`);let f=document.scrollingElement||document.documentElement,p=[],m=e;for(;a(m)&&d(m);){if(m=l(m),m===f){p.push(m);break}m!=null&&m===document.body&&s(m)&&!s(document.documentElement)||m!=null&&s(m,u)&&p.push(m)}let h=window.visualViewport?.width??innerWidth,g=window.visualViewport?.height??innerHeight,{scrollX:_,scrollY:v}=window,{height:y,width:b,top:x,right:S,bottom:C,left:w}=e.getBoundingClientRect(),{top:T,right:E,bottom:D,left:O}=(e=>{let t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e),k=r===`start`||r===`nearest`?x-T:r===`end`?C+D:x+y/2-T+D,A=i===`center`?w+b/2-O+E:i===`end`?S+E:w-O,j=[];for(let e=0;e<p.length;e++){let t=p[e],{height:a,width:o,top:l,right:u,bottom:d,left:m}=t.getBoundingClientRect();if(n===`if-needed`&&x>=0&&w>=0&&C<=g&&S<=h&&(t===f&&!s(t)||x>=l&&C<=d&&w>=m&&S<=u))return j;let T=getComputedStyle(t),E=parseInt(T.borderLeftWidth,10),D=parseInt(T.borderTopWidth,10),O=parseInt(T.borderRightWidth,10),M=parseInt(T.borderBottomWidth,10),N=0,P=0,F=`offsetWidth`in t?t.offsetWidth-t.clientWidth-E-O:0,I=`offsetHeight`in t?t.offsetHeight-t.clientHeight-D-M:0,L=`offsetWidth`in t?t.offsetWidth===0?0:o/t.offsetWidth:0,R=`offsetHeight`in t?t.offsetHeight===0?0:a/t.offsetHeight:0;if(f===t)N=r===`start`?k:r===`end`?k-g:r===`nearest`?c(v,v+g,g,D,M,v+k,v+k+y,y):k-g/2,P=i===`start`?A:i===`center`?A-h/2:i===`end`?A-h:c(_,_+h,h,E,O,_+A,_+A+b,b),N=Math.max(0,N+v),P=Math.max(0,P+_);else{N=r===`start`?k-l-D:r===`end`?k-d+M+I:r===`nearest`?c(l,d,a,D,M+I,k,k+y,y):k-(l+a/2)+I/2,P=i===`start`?A-m-E:i===`center`?A-(m+o/2)+F/2:i===`end`?A-u+O+F:c(m,u,o,E,O+F,A,A+b,b);let{scrollLeft:e,scrollTop:n}=t;N=R===0?0:Math.max(0,Math.min(n+N/R,t.scrollHeight-a/R+I)),P=L===0?0:Math.max(0,Math.min(e+P/L,t.scrollWidth-o/L+F)),k+=n-N,A+=e-P}j.push({el:t,top:N,left:P})}return j},d=e=>!1===e?{block:`end`,inline:`nearest`}:(e=>e===Object(e)&&Object.keys(e).length!==0)(e)?e:{block:`start`,inline:`nearest`};function f(e,t){if(!e.isConnected||!(e=>{let t=e;for(;t&&t.parentNode;){if(t.parentNode===document)return!0;t=t.parentNode instanceof ShadowRoot?t.parentNode.host:t.parentNode}return!1})(e))return;let n=(e=>{let t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e);if((e=>typeof e==`object`&&typeof e.behavior==`function`)(t))return t.behavior(u(e,t));let r=typeof t==`boolean`||t==null?void 0:t.behavior;for(let{el:i,top:a,left:o}of u(e,d(t))){let e=a-n.top+n.bottom,t=o-n.left+n.right;i.scroll({top:e,left:t,behavior:r})}}var p=[`parentNode`],m=`form_item`;function h(e){return e===void 0||e===!1?[]:Array.isArray(e)?e:[e]}function g(e,t){if(!e.length)return;let n=e.join(`_`);return t?`${t}_${n}`:p.includes(n)?`${m}_${n}`:n}function _(e,t,n,r,i,a){let o=r;return a===void 0?n.validating?o=`validating`:e.length?o=`error`:t.length?o=`warning`:(n.touched||i&&n.validated)&&(o=`success`):o=a,o}var v=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function y(e){return h(e).join(`_`)}function b(e,t){let r=n(t.getFieldInstance(e));if(r)return r;let i=g(h(e),t.__INTERNAL__.name);if(i)return document.getElementById(i)}function x(e){let[t]=r(),n=i.useRef({}),a=i.useMemo(()=>e??Object.assign(Object.assign({},t),{__INTERNAL__:{itemRef:e=>t=>{let r=y(e);t?n.current[r]=t:delete n.current[r]}},scrollToField:(e,t={})=>{let{focus:n}=t,r=v(t,[`focus`]),i=b(e,a);i&&(f(i,Object.assign({scrollMode:`if-needed`,block:`nearest`},r)),n&&a.focusField(e))},focusField:e=>{var t,n;let r=a.getFieldInstance(e);typeof r?.focus==`function`?r.focus():(n=(t=b(e,a))?.focus)==null||n.call(t)},getFieldInstance:e=>{let t=y(e);return n.current[t]}}),[e,t]);return[a]}export{h as a,_ as i,x as n,g as r,y as t};
|