@floating-ui/react-dom-interactions
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -1,1 +0,1 @@ | ||
import*as e from"react";import{useLayoutEffect as n,useEffect as t,useRef as r}from"react";import{getOverflowAncestors as o,useFloating as u}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import{createPortal as c}from"react-dom";import{hideOthers as i}from"aria-hidden";var l="undefined"!=typeof document?n:t;function a(){const e=new Map;return{emit(n,t){var r;null==(r=e.get(n))||r.forEach((e=>e(t)))},on(n,t){e.set(n,[...e.get(n)||[],t])},off(n,t){e.set(n,(e.get(n)||[]).filter((e=>e!==t)))}}}let s=!1,f=0;const d=()=>"floating-ui-"+f++;const v=e["useId".toString()],m=null!=v?v:function(){const[n,t]=e.useState((()=>s?d():void 0));return l((()=>{null==n&&t(d())}),[]),e.useEffect((()=>{s||(s=!0)}),[]),n},p=e.createContext(null),g=e.createContext(null),b=()=>{var n,t;return null!=(n=null==(t=e.useContext(p))?void 0:t.id)?n:null},h=()=>e.useContext(g),y=()=>{const e=m(),n=h(),t=b();return l((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},w=n=>{let{children:t,id:r}=n;const o=b();return e.createElement(p.Provider,{value:e.useMemo((()=>({id:r,parentId:o})),[r,o])},t)},E=n=>{let{children:t}=n;const r=e.useRef([]),o=e.useCallback((e=>{r.current=[...r.current,e]}),[]),u=e.useCallback((e=>{r.current=r.current.filter((n=>n!==e))}),[]),c=e.useState((()=>a()))[0];return e.createElement(g.Provider,{value:e.useMemo((()=>({nodesRef:r,addNode:o,removeNode:u,events:c})),[r,o,u,c])},t)};function x(e,n,t){const r={};return{..."floating"===t&&{tabIndex:-1},...e,...n.map((e=>e?e[t]:null)).concat(e).reduce(((e,n)=>n?(Object.entries(n).forEach((n=>{let[t,o]=n;0===t.indexOf("on")?(r[t]||(r[t]=[]),"function"==typeof o&&r[t].push(o),e[t]=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];r[t].forEach((e=>e(...n)))}):e[t]=o})),e):e),{})}}const R=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>x(n,e,"reference"),getFloatingProps:n=>x(n,e,"floating"),getItemProps:n=>x(n,e,"item")}};function L(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function k(e){var n;return null!=(n=L(e).defaultView)?n:window}function I(e){return!!e&&e instanceof k(e).Element}function T(e){return!!e&&e instanceof k(e).HTMLElement}function C(e,n){var t;let r=null!=(t=null==e?void 0:e.nodesRef.current.filter((e=>{var t;return e.parentId===n&&(null==(t=e.context)?void 0:t.open)})))?t:[],o=r;for(;o.length;){var u;o=null!=(u=null==e?void 0:e.nodesRef.current.filter((e=>{var n;return null==(n=o)?void 0:n.some((n=>{var t;return e.parentId===n.id&&(null==(t=e.context)?void 0:t.open)}))})))?u:[],r=r.concat(o)}return r}function A(e){let n,{restMs:t=0,buffer:r=.5,debug:o=null}=void 0===e?{}:e,u=!1;return e=>{let{x:o,y:c,placement:i,refs:l,onClose:a,nodeId:s,tree:f,leave:d=!1}=e;return function(e){var v;function m(){clearTimeout(n),a()}if(clearTimeout(n),e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:p,clientY:g}=e,b="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&I(l.reference.current)&&l.reference.current.contains(b))return;if(f&&C(f,s).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(null!=(v=l.floating.current)&&v.contains(b)&&!d)return void(u=!0);if(!l.reference.current||!l.floating.current||null==i||null==o||null==c)return;const h=l.reference.current.getBoundingClientRect(),y=l.floating.current.getBoundingClientRect(),w=i.split("-")[0],E=o>y.right-y.width/2,x=c>y.bottom-y.height/2;if("top"===w&&c>=h.bottom-1||"bottom"===w&&c<=h.top+1||"left"===w&&o>=h.right-1||"right"===w&&o<=h.left+1)return m();switch(w){case"top":if(p>=y.left&&p<=y.right&&g>=y.top&&g<=h.top+1)return;break;case"bottom":if(p>=y.left&&p<=y.right&&g>=h.bottom-1&&g<=y.bottom)return;break;case"left":if(p>=y.left&&p<=h.left+1&&g>=y.top&&g<=y.bottom)return;break;case"right":if(p>=h.right-1&&p<=y.right&&g>=y.top&&g<=y.bottom)return}if(u)return m();const R=function(e){let[n,t]=e;const o=y.width>h.width,u=y.height>h.height;switch(w){case"top":return[[o?n+r/2:E?n+4*r:n-4*r,t+r+1],[o?n-r/2:E?n+4*r:n-4*r,t+r+1],...[[y.left,E||o?y.bottom-r:y.top],[y.right,E?o?y.bottom-r:y.top:y.bottom-r]]];case"bottom":return[[o?n+r/2:E?n+4*r:n-4*r,t-r],[o?n-r/2:E?n+4*r:n-4*r,t-r],...[[y.left,E||o?y.top+r:y.bottom],[y.right,E?o?y.top+r:y.bottom:y.top+r]]];case"left":{const e=[n+r+1,u?t+r/2:x?t+4*r:t-4*r],o=[n+r+1,u?t-r/2:x?t+4*r:t-4*r];return[...[[x||u?y.right-r:y.left,y.top],[x?u?y.right-r:y.left:y.right-r,y.bottom]],e,o]}case"right":return[[n-r,u?t+r/2:x?t+4*r:t-4*r],[n-r,u?t-r/2:x?t+4*r:t-4*r],...[[x||u?y.left+r:y.right,y.top],[x?u?y.left+r:y.right:y.left+r,y.bottom]]]}}([o,c]);!function(e,n){const[t,r]=e;let o=!1;const u=n.length;for(let e=0,c=u-1;e<u;c=e++){const[u,i]=n[e]||[0,0],[l,a]=n[c]||[0,0];i>=r!=a>=r&&t<=(l-u)*(r-i)/(a-i)+u&&(o=!o)}return o}([p,g],R)?m():t&&(n=setTimeout(a,t))}}}const O="floating-ui-root",M=function(n){let{id:t=O,enabled:r=!0}=void 0===n?{}:n;const o=e.useRef(null);return l((()=>{if(!r)return;const e=document.getElementById(t);e?o.current=e:(o.current=document.createElement("div"),o.current.id=t),document.body.contains(o.current)||document.body.appendChild(o.current)}),[t,r]),o.current},D=n=>{let{children:t,id:r=O,root:o=null}=n;const[u,i]=e.useState(!1),a=M({id:r,enabled:!o});return l((()=>{o||i(!0)}),[o]),o?c(t,o):u&&a?c(t,a):null};function P(){return P=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},P.apply(this,arguments)}const S="data-floating-ui-scroll-lock";const F=e.forwardRef((function(n,t){let{lockScroll:r=!1,...o}=n;return l((()=>{var e,n,t,o;if(!r)return;if(document.body.hasAttribute(S))return;document.body.setAttribute(S,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(function(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(S),Object.assign(document.body.style,{overflow:"",[u]:""})};const i=null!=(e=null==(n=window.visualViewport)?void 0:n.offsetLeft)?e:0,l=null!=(t=null==(o=window.visualViewport)?void 0:o.offsetTop)?t:0,a=window.pageXOffset,s=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(s-Math.floor(l))+"px",left:-(a-Math.floor(i))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(S),window.scrollTo(a,s)}}),[r]),e.createElement("div",P({ref:t},o,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...o.style}}))}));function K(e){let n=e.activeElement;for(;null!=(null==(t=n)||null==(r=t.shadowRoot)?void 0:r.activeElement);){var t,r;n=n.shadowRoot.activeElement}return n}function j(e){e.preventDefault(),e.stopPropagation()}function N(e){const n=r(e);return l((()=>{n.current=e})),n}function B(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const V=e.forwardRef((function(n,t){return e.createElement("span",P({},n,{ref:t,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function U(n){let{context:{refs:t,nodeId:r,onOpenChange:o},children:u,order:c=["content"],endGuard:l=!0,preventTabbing:a=!1,initialFocus:s=0,returnFocus:f=!0,modal:d=!0}=n;const v=N(c),m=N(o),p=h(),g=e.useCallback((()=>v.current.map((e=>{return T(t.reference.current)&&"reference"===e?t.reference.current:t.floating.current&&"floating"===e?t.floating.current:"content"===e?Array.from(null!=(n=null==(r=t.floating.current)?void 0:r.querySelectorAll("input:not([type='hidden']):not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],[contenteditable]:not([contenteditable='false'])"))?n:[]):null;var n,r})).flat().filter((e=>{if(e===t.floating.current||e===t.reference.current)return!0;if(T(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[v,t.floating,t.reference]);return e.useEffect((()=>{if(!d)return;const e=0===g().filter((e=>e!==t.floating.current&&e!==t.reference.current)).length;function n(n){if("Tab"===n.key){(a||e)&&j(n);const r=g(),o="composedPath"in n?n.composedPath()[0]:n.target;"reference"===v.current[0]&&o===t.reference.current&&(j(n),n.shiftKey?B(r[r.length-1]):B(r[1])),"floating"===v.current[1]&&o===t.floating.current&&n.shiftKey&&(j(n),B(r[0]))}}const r=L(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[a,d,g,v,t.floating,t.reference]),e.useEffect((()=>{function e(e){var n;const o=e.relatedTarget;null!=(n=t.floating.current)&&n.contains(o)||!I(t.reference.current)||t.reference.current.contains(o)||p&&C(p,r).some((e=>{let{context:n}=e;return null==n?void 0:n.open}))||p&&C(p,r).some((e=>{var n,t;return null==(n=e.context)||null==(t=n.refs.floating.current)?void 0:t.contains(o)}))||m.current(!1)}const n=t.floating.current,o=t.reference.current;if(n&&T(o)){!d&&n.addEventListener("focusout",e);const t=d?i(n):null;return()=>{!d&&n.removeEventListener("focusout",e),null==t||t()}}}),[r,p,d,m,g,s,t.floating,t.reference]),e.useEffect((()=>{if(a)return;const e=t.floating.current,n=K(L(e));var r;if("number"==typeof s)B(null!=(r=g()[s])?r:e);else if(T(null==s?void 0:s.current)){var o;B(null!=(o=s.current)?o:e)}return()=>{f&&T(n)&&B(n)}}),[a,g,s,d,f,t.floating]),e.createElement(e.Fragment,null,d&&e.createElement(V,{onFocus:e=>{j(e);const n=g();"reference"===c[0]?B(n[0]):B(n[n.length-1])}}),e.cloneElement(u,c.includes("floating")?{tabIndex:0}:{}),d&&l&&e.createElement(V,{onFocus:e=>{j(e),B(g()[0])}}))}function H(e,n,t){return t&&"mouse"!==t?0:"number"==typeof e?e:null==e?void 0:e[n]}const X=function(n,t){let{enabled:r=!0,delay:o=0,handleClose:u=null,mouseOnly:c=!1,restMs:i=0}=void 0===t?{}:t;const{open:a,onOpenChange:s,dataRef:f,events:d,refs:v}=n,m=h(),p=N(s),g=N(u),b=e.useRef(),y=e.useRef(),w=e.useRef(),E=e.useRef(),x=e.useRef(!0);l((()=>{r&&(a||(b.current=void 0))})),e.useEffect((()=>{if(r)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(y.current),clearTimeout(E.current),x.current=!0}}),[r,d,v.floating]),e.useEffect((()=>{if(!r||!g.current)return;function e(){var e;null!=(e=f.current.openEvent)&&e.type.includes("mouse")&&p.current(!1)}const n=L(v.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[v.floating,p,r,g,f]);const R=e.useCallback((function(e){void 0===e&&(e=!0);const n=H(o,"close",b.current);n&&!w.current?(clearTimeout(y.current),y.current=setTimeout((()=>p.current(!1)),n)):e&&p.current(!1)}),[o,p]),k=e.useCallback((()=>{w.current&&(L(v.floating.current).removeEventListener("pointermove",w.current),w.current=void 0)}),[v.floating]);if(e.useEffect((()=>{a||k()}),[a,r,k]),e.useEffect((()=>{if(!r)return;function e(e){if(clearTimeout(y.current),x.current=!1,a||c&&"mouse"!==b.current||i>0&&0===H(o,"open"))return;f.current.openEvent=e;const n=H(o,"open",b.current);n?y.current=setTimeout((()=>{p.current(!0)}),n):p.current(!0)}function t(e){var t,r;if("click"===(null==(t=f.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=f.current.openEvent)?void 0:r.type))return;const o=L(v.floating.current);if(clearTimeout(E.current),g.current)return clearTimeout(y.current),w.current&&o.removeEventListener("pointermove",w.current),w.current=g.current({...n,tree:m,x:e.clientX,y:e.clientY,onClose(){k(),R()}}),void o.addEventListener("pointermove",w.current);R()}function u(e){null==g.current||g.current({...n,tree:m,x:e.clientX,y:e.clientY,leave:!0,onClose(){k(),R()}})(e)}const l=v.floating.current,s=v.reference.current;return I(s)?(a&&s.addEventListener("pointerleave",u),null==l||l.addEventListener("pointerleave",u),s.addEventListener("mousemove",e,{once:!0}),s.addEventListener("mouseenter",e),s.addEventListener("mouseleave",t),()=>{a&&s.removeEventListener("pointerleave",u),null==l||l.removeEventListener("pointerleave",u),s.removeEventListener("mousemove",e),s.removeEventListener("mouseenter",e),s.removeEventListener("mouseleave",t)}):void 0}),[r,R,n,o,g,f,c,p,a,m,i,k,v.reference,v.floating]),!r)return{};function T(e){b.current=e.pointerType}return{reference:{onPointerDown:T,onPointerEnter:T,onMouseMove(){a||0===i||(clearTimeout(E.current),E.current=setTimeout((()=>{x.current||s(!0)}),i))}},floating:{onMouseEnter(){clearTimeout(y.current)},onMouseLeave(){R(!1)}}}},Y=e.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),q=()=>e.useContext(Y),W=n=>{let{children:t,delay:r}=n;const[o,u]=e.useState({delay:r,initialDelay:r,currentId:null}),c=e.useCallback((e=>{u((n=>({...n,currentId:e})))}),[]);return e.createElement(Y.Provider,{value:e.useMemo((()=>({...o,setState:u,setCurrentId:c})),[o,u,c])},t)},z=(n,t)=>{let{open:r,onOpenChange:o}=n,{id:u}=t;const{currentId:c,initialDelay:i,setState:l}=q(),a=N(o);e.useEffect((()=>{c&&a.current&&(l((e=>({...e,delay:{open:1,close:H(i,"close")}}))),c!==u&&a.current(!1))}),[u,a,l,c,i]),e.useEffect((()=>{!r&&c===u&&a.current&&(a.current(!1),l((e=>({...e,delay:i,currentId:null}))))}),[r,l,c,u,a,i])},G=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=m(),c=m(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?u:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},J=function(n,t){let{open:r,onOpenChange:o,dataRef:u,refs:c}=n,{enabled:i=!0,pointerDown:l=!1,toggle:a=!0,ignoreMouse:s=!1}=void 0===t?{}:t;const f=e.useRef();function d(){return T(c.reference.current)&&"BUTTON"===c.reference.current.tagName}return i?{reference:{onPointerDown(e){if(f.current=e.pointerType,("mouse"!==f.current||!s)&&l){var n;if(r)a&&"pointerdown"===(null==(n=u.current.openEvent)?void 0:n.type)&&o(!1);else o(!0);u.current.openEvent=e.nativeEvent}},onClick(e){if(l&&f.current)f.current=void 0;else if("mouse"!==f.current||!s){var n;if(r)a&&"click"===(null==(n=u.current.openEvent)?void 0:n.type)&&o(!1);else o(!0);u.current.openEvent=e.nativeEvent}},onKeyDown(e){f.current=void 0,d()||(" "===e.key&&e.preventDefault(),"Enter"===e.key&&(r?a&&o(!1):o(!0)))},onKeyUp(e){d()||" "===e.key&&(r?a&&o(!1):o(!0))}}}:{}};function Q(e,n){if(null==n)return!1;if("composedPath"in e)return e.composedPath().includes(n);const t=e;return null!=t.target&&n.contains(t.target)}const Z=function(n,t){let{open:r,onOpenChange:u,refs:c,events:i,nodeId:l}=n,{enabled:a=!0,escapeKey:s=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===t?{}:t;const p=h(),g=N(u),b=e.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(K(L(c.floating.current)))}),[c.floating]),y=e.useCallback((()=>{T(c.reference.current)&&c.reference.current.focus()}),[c.reference]);return e.useEffect((()=>{if(!r||!a)return;function e(e){if("Escape"===e.key){if(!m&&!b())return;i.emit("dismiss"),g.current(!1),y()}}function n(e){const n=p&&C(p,l).some((n=>{var t;return Q(e,null==(t=n.context)?void 0:t.refs.floating.current)}));Q(e,c.floating.current)||I(c.reference.current)&&Q(e,c.reference.current)||n||(m||b())&&(i.emit("dismiss"),g.current(!1),y())}function t(){g.current(!1)}const u=L(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("mousedown",n);const d=(v?[...I(c.reference.current)?o(c.reference.current):[],...I(c.floating.current)?o(c.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=u.defaultView)?void 0:n.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",t,{passive:!0}))),()=>{s&&u.removeEventListener("keydown",e),f&&u.removeEventListener("mousedown",n),d.forEach((e=>e.removeEventListener("scroll",t)))}}),[s,f,i,p,l,r,g,y,v,a,m,b,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),u(!1))}}}:{}},$=function(n,t){let{open:r,onOpenChange:o,dataRef:u,refs:c,events:i}=n,{enabled:l=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const s=e.useRef(""),f=e.useRef(!1);return e.useEffect((()=>{var e;if(!l)return;const n=null!=(e=L(c.floating.current).defaultView)?e:window;function t(){s.current&&(f.current=!r)}function o(){setTimeout((()=>{f.current=!1,s.current=""}))}return n.addEventListener("focus",o),n.addEventListener("blur",t),()=>{n.removeEventListener("focus",o),n.removeEventListener("blur",t)}}),[c.floating,r,l]),e.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){f.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:n}=e;s.current=n,f.current=!(!n||!a)},onFocus(e){var n,t,r;f.current||"focus"===e.type&&"mousedown"===(null==(n=u.current.openEvent)?void 0:n.type)&&I(c.reference.current)&&null!=(t=c.reference.current)&&t.contains(null==(r=u.current.openEvent)?void 0:r.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n;const t=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(t)||I(c.reference.current)&&c.reference.current.contains(t)||(f.current=!1,o(!1))}}}:{}};function _(e){const n=r();return l((()=>{n.current=e}),[e]),n.current}function ee(e,n){let{startingIndex:t=-1,decrement:r=!1,disabledIndices:o}=void 0===n?{}:n;const u=e.current;let c=t;do{var i,l;c+=r?-1:1}while(c>=0&&c<=u.length-1&&(o?o.includes(c):null==u[c]||(null==(i=u[c])?void 0:i.hasAttribute("disabled"))||"true"===(null==(l=u[c])?void 0:l.getAttribute("aria-disabled"))));return c}function ne(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function te(e,n){return ne(n,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function re(e,n,t){return ne(n,"ArrowDown"===e,t?"ArrowLeft"===e:"ArrowRight"===e)||"Enter"===e||" "==e||""===e}function oe(e,n){return ee(e,{disabledIndices:n})}function ue(e,n){return ee(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:n})}const ce=function(n,t){let{open:r,onOpenChange:o,refs:u}=n,{listRef:c,activeIndex:i,onNavigate:a,enabled:s=!0,selectedIndex:f=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:p=!1,virtual:g=!1,focusItemOnOpen:y="auto",focusItemOnHover:w=!0,openOnArrowKeyDown:E=!0,disabledIndices:x=(E?void 0:[]),orientation:R="vertical"}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const k=b(),I=h(),C=_(r),A=e.useRef(y),O=e.useRef(null!=f?f:-1),M=e.useRef(null),D=N(_(a)),P=N(a),S=N(x),F=e.useRef(!1),B=e.useRef(-1),[V,U]=e.useState(),H=e.useCallback(((e,n)=>{B.current=requestAnimationFrame((()=>{var t,r;g?U(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}))}),[g]);function X(e){if(F.current=!0,m&&function(e,n,t){return ne(n,t?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(e.key,R,p))return j(e),o(!1),void(T(u.reference.current)&&u.reference.current.focus());const n=O.current,t=oe(c,x),i=ue(c,x);if("Home"===e.key&&(O.current=t,a(O.current)),"End"===e.key&&(O.current=i,a(O.current)),te(e.key,R)){if(j(e),r&&!g&&K(e.currentTarget.ownerDocument)===e.currentTarget)return O.current=re(e.key,R,p)?t:i,void a(O.current);re(e.key,R,p)?O.current=v?n>=i?d&&n!==c.current.length?-1:t:ee(c,{startingIndex:n,disabledIndices:x}):Math.min(i,ee(c,{startingIndex:n,disabledIndices:x})):O.current=v?n<=t?d&&-1!==n?c.current.length:i:ee(c,{startingIndex:n,decrement:!0,disabledIndices:x}):Math.max(t,ee(c,{startingIndex:n,decrement:!0,disabledIndices:x})),a(O.current)}}return l((()=>{s&&(!C&&r&&A.current&&null!=f&&P.current(f),C&&!r&&(cancelAnimationFrame(B.current),O.current=-1,null==D.current||D.current(null)))}),[r,C,f,c,P,D,H,s]),l((()=>{if(s&&r)if(null==i){if(null!=f)return;C&&(O.current=-1,H(c,O)),!C&&A.current&&(null!=M.current||!0===A.current&&null==M.current)&&(O.current=null==M.current||re(M.current,R,p)||m?oe(c,S.current):ue(c,S.current),P.current(O.current),H(c,O))}else i>=0&&i<c.current.length&&(O.current=i,H(c,O))}),[r,C,i,f,m,c,P,H,s,d,R,p,g,S]),l((()=>{s&&!r&&C&&null!=f&&T(u.reference.current)&&u.reference.current.focus()}),[u.reference,f,r,C,s]),l((()=>{if(s&&!r&&C){var e,n;const t=null==I||null==(e=I.nodesRef.current.find((e=>e.id===k)))||null==(n=e.context)?void 0:n.refs.floating.current;t&&!t.contains(K(L(t)))&&t.focus({preventScroll:!0})}}),[s,r,C,I,k]),l((()=>{M.current=null})),s?{reference:{...g&&r&&null!=i&&{"aria-activedescendant":V},onKeyDown(e){if(F.current=!0,g&&r)return X(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(M.current=e.key),m?function(e,n,t){return ne(n,t?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(e.key,R,p)&&(j(e),r?(O.current=oe(c,x),a(O.current)):o(!0)):te(e.key,R)&&(null!=f&&(O.current=f),j(e),!r&&E?o(!0):X(e),r&&a(O.current))}},floating:{"aria-orientation":"both"===R?void 0:R,...g&&null!=i&&{"aria-activedescendant":V},onKeyDown:X,onPointerMove(){F.current=!1}},item:{onFocus(e){let{currentTarget:n}=e;const t=c.current.indexOf(n);-1!==t&&a(t)},onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...w&&{onMouseMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=c.current.indexOf(t);-1!==e&&a(e)}},onMouseLeave(){var e;F.current||(O.current=-1,H(c,O),P.current(null),g||null==(e=u.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},ie=function(n,t){var r;let{open:o,dataRef:u}=n,{listRef:c,activeIndex:i,onMatch:a=(()=>{}),enabled:s=!0,findMatch:f=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const p=e.useRef(),g=e.useRef(""),b=e.useRef(null!=(r=null!=m?m:i)?r:-1),h=e.useRef(null);function y(e){if(!e.currentTarget.contains(K(L(e.currentTarget))))return;g.current.length>0&&" "!==g.current[0]&&(u.current.typing=!0," "===e.key&&j(e));const n=c.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...v].includes(e.key))return;n.every((e=>{var n,t;return!e||(null==(n=e[0])?void 0:n.toLocaleLowerCase())!==(null==(t=e[1])?void 0:t.toLocaleLowerCase())}))&&g.current===e.key&&(g.current="",b.current=h.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",b.current=h.current,u.current.typing=!1}),d);const t=b.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],o=f?f(r,g.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current)))),i=o?n.indexOf(o):-1;-1!==i&&(a(i),h.current=i)}return l((()=>{o&&(clearTimeout(p.current),h.current=null,g.current="")}),[o]),l((()=>{var e;o&&""===g.current&&(b.current=null!=(e=null!=m?m:i)?e:-1)}),[o,m,i]),s?{reference:{onKeyDown:y},floating:{onKeyDown:y}}:{}};function le(n){let{open:t=!1,onOpenChange:r=(()=>{}),whileElementsMounted:o,placement:c,middleware:i,strategy:s,nodeId:f}=void 0===n?{}:n;const d=h(),v=e.useRef({}),m=e.useState((()=>a()))[0],p=u({placement:c,middleware:i,strategy:s,whileElementsMounted:o}),g=e.useMemo((()=>({...p,dataRef:v,nodeId:f,events:m,open:t,onOpenChange:r})),[p,v,f,m,t,r]);return l((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===f));e&&(e.context=g)})),e.useMemo((()=>({context:g,...p})),[p,g])}export{W as FloatingDelayGroup,U as FloatingFocusManager,w as FloatingNode,F as FloatingOverlay,D as FloatingPortal,E as FloatingTree,A as safePolygon,J as useClick,z as useDelayGroup,q as useDelayGroupContext,Z as useDismiss,le as useFloating,y as useFloatingNodeId,b as useFloatingParentNodeId,M as useFloatingPortalNode,h as useFloatingTree,$ as useFocus,X as useHover,m as useId,R as useInteractions,ce as useListNavigation,G as useRole,ie as useTypeahead}; | ||
import{useFloating as e,getOverflowAncestors as n}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import*as t from"react";import{useLayoutEffect as r,useEffect as o,useRef as u}from"react";import{createPortal as c}from"react-dom";import{hideOthers as i}from"aria-hidden";var l="undefined"!=typeof document?r:o;function a(){const e=new Map;return{emit(n,t){var r;null==(r=e.get(n))||r.forEach((e=>e(t)))},on(n,t){e.set(n,[...e.get(n)||[],t])},off(n,t){e.set(n,(e.get(n)||[]).filter((e=>e!==t)))}}}let s=!1,f=0;const d=()=>"floating-ui-"+f++;const v=t["useId".toString()],m=null!=v?v:function(){const[e,n]=t.useState((()=>s?d():void 0));return l((()=>{null==e&&n(d())}),[]),t.useEffect((()=>{s||(s=!0)}),[]),e},p=t.createContext(null),g=t.createContext(null),b=()=>{var e,n;return null!=(e=null==(n=t.useContext(p))?void 0:n.id)?e:null},h=()=>t.useContext(g),y=()=>{const e=m(),n=h(),t=b();return l((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},w=e=>{let{children:n,id:r}=e;const o=b();return t.createElement(p.Provider,{value:t.useMemo((()=>({id:r,parentId:o})),[r,o])},n)},E=e=>{let{children:n}=e;const r=t.useRef([]),o=t.useCallback((e=>{r.current=[...r.current,e]}),[]),u=t.useCallback((e=>{r.current=r.current.filter((n=>n!==e))}),[]),c=t.useState((()=>a()))[0];return t.createElement(g.Provider,{value:t.useMemo((()=>({nodesRef:r,addNode:o,removeNode:u,events:c})),[r,o,u,c])},n)};function x(n){let{open:r=!1,onOpenChange:o=(()=>{}),whileElementsMounted:u,placement:c,middleware:i,strategy:s,nodeId:f}=void 0===n?{}:n;const d=h(),v=t.useRef({}),m=t.useState((()=>a()))[0],p=e({placement:c,middleware:i,strategy:s,whileElementsMounted:u}),g=t.useMemo((()=>({...p,dataRef:v,nodeId:f,events:m,open:r,onOpenChange:o})),[p,v,f,m,r,o]);return l((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===f));e&&(e.context=g)})),t.useMemo((()=>({context:g,...p})),[p,g])}function R(e,n,t){const r={};return{..."floating"===t&&{tabIndex:-1},...e,...n.map((e=>e?e[t]:null)).concat(e).reduce(((e,n)=>n?(Object.entries(n).forEach((n=>{let[t,o]=n;0===t.indexOf("on")?(r[t]||(r[t]=[]),"function"==typeof o&&r[t].push(o),e[t]=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];r[t].forEach((e=>e(...n)))}):e[t]=o})),e):e),{})}}const k=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>R(n,e,"reference"),getFloatingProps:n=>R(n,e,"floating"),getItemProps:n=>R(n,e,"item")}};function L(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function I(e){var n;return null!=(n=L(e).defaultView)?n:window}function T(e){return!!e&&e instanceof I(e).Element}function C(e){return!!e&&e instanceof I(e).HTMLElement}function A(e,n){var t;let r=null!=(t=null==e?void 0:e.nodesRef.current.filter((e=>{var t;return e.parentId===n&&(null==(t=e.context)?void 0:t.open)})))?t:[],o=r;for(;o.length;){var u;o=null!=(u=null==e?void 0:e.nodesRef.current.filter((e=>{var n;return null==(n=o)?void 0:n.some((n=>{var t;return e.parentId===n.id&&(null==(t=e.context)?void 0:t.open)}))})))?u:[],r=r.concat(o)}return r}function O(e){let n,{restMs:t=0,buffer:r=.5,debug:o=null}=void 0===e?{}:e,u=!1;return e=>{let{x:o,y:c,placement:i,refs:l,onClose:a,nodeId:s,tree:f,leave:d=!1}=e;return function(e){var v;function m(){clearTimeout(n),a()}if(clearTimeout(n),e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:p,clientY:g}=e,b="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&T(l.reference.current)&&l.reference.current.contains(b))return;if(f&&A(f,s).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(null!=(v=l.floating.current)&&v.contains(b)&&!d)return void(u=!0);if(!l.reference.current||!l.floating.current||null==i||null==o||null==c)return;const h=l.reference.current.getBoundingClientRect(),y=l.floating.current.getBoundingClientRect(),w=i.split("-")[0],E=o>y.right-y.width/2,x=c>y.bottom-y.height/2;if("top"===w&&c>=h.bottom-1||"bottom"===w&&c<=h.top+1||"left"===w&&o>=h.right-1||"right"===w&&o<=h.left+1)return m();switch(w){case"top":if(p>=y.left&&p<=y.right&&g>=y.top&&g<=h.top+1)return;break;case"bottom":if(p>=y.left&&p<=y.right&&g>=h.bottom-1&&g<=y.bottom)return;break;case"left":if(p>=y.left&&p<=h.left+1&&g>=y.top&&g<=y.bottom)return;break;case"right":if(p>=h.right-1&&p<=y.right&&g>=y.top&&g<=y.bottom)return}if(u)return m();const R=function(e){let[n,t]=e;const o=y.width>h.width,u=y.height>h.height;switch(w){case"top":return[[o?n+r/2:E?n+4*r:n-4*r,t+r+1],[o?n-r/2:E?n+4*r:n-4*r,t+r+1],...[[y.left,E||o?y.bottom-r:y.top],[y.right,E?o?y.bottom-r:y.top:y.bottom-r]]];case"bottom":return[[o?n+r/2:E?n+4*r:n-4*r,t-r],[o?n-r/2:E?n+4*r:n-4*r,t-r],...[[y.left,E||o?y.top+r:y.bottom],[y.right,E?o?y.top+r:y.bottom:y.top+r]]];case"left":{const e=[n+r+1,u?t+r/2:x?t+4*r:t-4*r],o=[n+r+1,u?t-r/2:x?t+4*r:t-4*r];return[...[[x||u?y.right-r:y.left,y.top],[x?u?y.right-r:y.left:y.right-r,y.bottom]],e,o]}case"right":return[[n-r,u?t+r/2:x?t+4*r:t-4*r],[n-r,u?t-r/2:x?t+4*r:t-4*r],...[[x||u?y.left+r:y.right,y.top],[x?u?y.left+r:y.right:y.left+r,y.bottom]]]}}([o,c]);!function(e,n){const[t,r]=e;let o=!1;const u=n.length;for(let e=0,c=u-1;e<u;c=e++){const[u,i]=n[e]||[0,0],[l,a]=n[c]||[0,0];i>=r!=a>=r&&t<=(l-u)*(r-i)/(a-i)+u&&(o=!o)}return o}([p,g],R)?m():t&&(n=setTimeout(a,t))}}}const M="floating-ui-root",D=function(e){let{id:n=M,enabled:r=!0}=void 0===e?{}:e;const o=t.useRef(null);return l((()=>{if(!r)return;const e=document.getElementById(n);e?o.current=e:(o.current=document.createElement("div"),o.current.id=n),document.body.contains(o.current)||document.body.appendChild(o.current)}),[n,r]),o.current},P=e=>{let{children:n,id:r=M,root:o=null}=e;const[u,i]=t.useState(!1),a=D({id:r,enabled:!o});return l((()=>{o||i(!0)}),[o]),o?c(n,o):u&&a?c(n,a):null};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)}const F="data-floating-ui-scroll-lock";const K=t.forwardRef((function(e,n){let{lockScroll:r=!1,...o}=e;return l((()=>{var e,n,t,o;if(!r)return;if(document.body.hasAttribute(F))return;document.body.setAttribute(F,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(function(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(F),Object.assign(document.body.style,{overflow:"",[u]:""})};const i=null!=(e=null==(n=window.visualViewport)?void 0:n.offsetLeft)?e:0,l=null!=(t=null==(o=window.visualViewport)?void 0:o.offsetTop)?t:0,a=window.pageXOffset,s=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(s-Math.floor(l))+"px",left:-(a-Math.floor(i))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(F),window.scrollTo(a,s)}}),[r]),t.createElement("div",S({ref:n},o,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...o.style}}))}));function N(e){let n=e.activeElement;for(;null!=(null==(t=n)||null==(r=t.shadowRoot)?void 0:r.activeElement);){var t,r;n=n.shadowRoot.activeElement}return n}function j(e){e.preventDefault(),e.stopPropagation()}function B(e){const n=u(e);return l((()=>{n.current=e})),n}function U(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const V=t.forwardRef((function(e,n){return t.createElement("span",S({},e,{ref:n,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function H(e){let{context:{refs:n,nodeId:r,onOpenChange:o},children:u,order:c=["content"],endGuard:l=!0,preventTabbing:a=!1,initialFocus:s=0,returnFocus:f=!0,modal:d=!0}=e;const v=B(c),m=B(o),p=h(),g=t.useCallback((()=>v.current.map((e=>{return C(n.reference.current)&&"reference"===e?n.reference.current:n.floating.current&&"floating"===e?n.floating.current:"content"===e?Array.from(null!=(t=null==(r=n.floating.current)?void 0:r.querySelectorAll("input:not([type='hidden']):not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],[contenteditable]:not([contenteditable='false'])"))?t:[]):null;var t,r})).flat().filter((e=>{if(e===n.floating.current||e===n.reference.current)return!0;if(C(e)){var t;return"-"!==(null!=(t=e.getAttribute("tabindex"))?t:"0")[0].trim()}}))),[v,n.floating,n.reference]),b=t.useCallback((()=>C(n.reference.current)&&"combobox"===n.reference.current.getAttribute("role")&&"INPUT"===n.reference.current.tagName),[n]);return t.useEffect((()=>{if(!d)return;const e=0===g().filter((e=>e!==n.floating.current&&e!==n.reference.current)).length;function t(t){if("Tab"===t.key){(a||e)&&j(t);const r=g(),o="composedPath"in t?t.composedPath()[0]:t.target;"reference"===v.current[0]&&o===n.reference.current&&(j(t),t.shiftKey?U(r[r.length-1]):U(r[1])),"floating"===v.current[1]&&o===n.floating.current&&t.shiftKey&&(j(t),U(r[0]))}}const r=L(n.floating.current);return r.addEventListener("keydown",t),()=>{r.removeEventListener("keydown",t)}}),[a,d,g,v,n.floating,n.reference]),t.useEffect((()=>{function e(e){var t;const o=e.relatedTarget;null!=(t=n.floating.current)&&t.contains(o)||!T(n.reference.current)||n.reference.current.contains(o)||p&&A(p,r).some((e=>{let{context:n}=e;return null==n?void 0:n.open}))||p&&A(p,r).some((e=>{var n,t;return null==(n=e.context)||null==(t=n.refs.floating.current)?void 0:t.contains(o)}))||m.current(!1)}const t=n.floating.current,o=n.reference.current;if(t&&C(o)){let n;return!d&&t.addEventListener("focusout",e),d&&(n=v.current.includes("reference")?i([o,t]):i(t)),()=>{!d&&t.removeEventListener("focusout",e),null==n||n()}}}),[r,p,d,m,v,g,s,n.floating,n.reference]),t.useEffect((()=>{if(a)return;const e=n.floating.current,t=N(L(e));var r;if("number"==typeof s)U(null!=(r=g()[s])?r:e);else if(C(null==s?void 0:s.current)){var o;U(null!=(o=s.current)?o:e)}return()=>{f&&C(t)&&U(t)}}),[a,g,s,d,f,n.floating]),t.createElement(t.Fragment,null,d&&t.createElement(V,{onFocus:e=>{if(b())return;j(e);const n=g();"reference"===c[0]?U(n[0]):U(n[n.length-1])}}),t.cloneElement(u,c.includes("floating")?{tabIndex:0}:{}),d&&l&&t.createElement(V,{onFocus:e=>{b()||(j(e),U(g()[0]))}}))}function X(e,n,t){return t&&"mouse"!==t?0:"number"==typeof e?e:null==e?void 0:e[n]}const Y=function(e,n){let{enabled:r=!0,delay:o=0,handleClose:u=null,mouseOnly:c=!1,restMs:i=0}=void 0===n?{}:n;const{open:a,onOpenChange:s,dataRef:f,events:d,refs:v}=e,m=h(),p=B(s),g=B(u),b=t.useRef(),y=t.useRef(),w=t.useRef(),E=t.useRef(),x=t.useRef(!0);t.useEffect((()=>{if(r)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(y.current),clearTimeout(E.current),x.current=!0}}),[r,d,v.floating]),t.useEffect((()=>{if(!r||!g.current)return;function e(){var e;null!=(e=f.current.openEvent)&&e.type.includes("mouse")&&p.current(!1)}const n=L(v.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[v.floating,p,r,g,f]);const R=t.useCallback((function(e){void 0===e&&(e=!0);const n=X(o,"close",b.current);n&&!w.current?(clearTimeout(y.current),y.current=setTimeout((()=>p.current(!1)),n)):e&&p.current(!1)}),[o,p]),k=t.useCallback((()=>{w.current&&(L(v.floating.current).removeEventListener("pointermove",w.current),w.current=void 0)}),[v.floating]);if(t.useEffect((()=>{if(!r)return;function n(e){if(clearTimeout(y.current),x.current=!1,a||c&&"mouse"!==b.current||i>0&&0===X(o,"open"))return;f.current.openEvent=e;const n=X(o,"open",b.current);n?y.current=setTimeout((()=>{p.current(!0)}),n):p.current(!0)}function t(n){var t,r;if("click"===(null==(t=f.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=f.current.openEvent)?void 0:r.type))return;const o=L(v.floating.current);if(clearTimeout(E.current),g.current)return clearTimeout(y.current),w.current&&o.removeEventListener("pointermove",w.current),w.current=g.current({...e,tree:m,x:n.clientX,y:n.clientY,onClose(){k(),R()}}),void o.addEventListener("pointermove",w.current);R()}function u(n){null==g.current||g.current({...e,tree:m,x:n.clientX,y:n.clientY,leave:!0,onClose(){k(),R()}})(n)}const l=v.floating.current,s=v.reference.current;return T(s)?(a&&s.addEventListener("pointerleave",u),null==l||l.addEventListener("pointerleave",u),s.addEventListener("mousemove",n,{once:!0}),s.addEventListener("mouseenter",n),s.addEventListener("mouseleave",t),()=>{a&&s.removeEventListener("pointerleave",u),null==l||l.removeEventListener("pointerleave",u),s.removeEventListener("mousemove",n),s.removeEventListener("mouseenter",n),s.removeEventListener("mouseleave",t)}):void 0}),[r,R,e,o,g,f,c,p,a,m,i,k,v.reference,v.floating]),l((()=>{a||(b.current=void 0,k())})),t.useEffect((()=>()=>{k(),clearTimeout(y.current),clearTimeout(E.current)}),[k]),!r)return{};function I(e){b.current=e.pointerType}return{reference:{onPointerDown:I,onPointerEnter:I,onMouseMove(){a||0===i||(clearTimeout(E.current),E.current=setTimeout((()=>{x.current||s(!0)}),i))}},floating:{onMouseEnter(){clearTimeout(y.current)},onMouseLeave(){R(!1)}}}},q=t.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),W=()=>t.useContext(q),z=e=>{let{children:n,delay:r}=e;const[o,u]=t.useState({delay:r,initialDelay:r,currentId:null}),c=t.useCallback((e=>{u((n=>({...n,currentId:e})))}),[]);return t.createElement(q.Provider,{value:t.useMemo((()=>({...o,setState:u,setCurrentId:c})),[o,u,c])},n)},G=(e,n)=>{let{open:r,onOpenChange:o}=e,{id:u}=n;const{currentId:c,initialDelay:i,setState:l}=W(),a=B(o);t.useEffect((()=>{c&&a.current&&(l((e=>({...e,delay:{open:1,close:X(i,"close")}}))),c!==u&&a.current(!1))}),[u,a,l,c,i]),t.useEffect((()=>{!r&&c===u&&a.current&&(a.current(!1),l((e=>({...e,delay:i,currentId:null}))))}),[r,l,c,u,a,i])},J=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=m(),c=m(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?u:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},Q=function(e,n){let{open:r,onOpenChange:o,dataRef:u,refs:c}=e,{enabled:i=!0,pointerDown:l=!1,toggle:a=!0,ignoreMouse:s=!1}=void 0===n?{}:n;const f=t.useRef();function d(){return C(c.reference.current)&&"BUTTON"===c.reference.current.tagName}return i?{reference:{onPointerDown(e){if(f.current=e.pointerType,("mouse"!==f.current||!s)&&l){var n;if(r)a&&"pointerdown"===(null==(n=u.current.openEvent)?void 0:n.type)&&o(!1);else o(!0);u.current.openEvent=e.nativeEvent}},onClick(e){if(l&&f.current)f.current=void 0;else if("mouse"!==f.current||!s){var n;if(r)a&&"click"===(null==(n=u.current.openEvent)?void 0:n.type)&&o(!1);else o(!0);u.current.openEvent=e.nativeEvent}},onKeyDown(e){f.current=void 0,d()||(" "===e.key&&e.preventDefault(),"Enter"===e.key&&(r?a&&o(!1):o(!0)))},onKeyUp(e){d()||" "===e.key&&(r?a&&o(!1):o(!0))}}}:{}};function Z(e,n){if(null==n)return!1;if("composedPath"in e)return e.composedPath().includes(n);const t=e;return null!=t.target&&n.contains(t.target)}const $=function(e,r){let{open:o,onOpenChange:u,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:s=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===r?{}:r;const p=h(),g=B(u),b=t.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(N(L(c.floating.current)))}),[c.floating]),y=t.useCallback((()=>{C(c.reference.current)&&c.reference.current.focus()}),[c.reference]);return t.useEffect((()=>{if(!o||!a)return;function e(e){if("Escape"===e.key){if(!m&&!b())return;i.emit("dismiss"),g.current(!1),y()}}function t(e){const n=p&&A(p,l).some((n=>{var t;return Z(e,null==(t=n.context)?void 0:t.refs.floating.current)}));Z(e,c.floating.current)||T(c.reference.current)&&Z(e,c.reference.current)||n||(m||b())&&(i.emit("dismiss"),g.current(!1),y())}function r(){g.current(!1)}const u=L(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("mousedown",t);const d=(v?[...T(c.reference.current)?n(c.reference.current):[],...T(c.floating.current)?n(c.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=u.defaultView)?void 0:n.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{s&&u.removeEventListener("keydown",e),f&&u.removeEventListener("mousedown",t),d.forEach((e=>e.removeEventListener("scroll",r)))}}),[s,f,i,p,l,o,g,y,v,a,m,b,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),u(!1))}}}:{}},_=function(e,n){let{open:r,onOpenChange:o,dataRef:u,refs:c,events:i}=e,{enabled:l=!0,keyboardOnly:a=!0}=void 0===n?{}:n;const s=t.useRef(""),f=t.useRef(!1);return t.useEffect((()=>{var e;if(!l)return;const n=null!=(e=L(c.floating.current).defaultView)?e:window;function t(){s.current&&(f.current=!r)}function o(){setTimeout((()=>{f.current=!1,s.current=""}))}return n.addEventListener("focus",o),n.addEventListener("blur",t),()=>{n.removeEventListener("focus",o),n.removeEventListener("blur",t)}}),[c.floating,r,l]),t.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){f.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:n}=e;s.current=n,f.current=!(!n||!a)},onFocus(e){var n,t,r;f.current||"focus"===e.type&&"mousedown"===(null==(n=u.current.openEvent)?void 0:n.type)&&T(c.reference.current)&&null!=(t=c.reference.current)&&t.contains(null==(r=u.current.openEvent)?void 0:r.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n;const t=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(t)||T(c.reference.current)&&c.reference.current.contains(t)||(f.current=!1,o(!1))}}}:{}};function ee(e){const n=u();return l((()=>{n.current=e}),[e]),n.current}function ne(e,n){return n<0||n>=e.current.length}function te(e,n){let{startingIndex:t=-1,decrement:r=!1,disabledIndices:o}=void 0===n?{}:n;const u=e.current;let c=t;do{var i,l;c+=r?-1:1}while(c>=0&&c<=u.length-1&&(o?o.includes(c):null==u[c]||(null==(i=u[c])?void 0:i.hasAttribute("disabled"))||"true"===(null==(l=u[c])?void 0:l.getAttribute("aria-disabled"))));return c}function re(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function oe(e,n){return re(n,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function ue(e,n,t){return re(n,"ArrowDown"===e,t?"ArrowLeft"===e:"ArrowRight"===e)||"Enter"===e||" "==e||""===e}function ce(e,n){return te(e,{disabledIndices:n})}function ie(e,n){return te(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:n})}const le=function(e,n){let{open:r,onOpenChange:o,refs:u}=e,{listRef:c,activeIndex:i,onNavigate:a,enabled:s=!0,selectedIndex:f=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:p=!1,virtual:g=!1,focusItemOnOpen:y="auto",focusItemOnHover:w=!0,openOnArrowKeyDown:E=!0,disabledIndices:x=(E?void 0:[]),orientation:R="vertical"}=void 0===n?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:n;const k=b(),I=h(),T=ee(r),A=t.useRef(y),O=t.useRef(null!=f?f:-1),M=t.useRef(null),D=B(ee(a)),P=B(a),S=B(x),F=t.useRef(!1),K=t.useRef(-1),[U,V]=t.useState(),H=t.useCallback(((e,n)=>{K.current=requestAnimationFrame((()=>{var t,r;g?V(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}))}),[g]);function X(e){if(F.current=!0,m&&function(e,n,t){return re(n,t?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(e.key,R,p))return j(e),o(!1),void(C(u.reference.current)&&u.reference.current.focus());const n=O.current,t=ce(c,x),i=ie(c,x);if("Home"===e.key&&(O.current=t,a(O.current)),"End"===e.key&&(O.current=i,a(O.current)),oe(e.key,R)){if(j(e),r&&!g&&N(e.currentTarget.ownerDocument)===e.currentTarget)return O.current=ue(e.key,R,p)?t:i,void a(O.current);ue(e.key,R,p)?O.current=v?n>=i?d&&n!==c.current.length?-1:t:te(c,{startingIndex:n,disabledIndices:x}):Math.min(i,te(c,{startingIndex:n,disabledIndices:x})):O.current=v?n<=t?d&&-1!==n?c.current.length:i:te(c,{startingIndex:n,decrement:!0,disabledIndices:x}):Math.max(t,te(c,{startingIndex:n,decrement:!0,disabledIndices:x})),ne(c,O.current)?a(null):a(O.current)}}return l((()=>{s&&(!T&&r&&A.current&&null!=f&&P.current(f),T&&!r&&(cancelAnimationFrame(K.current),O.current=-1,null==D.current||D.current(null)))}),[r,T,f,c,P,D,H,s]),l((()=>{if(s&&r)if(null==i){if(null!=f)return;T&&(O.current=-1,H(c,O)),!T&&A.current&&(null!=M.current||!0===A.current&&null==M.current)&&(O.current=null==M.current||ue(M.current,R,p)||m?ce(c,S.current):ie(c,S.current),P.current(O.current),H(c,O))}else ne(c,i)||(O.current=i,H(c,O))}),[r,T,i,f,m,c,P,H,s,d,R,p,g,S]),l((()=>{s&&!r&&T&&null!=f&&C(u.reference.current)&&u.reference.current.focus()}),[u.reference,f,r,T,s]),l((()=>{if(s&&!r&&T){var e,n;const t=null==I||null==(e=I.nodesRef.current.find((e=>e.id===k)))||null==(n=e.context)?void 0:n.refs.floating.current;t&&!t.contains(N(L(t)))&&t.focus({preventScroll:!0})}}),[s,r,T,I,k]),l((()=>{M.current=null})),s?{reference:{...g&&r&&null!=i&&{"aria-activedescendant":U},onKeyDown(e){if(F.current=!0,g&&r)return X(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(M.current=e.key),m?function(e,n,t){return re(n,t?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(e.key,R,p)&&(j(e),r?(O.current=ce(c,x),a(O.current)):o(!0)):oe(e.key,R)&&(null!=f&&(O.current=f),j(e),!r&&E?o(!0):X(e),r&&a(O.current))}},floating:{"aria-orientation":"both"===R?void 0:R,...g&&null!=i&&{"aria-activedescendant":U},onKeyDown:X,onPointerMove(){F.current=!1}},item:{onFocus(e){let{currentTarget:n}=e;const t=c.current.indexOf(n);-1!==t&&a(t)},onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...w&&{onMouseMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=c.current.indexOf(t);-1!==e&&a(e)}},onMouseLeave(){var e;F.current||(O.current=-1,H(c,O),P.current(null),g||null==(e=u.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},ae=function(e,n){var r;let{open:o,dataRef:u}=e,{listRef:c,activeIndex:i,onMatch:a=(()=>{}),enabled:s=!0,findMatch:f=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===n?{listRef:{current:[]},activeIndex:null}:n;const p=t.useRef(),g=t.useRef(""),b=t.useRef(null!=(r=null!=m?m:i)?r:-1),h=t.useRef(null);function y(e){if(!e.currentTarget.contains(N(L(e.currentTarget))))return;g.current.length>0&&" "!==g.current[0]&&(u.current.typing=!0," "===e.key&&j(e));const n=c.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...v].includes(e.key))return;n.every((e=>{var n,t;return!e||(null==(n=e[0])?void 0:n.toLocaleLowerCase())!==(null==(t=e[1])?void 0:t.toLocaleLowerCase())}))&&g.current===e.key&&(g.current="",b.current=h.current),g.current+=e.key,clearTimeout(p.current),p.current=setTimeout((()=>{g.current="",b.current=h.current,u.current.typing=!1}),d);const t=b.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],o=f?f(r,g.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(g.current)))),i=o?n.indexOf(o):-1;-1!==i&&(a(i),h.current=i)}return l((()=>{o&&(clearTimeout(p.current),h.current=null,g.current="")}),[o]),l((()=>{var e;o&&""===g.current&&(b.current=null!=(e=null!=m?m:i)?e:-1)}),[o,m,i]),s?{reference:{onKeyDown:y},floating:{onKeyDown:y}}:{}};export{z as FloatingDelayGroup,H as FloatingFocusManager,w as FloatingNode,K as FloatingOverlay,P as FloatingPortal,E as FloatingTree,O as safePolygon,Q as useClick,G as useDelayGroup,W as useDelayGroupContext,$ as useDismiss,x as useFloating,y as useFloatingNodeId,b as useFloatingParentNodeId,D as useFloatingPortalNode,h as useFloatingTree,_ as useFocus,Y as useHover,m as useId,k as useInteractions,le as useListNavigation,J as useRole,ae as useTypeahead}; |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("@floating-ui/react-dom"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","@floating-ui/react-dom","react-dom"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.React,e.FloatingUIReactDOM,e.ReactDOM)}(this,(function(e,n,t,r){"use strict";function o(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var u=o(n),c="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;function i(){const e=new Map;return{emit(n,t){var r;null==(r=e.get(n))||r.forEach((e=>e(t)))},on(n,t){e.set(n,[...e.get(n)||[],t])},off(n,t){e.set(n,(e.get(n)||[]).filter((e=>e!==t)))}}}let l=!1,a=0;const s=()=>"floating-ui-"+a++;const f=u["useId".toString()],d=null!=f?f:function(){const[e,n]=u.useState((()=>l?s():void 0));return c((()=>{null==e&&n(s())}),[]),u.useEffect((()=>{l||(l=!0)}),[]),e},v=u.createContext(null),m=u.createContext(null),g=()=>{var e,n;return null!=(e=null==(n=u.useContext(v))?void 0:n.id)?e:null},p=()=>u.useContext(m);function y(e,n,t){const r={};return{..."floating"===t&&{tabIndex:-1},...e,...n.map((e=>e?e[t]:null)).concat(e).reduce(((e,n)=>n?(Object.entries(n).forEach((n=>{let[t,o]=n;0===t.indexOf("on")?(r[t]||(r[t]=[]),"function"==typeof o&&r[t].push(o),e[t]=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];r[t].forEach((e=>e(...n)))}):e[t]=o})),e):e),{})}}function b(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function h(e){var n;return null!=(n=b(e).defaultView)?n:window}function E(e){return!!e&&e instanceof h(e).Element}function w(e){return!!e&&e instanceof h(e).HTMLElement}function x(e,n){var t;let r=null!=(t=null==e?void 0:e.nodesRef.current.filter((e=>{var t;return e.parentId===n&&(null==(t=e.context)?void 0:t.open)})))?t:[],o=r;for(;o.length;){var u;o=null!=(u=null==e?void 0:e.nodesRef.current.filter((e=>{var n;return null==(n=o)?void 0:n.some((n=>{var t;return e.parentId===n.id&&(null==(t=e.context)?void 0:t.open)}))})))?u:[],r=r.concat(o)}return r}const k="floating-ui-root",R=function(e){let{id:n=k,enabled:t=!0}=void 0===e?{}:e;const r=u.useRef(null);return c((()=>{if(!t)return;const e=document.getElementById(n);e?r.current=e:(r.current=document.createElement("div"),r.current.id=n),document.body.contains(r.current)||document.body.appendChild(r.current)}),[n,t]),r.current};function I(){return I=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},I.apply(this,arguments)}const O="data-floating-ui-scroll-lock";const L=u.forwardRef((function(e,n){let{lockScroll:t=!1,...r}=e;return c((()=>{var e,n,r,o;if(!t)return;if(document.body.hasAttribute(O))return;document.body.setAttribute(O,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(function(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(O),Object.assign(document.body.style,{overflow:"",[u]:""})};const i=null!=(e=null==(n=window.visualViewport)?void 0:n.offsetLeft)?e:0,l=null!=(r=null==(o=window.visualViewport)?void 0:o.offsetTop)?r:0,a=window.pageXOffset,s=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(s-Math.floor(l))+"px",left:-(a-Math.floor(i))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(O),window.scrollTo(a,s)}}),[t]),u.createElement("div",I({ref:n},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var T=new WeakMap,C=new WeakMap,M={},A=0,P=function(e,n,t){void 0===n&&(n=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e)),void 0===t&&(t="data-aria-hidden");var r=Array.isArray(e)?e:[e];M[t]||(M[t]=new WeakMap);var o=M[t],u=[],c=new Set,i=function(e){e&&!c.has(e)&&(c.add(e),i(e.parentNode))};r.forEach(i);var l=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(c.has(e))l(e);else{var n=e.getAttribute("aria-hidden"),r=null!==n&&"false"!==n,i=(T.get(e)||0)+1,a=(o.get(e)||0)+1;T.set(e,i),o.set(e,a),u.push(e),1===i&&r&&C.set(e,!0),1===a&&e.setAttribute(t,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(n),c.clear(),A++,function(){u.forEach((function(e){var n=T.get(e)-1,r=o.get(e)-1;T.set(e,n),o.set(e,r),n||(C.has(e)||e.removeAttribute("aria-hidden"),C.delete(e)),r||e.removeAttribute(t)})),--A||(T=new WeakMap,T=new WeakMap,C=new WeakMap,M={})}};function D(e){let n=e.activeElement;for(;null!=(null==(t=n)||null==(r=t.shadowRoot)?void 0:r.activeElement);){var t,r;n=n.shadowRoot.activeElement}return n}function F(e){e.preventDefault(),e.stopPropagation()}function S(e){const t=n.useRef(e);return c((()=>{t.current=e})),t}function j(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const N=u.forwardRef((function(e,n){return u.createElement("span",I({},e,{ref:n,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function K(e,n,t){return t&&"mouse"!==t?0:"number"==typeof e?e:null==e?void 0:e[n]}const W=u.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),q=()=>u.useContext(W);function B(e,n){if(null==n)return!1;if("composedPath"in e)return e.composedPath().includes(n);const t=e;return null!=t.target&&n.contains(t.target)}function U(e){const t=n.useRef();return c((()=>{t.current=e}),[e]),t.current}const V="ArrowUp",H="ArrowDown",G="ArrowLeft",X="ArrowRight";function Y(e,n){let{startingIndex:t=-1,decrement:r=!1,disabledIndices:o}=void 0===n?{}:n;const u=e.current;let c=t;do{var i,l;c+=r?-1:1}while(c>=0&&c<=u.length-1&&(o?o.includes(c):null==u[c]||(null==(i=u[c])?void 0:i.hasAttribute("disabled"))||"true"===(null==(l=u[c])?void 0:l.getAttribute("aria-disabled"))));return c}function _(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function z(e,n){return _(n,e===V||e===H,e===G||e===X)}function J(e,n,t){return _(n,e===H,t?e===G:e===X)||"Enter"===e||" "==e||""===e}function Q(e,n){return Y(e,{disabledIndices:n})}function Z(e,n){return Y(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:n})}e.FloatingDelayGroup=e=>{let{children:n,delay:t}=e;const[r,o]=u.useState({delay:t,initialDelay:t,currentId:null}),c=u.useCallback((e=>{o((n=>({...n,currentId:e})))}),[]);return u.createElement(W.Provider,{value:u.useMemo((()=>({...r,setState:o,setCurrentId:c})),[r,o,c])},n)},e.FloatingFocusManager=function(e){let{context:{refs:n,nodeId:t,onOpenChange:r},children:o,order:c=["content"],endGuard:i=!0,preventTabbing:l=!1,initialFocus:a=0,returnFocus:s=!0,modal:f=!0}=e;const d=S(c),v=S(r),m=p(),g=u.useCallback((()=>d.current.map((e=>{return w(n.reference.current)&&"reference"===e?n.reference.current:n.floating.current&&"floating"===e?n.floating.current:"content"===e?Array.from(null!=(t=null==(r=n.floating.current)?void 0:r.querySelectorAll("input:not([type='hidden']):not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],[contenteditable]:not([contenteditable='false'])"))?t:[]):null;var t,r})).flat().filter((e=>{if(e===n.floating.current||e===n.reference.current)return!0;if(w(e)){var t;return"-"!==(null!=(t=e.getAttribute("tabindex"))?t:"0")[0].trim()}}))),[d,n.floating,n.reference]);return u.useEffect((()=>{if(!f)return;const e=0===g().filter((e=>e!==n.floating.current&&e!==n.reference.current)).length;function t(t){if("Tab"===t.key){(l||e)&&F(t);const r=g(),o="composedPath"in t?t.composedPath()[0]:t.target;"reference"===d.current[0]&&o===n.reference.current&&(F(t),t.shiftKey?j(r[r.length-1]):j(r[1])),"floating"===d.current[1]&&o===n.floating.current&&t.shiftKey&&(F(t),j(r[0]))}}const r=b(n.floating.current);return r.addEventListener("keydown",t),()=>{r.removeEventListener("keydown",t)}}),[l,f,g,d,n.floating,n.reference]),u.useEffect((()=>{function e(e){var r;const o=e.relatedTarget;null!=(r=n.floating.current)&&r.contains(o)||!E(n.reference.current)||n.reference.current.contains(o)||m&&x(m,t).some((e=>{let{context:n}=e;return null==n?void 0:n.open}))||m&&x(m,t).some((e=>{var n,t;return null==(n=e.context)||null==(t=n.refs.floating.current)?void 0:t.contains(o)}))||v.current(!1)}const r=n.floating.current,o=n.reference.current;if(r&&w(o)){!f&&r.addEventListener("focusout",e);const n=f?P(r):null;return()=>{!f&&r.removeEventListener("focusout",e),null==n||n()}}}),[t,m,f,v,g,a,n.floating,n.reference]),u.useEffect((()=>{if(l)return;const e=n.floating.current,t=D(b(e));var r;if("number"==typeof a)j(null!=(r=g()[a])?r:e);else if(w(null==a?void 0:a.current)){var o;j(null!=(o=a.current)?o:e)}return()=>{s&&w(t)&&j(t)}}),[l,g,a,f,s,n.floating]),u.createElement(u.Fragment,null,f&&u.createElement(N,{onFocus:e=>{F(e);const n=g();"reference"===c[0]?j(n[0]):j(n[n.length-1])}}),u.cloneElement(o,c.includes("floating")?{tabIndex:0}:{}),f&&i&&u.createElement(N,{onFocus:e=>{F(e),j(g()[0])}}))},e.FloatingNode=e=>{let{children:n,id:t}=e;const r=g();return u.createElement(v.Provider,{value:u.useMemo((()=>({id:t,parentId:r})),[t,r])},n)},e.FloatingOverlay=L,e.FloatingPortal=e=>{let{children:n,id:t=k,root:o=null}=e;const[i,l]=u.useState(!1),a=R({id:t,enabled:!o});return c((()=>{o||l(!0)}),[o]),o?r.createPortal(n,o):i&&a?r.createPortal(n,a):null},e.FloatingTree=e=>{let{children:n}=e;const t=u.useRef([]),r=u.useCallback((e=>{t.current=[...t.current,e]}),[]),o=u.useCallback((e=>{t.current=t.current.filter((n=>n!==e))}),[]),c=u.useState((()=>i()))[0];return u.createElement(m.Provider,{value:u.useMemo((()=>({nodesRef:t,addNode:r,removeNode:o,events:c})),[t,r,o,c])},n)},e.safePolygon=function(e){let n,{restMs:t=0,buffer:r=.5,debug:o=null}=void 0===e?{}:e,u=!1;return e=>{let{x:o,y:c,placement:i,refs:l,onClose:a,nodeId:s,tree:f,leave:d=!1}=e;return function(e){var v;function m(){clearTimeout(n),a()}if(clearTimeout(n),e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:g,clientY:p}=e,y="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&E(l.reference.current)&&l.reference.current.contains(y))return;if(f&&x(f,s).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(null!=(v=l.floating.current)&&v.contains(y)&&!d)return void(u=!0);if(!l.reference.current||!l.floating.current||null==i||null==o||null==c)return;const b=l.reference.current.getBoundingClientRect(),h=l.floating.current.getBoundingClientRect(),w=i.split("-")[0],k=o>h.right-h.width/2,R=c>h.bottom-h.height/2;if("top"===w&&c>=b.bottom-1||"bottom"===w&&c<=b.top+1||"left"===w&&o>=b.right-1||"right"===w&&o<=b.left+1)return m();switch(w){case"top":if(g>=h.left&&g<=h.right&&p>=h.top&&p<=b.top+1)return;break;case"bottom":if(g>=h.left&&g<=h.right&&p>=b.bottom-1&&p<=h.bottom)return;break;case"left":if(g>=h.left&&g<=b.left+1&&p>=h.top&&p<=h.bottom)return;break;case"right":if(g>=b.right-1&&g<=h.right&&p>=h.top&&p<=h.bottom)return}if(u)return m();const I=function(e){let[n,t]=e;const o=h.width>b.width,u=h.height>b.height;switch(w){case"top":return[[o?n+r/2:k?n+4*r:n-4*r,t+r+1],[o?n-r/2:k?n+4*r:n-4*r,t+r+1],...[[h.left,k||o?h.bottom-r:h.top],[h.right,k?o?h.bottom-r:h.top:h.bottom-r]]];case"bottom":return[[o?n+r/2:k?n+4*r:n-4*r,t-r],[o?n-r/2:k?n+4*r:n-4*r,t-r],...[[h.left,k||o?h.top+r:h.bottom],[h.right,k?o?h.top+r:h.bottom:h.top+r]]];case"left":{const e=[n+r+1,u?t+r/2:R?t+4*r:t-4*r],o=[n+r+1,u?t-r/2:R?t+4*r:t-4*r];return[...[[R||u?h.right-r:h.left,h.top],[R?u?h.right-r:h.left:h.right-r,h.bottom]],e,o]}case"right":return[[n-r,u?t+r/2:R?t+4*r:t-4*r],[n-r,u?t-r/2:R?t+4*r:t-4*r],...[[R||u?h.left+r:h.right,h.top],[R?u?h.left+r:h.right:h.left+r,h.bottom]]]}}([o,c]);!function(e,n){const[t,r]=e;let o=!1;const u=n.length;for(let e=0,c=u-1;e<u;c=e++){const[u,i]=n[e]||[0,0],[l,a]=n[c]||[0,0];i>=r!=a>=r&&t<=(l-u)*(r-i)/(a-i)+u&&(o=!o)}return o}([g,p],I)?m():t&&(n=setTimeout(a,t))}}},e.useClick=function(e,n){let{open:t,onOpenChange:r,dataRef:o,refs:c}=e,{enabled:i=!0,pointerDown:l=!1,toggle:a=!0,ignoreMouse:s=!1}=void 0===n?{}:n;const f=u.useRef();function d(){return w(c.reference.current)&&"BUTTON"===c.reference.current.tagName}return i?{reference:{onPointerDown(e){if(f.current=e.pointerType,("mouse"!==f.current||!s)&&l){var n;if(t)a&&"pointerdown"===(null==(n=o.current.openEvent)?void 0:n.type)&&r(!1);else r(!0);o.current.openEvent=e.nativeEvent}},onClick(e){if(l&&f.current)f.current=void 0;else if("mouse"!==f.current||!s){var n;if(t)a&&"click"===(null==(n=o.current.openEvent)?void 0:n.type)&&r(!1);else r(!0);o.current.openEvent=e.nativeEvent}},onKeyDown(e){f.current=void 0,d()||(" "===e.key&&e.preventDefault(),"Enter"===e.key&&(t?a&&r(!1):r(!0)))},onKeyUp(e){d()||" "===e.key&&(t?a&&r(!1):r(!0))}}}:{}},e.useDelayGroup=(e,n)=>{let{open:t,onOpenChange:r}=e,{id:o}=n;const{currentId:c,initialDelay:i,setState:l}=q(),a=S(r);u.useEffect((()=>{c&&a.current&&(l((e=>({...e,delay:{open:1,close:K(i,"close")}}))),c!==o&&a.current(!1))}),[o,a,l,c,i]),u.useEffect((()=>{!t&&c===o&&a.current&&(a.current(!1),l((e=>({...e,delay:i,currentId:null}))))}),[t,l,c,o,a,i])},e.useDelayGroupContext=q,e.useDismiss=function(e,n){let{open:r,onOpenChange:o,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:s=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===n?{}:n;const g=p(),y=S(o),h=u.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(D(b(c.floating.current)))}),[c.floating]),k=u.useCallback((()=>{w(c.reference.current)&&c.reference.current.focus()}),[c.reference]);return u.useEffect((()=>{if(!r||!a)return;function e(e){if("Escape"===e.key){if(!m&&!h())return;i.emit("dismiss"),y.current(!1),k()}}function n(e){const n=g&&x(g,l).some((n=>{var t;return B(e,null==(t=n.context)?void 0:t.refs.floating.current)}));B(e,c.floating.current)||E(c.reference.current)&&B(e,c.reference.current)||n||(m||h())&&(i.emit("dismiss"),y.current(!1),k())}function o(){y.current(!1)}const u=b(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("mousedown",n);const d=(v?[...E(c.reference.current)?t.getOverflowAncestors(c.reference.current):[],...E(c.floating.current)?t.getOverflowAncestors(c.floating.current):[]]:[]).filter((e=>{var n;return e!==(null==(n=u.defaultView)?void 0:n.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",o,{passive:!0}))),()=>{s&&u.removeEventListener("keydown",e),f&&u.removeEventListener("mousedown",n),d.forEach((e=>e.removeEventListener("scroll",o)))}}),[s,f,i,g,l,r,y,k,v,a,m,h,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),o(!1))}}}:{}},e.useFloating=function(e){let{open:n=!1,onOpenChange:r=(()=>{}),whileElementsMounted:o,placement:l,middleware:a,strategy:s,nodeId:f}=void 0===e?{}:e;const d=p(),v=u.useRef({}),m=u.useState((()=>i()))[0],g=t.useFloating({placement:l,middleware:a,strategy:s,whileElementsMounted:o}),y=u.useMemo((()=>({...g,dataRef:v,nodeId:f,events:m,open:n,onOpenChange:r})),[g,v,f,m,n,r]);return c((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===f));e&&(e.context=y)})),u.useMemo((()=>({context:y,...g})),[g,y])},e.useFloatingNodeId=()=>{const e=d(),n=p(),t=g();return c((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},e.useFloatingParentNodeId=g,e.useFloatingPortalNode=R,e.useFloatingTree=p,e.useFocus=function(e,n){let{open:t,onOpenChange:r,dataRef:o,refs:c,events:i}=e,{enabled:l=!0,keyboardOnly:a=!0}=void 0===n?{}:n;const s=u.useRef(""),f=u.useRef(!1);return u.useEffect((()=>{var e;if(!l)return;const n=null!=(e=b(c.floating.current).defaultView)?e:window;function r(){s.current&&(f.current=!t)}function o(){setTimeout((()=>{f.current=!1,s.current=""}))}return n.addEventListener("focus",o),n.addEventListener("blur",r),()=>{n.removeEventListener("focus",o),n.removeEventListener("blur",r)}}),[c.floating,t,l]),u.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){f.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:n}=e;s.current=n,f.current=!(!n||!a)},onFocus(e){var n,t,u;f.current||"focus"===e.type&&"mousedown"===(null==(n=o.current.openEvent)?void 0:n.type)&&E(c.reference.current)&&null!=(t=c.reference.current)&&t.contains(null==(u=o.current.openEvent)?void 0:u.target)||(o.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){var n;const t=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(t)||E(c.reference.current)&&c.reference.current.contains(t)||(f.current=!1,r(!1))}}}:{}},e.useHover=function(e,n){let{enabled:t=!0,delay:r=0,handleClose:o=null,mouseOnly:i=!1,restMs:l=0}=void 0===n?{}:n;const{open:a,onOpenChange:s,dataRef:f,events:d,refs:v}=e,m=p(),g=S(s),y=S(o),h=u.useRef(),w=u.useRef(),x=u.useRef(),k=u.useRef(),R=u.useRef(!0);c((()=>{t&&(a||(h.current=void 0))})),u.useEffect((()=>{if(t)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(w.current),clearTimeout(k.current),R.current=!0}}),[t,d,v.floating]),u.useEffect((()=>{if(!t||!y.current)return;function e(){var e;null!=(e=f.current.openEvent)&&e.type.includes("mouse")&&g.current(!1)}const n=b(v.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[v.floating,g,t,y,f]);const I=u.useCallback((function(e){void 0===e&&(e=!0);const n=K(r,"close",h.current);n&&!x.current?(clearTimeout(w.current),w.current=setTimeout((()=>g.current(!1)),n)):e&&g.current(!1)}),[r,g]),O=u.useCallback((()=>{x.current&&(b(v.floating.current).removeEventListener("pointermove",x.current),x.current=void 0)}),[v.floating]);if(u.useEffect((()=>{a||O()}),[a,t,O]),u.useEffect((()=>{if(!t)return;function n(e){if(clearTimeout(w.current),R.current=!1,a||i&&"mouse"!==h.current||l>0&&0===K(r,"open"))return;f.current.openEvent=e;const n=K(r,"open",h.current);n?w.current=setTimeout((()=>{g.current(!0)}),n):g.current(!0)}function o(n){var t,r;if("click"===(null==(t=f.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=f.current.openEvent)?void 0:r.type))return;const o=b(v.floating.current);if(clearTimeout(k.current),y.current)return clearTimeout(w.current),x.current&&o.removeEventListener("pointermove",x.current),x.current=y.current({...e,tree:m,x:n.clientX,y:n.clientY,onClose(){O(),I()}}),void o.addEventListener("pointermove",x.current);I()}function u(n){null==y.current||y.current({...e,tree:m,x:n.clientX,y:n.clientY,leave:!0,onClose(){O(),I()}})(n)}const c=v.floating.current,s=v.reference.current;return E(s)?(a&&s.addEventListener("pointerleave",u),null==c||c.addEventListener("pointerleave",u),s.addEventListener("mousemove",n,{once:!0}),s.addEventListener("mouseenter",n),s.addEventListener("mouseleave",o),()=>{a&&s.removeEventListener("pointerleave",u),null==c||c.removeEventListener("pointerleave",u),s.removeEventListener("mousemove",n),s.removeEventListener("mouseenter",n),s.removeEventListener("mouseleave",o)}):void 0}),[t,I,e,r,y,f,i,g,a,m,l,O,v.reference,v.floating]),!t)return{};function L(e){h.current=e.pointerType}return{reference:{onPointerDown:L,onPointerEnter:L,onMouseMove(){a||0===l||(clearTimeout(k.current),k.current=setTimeout((()=>{R.current||s(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(w.current)},onMouseLeave(){I(!1)}}}},e.useId=d,e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>y(n,e,"reference"),getFloatingProps:n=>y(n,e,"floating"),getItemProps:n=>y(n,e,"item")}},e.useListNavigation=function(e,n){let{open:t,onOpenChange:r,refs:o}=e,{listRef:i,activeIndex:l,onNavigate:a,enabled:s=!0,selectedIndex:f=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:y=!1,virtual:h=!1,focusItemOnOpen:E="auto",focusItemOnHover:x=!0,openOnArrowKeyDown:k=!0,disabledIndices:R=(k?void 0:[]),orientation:I="vertical"}=void 0===n?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:n;const O=g(),L=p(),T=U(t),C=u.useRef(E),M=u.useRef(null!=f?f:-1),A=u.useRef(null),P=S(U(a)),j=S(a),N=S(R),K=u.useRef(!1),W=u.useRef(-1),[q,B]=u.useState(),$=u.useCallback(((e,n)=>{W.current=requestAnimationFrame((()=>{var t,r;h?B(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}))}),[h]);function ee(e){if(K.current=!0,m&&function(e,n,t){return _(n,t?e===X:e===G,e===V)}(e.key,I,y))return F(e),r(!1),void(w(o.reference.current)&&o.reference.current.focus());const n=M.current,u=Q(i,R),c=Z(i,R);if("Home"===e.key&&(M.current=u,a(M.current)),"End"===e.key&&(M.current=c,a(M.current)),z(e.key,I)){if(F(e),t&&!h&&D(e.currentTarget.ownerDocument)===e.currentTarget)return M.current=J(e.key,I,y)?u:c,void a(M.current);J(e.key,I,y)?M.current=v?n>=c?d&&n!==i.current.length?-1:u:Y(i,{startingIndex:n,disabledIndices:R}):Math.min(c,Y(i,{startingIndex:n,disabledIndices:R})):M.current=v?n<=u?d&&-1!==n?i.current.length:c:Y(i,{startingIndex:n,decrement:!0,disabledIndices:R}):Math.max(u,Y(i,{startingIndex:n,decrement:!0,disabledIndices:R})),a(M.current)}}return c((()=>{s&&(!T&&t&&C.current&&null!=f&&j.current(f),T&&!t&&(cancelAnimationFrame(W.current),M.current=-1,null==P.current||P.current(null)))}),[t,T,f,i,j,P,$,s]),c((()=>{if(s&&t)if(null==l){if(null!=f)return;T&&(M.current=-1,$(i,M)),!T&&C.current&&(null!=A.current||!0===C.current&&null==A.current)&&(M.current=null==A.current||J(A.current,I,y)||m?Q(i,N.current):Z(i,N.current),j.current(M.current),$(i,M))}else l>=0&&l<i.current.length&&(M.current=l,$(i,M))}),[t,T,l,f,m,i,j,$,s,d,I,y,h,N]),c((()=>{s&&!t&&T&&null!=f&&w(o.reference.current)&&o.reference.current.focus()}),[o.reference,f,t,T,s]),c((()=>{if(s&&!t&&T){var e,n;const t=null==L||null==(e=L.nodesRef.current.find((e=>e.id===O)))||null==(n=e.context)?void 0:n.refs.floating.current;t&&!t.contains(D(b(t)))&&t.focus({preventScroll:!0})}}),[s,t,T,L,O]),c((()=>{A.current=null})),s?{reference:{...h&&t&&null!=l&&{"aria-activedescendant":q},onKeyDown(e){if(K.current=!0,h&&t)return ee(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(A.current=e.key),m?function(e,n,t){return _(n,t?e===G:e===X,e===H)}(e.key,I,y)&&(F(e),t?(M.current=Q(i,R),a(M.current)):r(!0)):z(e.key,I)&&(null!=f&&(M.current=f),F(e),!t&&k?r(!0):ee(e),t&&a(M.current))}},floating:{"aria-orientation":"both"===I?void 0:I,...h&&null!=l&&{"aria-activedescendant":q},onKeyDown:ee,onPointerMove(){K.current=!1}},item:{onFocus(e){let{currentTarget:n}=e;const t=i.current.indexOf(n);-1!==t&&a(t)},onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...x&&{onMouseMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=i.current.indexOf(t);-1!==e&&a(e)}},onMouseLeave(){var e;K.current||(M.current=-1,$(i,M),j.current(null),h||null==(e=o.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},e.useRole=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog"}=void 0===n?{}:n;const u=d(),c=d(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?u:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},e.useTypeahead=function(e,n){var t;let{open:r,dataRef:o}=e,{listRef:i,activeIndex:l,onMatch:a=(()=>{}),enabled:s=!0,findMatch:f=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===n?{listRef:{current:[]},activeIndex:null}:n;const g=u.useRef(),p=u.useRef(""),y=u.useRef(null!=(t=null!=m?m:l)?t:-1),h=u.useRef(null);function E(e){if(!e.currentTarget.contains(D(b(e.currentTarget))))return;p.current.length>0&&" "!==p.current[0]&&(o.current.typing=!0," "===e.key&&F(e));const n=i.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...v].includes(e.key))return;n.every((e=>{var n,t;return!e||(null==(n=e[0])?void 0:n.toLocaleLowerCase())!==(null==(t=e[1])?void 0:t.toLocaleLowerCase())}))&&p.current===e.key&&(p.current="",y.current=h.current),p.current+=e.key,clearTimeout(g.current),g.current=setTimeout((()=>{p.current="",y.current=h.current,o.current.typing=!1}),d);const t=y.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],u=f?f(r,p.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(p.current)))),c=u?n.indexOf(u):-1;-1!==c&&(a(c),h.current=c)}return c((()=>{r&&(clearTimeout(g.current),h.current=null,p.current="")}),[r]),c((()=>{var e;r&&""===p.current&&(y.current=null!=(e=null!=m?m:l)?e:-1)}),[r,m,l]),s?{reference:{onKeyDown:E},floating:{onKeyDown:E}}:{}},Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@floating-ui/react-dom"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/react-dom","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.FloatingUIReactDOM,e.React,e.ReactDOM)}(this,(function(e,t,n,r){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var u=o(n),c="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;function i(){const e=new Map;return{emit(t,n){var r;null==(r=e.get(t))||r.forEach((e=>e(n)))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){e.set(t,(e.get(t)||[]).filter((e=>e!==n)))}}}let l=!1,a=0;const s=()=>"floating-ui-"+a++;const f=u["useId".toString()],d=null!=f?f:function(){const[e,t]=u.useState((()=>l?s():void 0));return c((()=>{null==e&&t(s())}),[]),u.useEffect((()=>{l||(l=!0)}),[]),e},v=u.createContext(null),m=u.createContext(null),g=()=>{var e,t;return null!=(e=null==(t=u.useContext(v))?void 0:t.id)?e:null},p=()=>u.useContext(m);function b(e,t,n){const r={};return{..."floating"===n&&{tabIndex:-1},...e,...t.map((e=>e?e[n]:null)).concat(e).reduce(((e,t)=>t?(Object.entries(t).forEach((t=>{let[n,o]=t;0===n.indexOf("on")?(r[n]||(r[n]=[]),"function"==typeof o&&r[n].push(o),e[n]=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];r[n].forEach((e=>e(...t)))}):e[n]=o})),e):e),{})}}function y(e){var t;return null!=(t=null==e?void 0:e.ownerDocument)?t:document}function h(e){var t;return null!=(t=y(e).defaultView)?t:window}function E(e){return!!e&&e instanceof h(e).Element}function w(e){return!!e&&e instanceof h(e).HTMLElement}function x(e,t){var n;let r=null!=(n=null==e?void 0:e.nodesRef.current.filter((e=>{var n;return e.parentId===t&&(null==(n=e.context)?void 0:n.open)})))?n:[],o=r;for(;o.length;){var u;o=null!=(u=null==e?void 0:e.nodesRef.current.filter((e=>{var t;return null==(t=o)?void 0:t.some((t=>{var n;return e.parentId===t.id&&(null==(n=e.context)?void 0:n.open)}))})))?u:[],r=r.concat(o)}return r}const k="floating-ui-root",R=function(e){let{id:t=k,enabled:n=!0}=void 0===e?{}:e;const r=u.useRef(null);return c((()=>{if(!n)return;const e=document.getElementById(t);e?r.current=e:(r.current=document.createElement("div"),r.current.id=t),document.body.contains(r.current)||document.body.appendChild(r.current)}),[t,n]),r.current};function I(){return I=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I.apply(this,arguments)}const O="data-floating-ui-scroll-lock";const T=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return c((()=>{var e,t,r,o;if(!n)return;if(document.body.hasAttribute(O))return;document.body.setAttribute(O,"");const u=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",c=window.innerWidth-document.documentElement.clientWidth;if(!/iP(hone|ad|od)|iOS/.test(function(){const e=navigator.userAgentData;return null!=e&&e.platform?e.platform:navigator.platform}()))return Object.assign(document.body.style,{overflow:"hidden",[u]:c+"px"}),()=>{document.body.removeAttribute(O),Object.assign(document.body.style,{overflow:"",[u]:""})};const i=null!=(e=null==(t=window.visualViewport)?void 0:t.offsetLeft)?e:0,l=null!=(r=null==(o=window.visualViewport)?void 0:o.offsetTop)?r:0,a=window.pageXOffset,s=window.pageYOffset;return Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:-(s-Math.floor(l))+"px",left:-(a-Math.floor(i))+"px",right:"0",[u]:c+"px"}),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[u]:""}),document.body.removeAttribute(O),window.scrollTo(a,s)}}),[n]),u.createElement("div",I({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var L=new WeakMap,C=new WeakMap,M={},A=0,P=function(e,t,n){void 0===t&&(t=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e)),void 0===n&&(n="data-aria-hidden");var r=Array.isArray(e)?e:[e];M[n]||(M[n]=new WeakMap);var o=M[n],u=[],c=new Set,i=function(e){e&&!c.has(e)&&(c.add(e),i(e.parentNode))};r.forEach(i);var l=function(e){!e||r.indexOf(e)>=0||Array.prototype.forEach.call(e.children,(function(e){if(c.has(e))l(e);else{var t=e.getAttribute("aria-hidden"),r=null!==t&&"false"!==t,i=(L.get(e)||0)+1,a=(o.get(e)||0)+1;L.set(e,i),o.set(e,a),u.push(e),1===i&&r&&C.set(e,!0),1===a&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(t),c.clear(),A++,function(){u.forEach((function(e){var t=L.get(e)-1,r=o.get(e)-1;L.set(e,t),o.set(e,r),t||(C.has(e)||e.removeAttribute("aria-hidden"),C.delete(e)),r||e.removeAttribute(n)})),--A||(L=new WeakMap,L=new WeakMap,C=new WeakMap,M={})}};function D(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(r=n.shadowRoot)?void 0:r.activeElement);){var n,r;t=t.shadowRoot.activeElement}return t}function F(e){e.preventDefault(),e.stopPropagation()}function S(e){const t=n.useRef(e);return c((()=>{t.current=e})),t}function j(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const N=u.forwardRef((function(e,t){return u.createElement("span",I({},e,{ref:t,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function K(e,t,n){return n&&"mouse"!==n?0:"number"==typeof e?e:null==e?void 0:e[t]}const W=u.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),U=()=>u.useContext(W);function q(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}function B(e){const t=n.useRef();return c((()=>{t.current=e}),[e]),t.current}const V="ArrowUp",H="ArrowDown",G="ArrowLeft",X="ArrowRight";function Y(e,t){return t<0||t>=e.current.length}function _(e,t){let{startingIndex:n=-1,decrement:r=!1,disabledIndices:o}=void 0===t?{}:t;const u=e.current;let c=n;do{var i,l;c+=r?-1:1}while(c>=0&&c<=u.length-1&&(o?o.includes(c):null==u[c]||(null==(i=u[c])?void 0:i.hasAttribute("disabled"))||"true"===(null==(l=u[c])?void 0:l.getAttribute("aria-disabled"))));return c}function z(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function J(e,t){return z(t,e===V||e===H,e===G||e===X)}function Q(e,t,n){return z(t,e===H,n?e===G:e===X)||"Enter"===e||" "==e||""===e}function Z(e,t){return _(e,{disabledIndices:t})}function $(e,t){return _(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}e.FloatingDelayGroup=e=>{let{children:t,delay:n}=e;const[r,o]=u.useState({delay:n,initialDelay:n,currentId:null}),c=u.useCallback((e=>{o((t=>({...t,currentId:e})))}),[]);return u.createElement(W.Provider,{value:u.useMemo((()=>({...r,setState:o,setCurrentId:c})),[r,o,c])},t)},e.FloatingFocusManager=function(e){let{context:{refs:t,nodeId:n,onOpenChange:r},children:o,order:c=["content"],endGuard:i=!0,preventTabbing:l=!1,initialFocus:a=0,returnFocus:s=!0,modal:f=!0}=e;const d=S(c),v=S(r),m=p(),g=u.useCallback((()=>d.current.map((e=>{return w(t.reference.current)&&"reference"===e?t.reference.current:t.floating.current&&"floating"===e?t.floating.current:"content"===e?Array.from(null!=(n=null==(r=t.floating.current)?void 0:r.querySelectorAll("input:not([type='hidden']):not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],button:not([disabled]),[tabindex],iframe,object,embed,area[href],audio[controls],video[controls],[contenteditable]:not([contenteditable='false'])"))?n:[]):null;var n,r})).flat().filter((e=>{if(e===t.floating.current||e===t.reference.current)return!0;if(w(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[d,t.floating,t.reference]),b=u.useCallback((()=>w(t.reference.current)&&"combobox"===t.reference.current.getAttribute("role")&&"INPUT"===t.reference.current.tagName),[t]);return u.useEffect((()=>{if(!f)return;const e=0===g().filter((e=>e!==t.floating.current&&e!==t.reference.current)).length;function n(n){if("Tab"===n.key){(l||e)&&F(n);const r=g(),o="composedPath"in n?n.composedPath()[0]:n.target;"reference"===d.current[0]&&o===t.reference.current&&(F(n),n.shiftKey?j(r[r.length-1]):j(r[1])),"floating"===d.current[1]&&o===t.floating.current&&n.shiftKey&&(F(n),j(r[0]))}}const r=y(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[l,f,g,d,t.floating,t.reference]),u.useEffect((()=>{function e(e){var r;const o=e.relatedTarget;null!=(r=t.floating.current)&&r.contains(o)||!E(t.reference.current)||t.reference.current.contains(o)||m&&x(m,n).some((e=>{let{context:t}=e;return null==t?void 0:t.open}))||m&&x(m,n).some((e=>{var t,n;return null==(t=e.context)||null==(n=t.refs.floating.current)?void 0:n.contains(o)}))||v.current(!1)}const r=t.floating.current,o=t.reference.current;if(r&&w(o)){let t;return!f&&r.addEventListener("focusout",e),f&&(t=d.current.includes("reference")?P([o,r]):P(r)),()=>{!f&&r.removeEventListener("focusout",e),null==t||t()}}}),[n,m,f,v,d,g,a,t.floating,t.reference]),u.useEffect((()=>{if(l)return;const e=t.floating.current,n=D(y(e));var r;if("number"==typeof a)j(null!=(r=g()[a])?r:e);else if(w(null==a?void 0:a.current)){var o;j(null!=(o=a.current)?o:e)}return()=>{s&&w(n)&&j(n)}}),[l,g,a,f,s,t.floating]),u.createElement(u.Fragment,null,f&&u.createElement(N,{onFocus:e=>{if(b())return;F(e);const t=g();"reference"===c[0]?j(t[0]):j(t[t.length-1])}}),u.cloneElement(o,c.includes("floating")?{tabIndex:0}:{}),f&&i&&u.createElement(N,{onFocus:e=>{b()||(F(e),j(g()[0]))}}))},e.FloatingNode=e=>{let{children:t,id:n}=e;const r=g();return u.createElement(v.Provider,{value:u.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},e.FloatingOverlay=T,e.FloatingPortal=e=>{let{children:t,id:n=k,root:o=null}=e;const[i,l]=u.useState(!1),a=R({id:n,enabled:!o});return c((()=>{o||l(!0)}),[o]),o?r.createPortal(t,o):i&&a?r.createPortal(t,a):null},e.FloatingTree=e=>{let{children:t}=e;const n=u.useRef([]),r=u.useCallback((e=>{n.current=[...n.current,e]}),[]),o=u.useCallback((e=>{n.current=n.current.filter((t=>t!==e))}),[]),c=u.useState((()=>i()))[0];return u.createElement(m.Provider,{value:u.useMemo((()=>({nodesRef:n,addNode:r,removeNode:o,events:c})),[n,r,o,c])},t)},e.safePolygon=function(e){let t,{restMs:n=0,buffer:r=.5,debug:o=null}=void 0===e?{}:e,u=!1;return e=>{let{x:o,y:c,placement:i,refs:l,onClose:a,nodeId:s,tree:f,leave:d=!1}=e;return function(e){var v;function m(){clearTimeout(t),a()}if(clearTimeout(t),e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:g,clientY:p}=e,b="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&E(l.reference.current)&&l.reference.current.contains(b))return;if(f&&x(f,s).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if(null!=(v=l.floating.current)&&v.contains(b)&&!d)return void(u=!0);if(!l.reference.current||!l.floating.current||null==i||null==o||null==c)return;const y=l.reference.current.getBoundingClientRect(),h=l.floating.current.getBoundingClientRect(),w=i.split("-")[0],k=o>h.right-h.width/2,R=c>h.bottom-h.height/2;if("top"===w&&c>=y.bottom-1||"bottom"===w&&c<=y.top+1||"left"===w&&o>=y.right-1||"right"===w&&o<=y.left+1)return m();switch(w){case"top":if(g>=h.left&&g<=h.right&&p>=h.top&&p<=y.top+1)return;break;case"bottom":if(g>=h.left&&g<=h.right&&p>=y.bottom-1&&p<=h.bottom)return;break;case"left":if(g>=h.left&&g<=y.left+1&&p>=h.top&&p<=h.bottom)return;break;case"right":if(g>=y.right-1&&g<=h.right&&p>=h.top&&p<=h.bottom)return}if(u)return m();const I=function(e){let[t,n]=e;const o=h.width>y.width,u=h.height>y.height;switch(w){case"top":return[[o?t+r/2:k?t+4*r:t-4*r,n+r+1],[o?t-r/2:k?t+4*r:t-4*r,n+r+1],...[[h.left,k||o?h.bottom-r:h.top],[h.right,k?o?h.bottom-r:h.top:h.bottom-r]]];case"bottom":return[[o?t+r/2:k?t+4*r:t-4*r,n-r],[o?t-r/2:k?t+4*r:t-4*r,n-r],...[[h.left,k||o?h.top+r:h.bottom],[h.right,k?o?h.top+r:h.bottom:h.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:R?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:R?n+4*r:n-4*r];return[...[[R||u?h.right-r:h.left,h.top],[R?u?h.right-r:h.left:h.right-r,h.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:R?n+4*r:n-4*r],[t-r,u?n-r/2:R?n+4*r:n-4*r],...[[R||u?h.left+r:h.right,h.top],[R?u?h.left+r:h.right:h.left+r,h.bottom]]]}}([o,c]);!function(e,t){const[n,r]=e;let o=!1;const u=t.length;for(let e=0,c=u-1;e<u;c=e++){const[u,i]=t[e]||[0,0],[l,a]=t[c]||[0,0];i>=r!=a>=r&&n<=(l-u)*(r-i)/(a-i)+u&&(o=!o)}return o}([g,p],I)?m():n&&(t=setTimeout(a,n))}}},e.useClick=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c}=e,{enabled:i=!0,pointerDown:l=!1,toggle:a=!0,ignoreMouse:s=!1}=void 0===t?{}:t;const f=u.useRef();function d(){return w(c.reference.current)&&"BUTTON"===c.reference.current.tagName}return i?{reference:{onPointerDown(e){if(f.current=e.pointerType,("mouse"!==f.current||!s)&&l){var t;if(n)a&&"pointerdown"===(null==(t=o.current.openEvent)?void 0:t.type)&&r(!1);else r(!0);o.current.openEvent=e.nativeEvent}},onClick(e){if(l&&f.current)f.current=void 0;else if("mouse"!==f.current||!s){var t;if(n)a&&"click"===(null==(t=o.current.openEvent)?void 0:t.type)&&r(!1);else r(!0);o.current.openEvent=e.nativeEvent}},onKeyDown(e){f.current=void 0,d()||(" "===e.key&&e.preventDefault(),"Enter"===e.key&&(n?a&&r(!1):r(!0)))},onKeyUp(e){d()||" "===e.key&&(n?a&&r(!1):r(!0))}}}:{}},e.useDelayGroup=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:o}=t;const{currentId:c,initialDelay:i,setState:l}=U(),a=S(r);u.useEffect((()=>{c&&a.current&&(l((e=>({...e,delay:{open:1,close:K(i,"close")}}))),c!==o&&a.current(!1))}),[o,a,l,c,i]),u.useEffect((()=>{!n&&c===o&&a.current&&(a.current(!1),l((e=>({...e,delay:i,currentId:null}))))}),[n,l,c,o,a,i])},e.useDelayGroupContext=U,e.useDismiss=function(e,n){let{open:r,onOpenChange:o,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:s=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===n?{}:n;const g=p(),b=S(o),h=u.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(D(y(c.floating.current)))}),[c.floating]),k=u.useCallback((()=>{w(c.reference.current)&&c.reference.current.focus()}),[c.reference]);return u.useEffect((()=>{if(!r||!a)return;function e(e){if("Escape"===e.key){if(!m&&!h())return;i.emit("dismiss"),b.current(!1),k()}}function n(e){const t=g&&x(g,l).some((t=>{var n;return q(e,null==(n=t.context)?void 0:n.refs.floating.current)}));q(e,c.floating.current)||E(c.reference.current)&&q(e,c.reference.current)||t||(m||h())&&(i.emit("dismiss"),b.current(!1),k())}function o(){b.current(!1)}const u=y(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("mousedown",n);const d=(v?[...E(c.reference.current)?t.getOverflowAncestors(c.reference.current):[],...E(c.floating.current)?t.getOverflowAncestors(c.floating.current):[]]:[]).filter((e=>{var t;return e!==(null==(t=u.defaultView)?void 0:t.visualViewport)}));return d.forEach((e=>e.addEventListener("scroll",o,{passive:!0}))),()=>{s&&u.removeEventListener("keydown",e),f&&u.removeEventListener("mousedown",n),d.forEach((e=>e.removeEventListener("scroll",o)))}}),[s,f,i,g,l,r,b,k,v,a,m,h,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),o(!1))}}}:{}},e.useFloating=function(e){let{open:n=!1,onOpenChange:r=(()=>{}),whileElementsMounted:o,placement:l,middleware:a,strategy:s,nodeId:f}=void 0===e?{}:e;const d=p(),v=u.useRef({}),m=u.useState((()=>i()))[0],g=t.useFloating({placement:l,middleware:a,strategy:s,whileElementsMounted:o}),b=u.useMemo((()=>({...g,dataRef:v,nodeId:f,events:m,open:n,onOpenChange:r})),[g,v,f,m,n,r]);return c((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===f));e&&(e.context=b)})),u.useMemo((()=>({context:b,...g})),[g,b])},e.useFloatingNodeId=()=>{const e=d(),t=p(),n=g();return c((()=>{const r={id:e,parentId:n};return null==t||t.addNode(r),()=>{null==t||t.removeNode(r)}}),[t,e,n]),e},e.useFloatingParentNodeId=g,e.useFloatingPortalNode=R,e.useFloatingTree=p,e.useFocus=function(e,t){let{open:n,onOpenChange:r,dataRef:o,refs:c,events:i}=e,{enabled:l=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const s=u.useRef(""),f=u.useRef(!1);return u.useEffect((()=>{var e;if(!l)return;const t=null!=(e=y(c.floating.current).defaultView)?e:window;function r(){s.current&&(f.current=!n)}function o(){setTimeout((()=>{f.current=!1,s.current=""}))}return t.addEventListener("focus",o),t.addEventListener("blur",r),()=>{t.removeEventListener("focus",o),t.removeEventListener("blur",r)}}),[c.floating,n,l]),u.useEffect((()=>{if(l)return i.on("dismiss",e),()=>{i.off("dismiss",e)};function e(){f.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:t}=e;s.current=t,f.current=!(!t||!a)},onFocus(e){var t,n,u;f.current||"focus"===e.type&&"mousedown"===(null==(t=o.current.openEvent)?void 0:t.type)&&E(c.reference.current)&&null!=(n=c.reference.current)&&n.contains(null==(u=o.current.openEvent)?void 0:u.target)||(o.current.openEvent=e.nativeEvent,r(!0))},onBlur(e){var t;const n=e.relatedTarget;null!=(t=c.floating.current)&&t.contains(n)||E(c.reference.current)&&c.reference.current.contains(n)||(f.current=!1,r(!1))}}}:{}},e.useHover=function(e,t){let{enabled:n=!0,delay:r=0,handleClose:o=null,mouseOnly:i=!1,restMs:l=0}=void 0===t?{}:t;const{open:a,onOpenChange:s,dataRef:f,events:d,refs:v}=e,m=p(),g=S(s),b=S(o),h=u.useRef(),w=u.useRef(),x=u.useRef(),k=u.useRef(),R=u.useRef(!0);u.useEffect((()=>{if(n)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(w.current),clearTimeout(k.current),R.current=!0}}),[n,d,v.floating]),u.useEffect((()=>{if(!n||!b.current)return;function e(){var e;null!=(e=f.current.openEvent)&&e.type.includes("mouse")&&g.current(!1)}const t=y(v.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[v.floating,g,n,b,f]);const I=u.useCallback((function(e){void 0===e&&(e=!0);const t=K(r,"close",h.current);t&&!x.current?(clearTimeout(w.current),w.current=setTimeout((()=>g.current(!1)),t)):e&&g.current(!1)}),[r,g]),O=u.useCallback((()=>{x.current&&(y(v.floating.current).removeEventListener("pointermove",x.current),x.current=void 0)}),[v.floating]);if(u.useEffect((()=>{if(!n)return;function t(e){if(clearTimeout(w.current),R.current=!1,a||i&&"mouse"!==h.current||l>0&&0===K(r,"open"))return;f.current.openEvent=e;const t=K(r,"open",h.current);t?w.current=setTimeout((()=>{g.current(!0)}),t):g.current(!0)}function o(t){var n,r;if("click"===(null==(n=f.current.openEvent)?void 0:n.type)||"pointerdown"===(null==(r=f.current.openEvent)?void 0:r.type))return;const o=y(v.floating.current);if(clearTimeout(k.current),b.current)return clearTimeout(w.current),x.current&&o.removeEventListener("pointermove",x.current),x.current=b.current({...e,tree:m,x:t.clientX,y:t.clientY,onClose(){O(),I()}}),void o.addEventListener("pointermove",x.current);I()}function u(t){null==b.current||b.current({...e,tree:m,x:t.clientX,y:t.clientY,leave:!0,onClose(){O(),I()}})(t)}const c=v.floating.current,s=v.reference.current;return E(s)?(a&&s.addEventListener("pointerleave",u),null==c||c.addEventListener("pointerleave",u),s.addEventListener("mousemove",t,{once:!0}),s.addEventListener("mouseenter",t),s.addEventListener("mouseleave",o),()=>{a&&s.removeEventListener("pointerleave",u),null==c||c.removeEventListener("pointerleave",u),s.removeEventListener("mousemove",t),s.removeEventListener("mouseenter",t),s.removeEventListener("mouseleave",o)}):void 0}),[n,I,e,r,b,f,i,g,a,m,l,O,v.reference,v.floating]),c((()=>{a||(h.current=void 0,O())})),u.useEffect((()=>()=>{O(),clearTimeout(w.current),clearTimeout(k.current)}),[O]),!n)return{};function T(e){h.current=e.pointerType}return{reference:{onPointerDown:T,onPointerEnter:T,onMouseMove(){a||0===l||(clearTimeout(k.current),k.current=setTimeout((()=>{R.current||s(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(w.current)},onMouseLeave(){I(!1)}}}},e.useId=d,e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:t=>b(t,e,"reference"),getFloatingProps:t=>b(t,e,"floating"),getItemProps:t=>b(t,e,"item")}},e.useListNavigation=function(e,t){let{open:n,onOpenChange:r,refs:o}=e,{listRef:i,activeIndex:l,onNavigate:a,enabled:s=!0,selectedIndex:f=null,allowEscape:d=!1,loop:v=!1,nested:m=!1,rtl:b=!1,virtual:h=!1,focusItemOnOpen:E="auto",focusItemOnHover:x=!0,openOnArrowKeyDown:k=!0,disabledIndices:R=(k?void 0:[]),orientation:I="vertical"}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const O=g(),T=p(),L=B(n),C=u.useRef(E),M=u.useRef(null!=f?f:-1),A=u.useRef(null),P=S(B(a)),j=S(a),N=S(R),K=u.useRef(!1),W=u.useRef(-1),[U,q]=u.useState(),ee=u.useCallback(((e,t)=>{W.current=requestAnimationFrame((()=>{var n,r;h?q(null==(n=e.current[t.current])?void 0:n.id):null==(r=e.current[t.current])||r.focus({preventScroll:!0})}))}),[h]);function te(e){if(K.current=!0,m&&function(e,t,n){return z(t,n?e===X:e===G,e===V)}(e.key,I,b))return F(e),r(!1),void(w(o.reference.current)&&o.reference.current.focus());const t=M.current,u=Z(i,R),c=$(i,R);if("Home"===e.key&&(M.current=u,a(M.current)),"End"===e.key&&(M.current=c,a(M.current)),J(e.key,I)){if(F(e),n&&!h&&D(e.currentTarget.ownerDocument)===e.currentTarget)return M.current=Q(e.key,I,b)?u:c,void a(M.current);Q(e.key,I,b)?M.current=v?t>=c?d&&t!==i.current.length?-1:u:_(i,{startingIndex:t,disabledIndices:R}):Math.min(c,_(i,{startingIndex:t,disabledIndices:R})):M.current=v?t<=u?d&&-1!==t?i.current.length:c:_(i,{startingIndex:t,decrement:!0,disabledIndices:R}):Math.max(u,_(i,{startingIndex:t,decrement:!0,disabledIndices:R})),Y(i,M.current)?a(null):a(M.current)}}return c((()=>{s&&(!L&&n&&C.current&&null!=f&&j.current(f),L&&!n&&(cancelAnimationFrame(W.current),M.current=-1,null==P.current||P.current(null)))}),[n,L,f,i,j,P,ee,s]),c((()=>{if(s&&n)if(null==l){if(null!=f)return;L&&(M.current=-1,ee(i,M)),!L&&C.current&&(null!=A.current||!0===C.current&&null==A.current)&&(M.current=null==A.current||Q(A.current,I,b)||m?Z(i,N.current):$(i,N.current),j.current(M.current),ee(i,M))}else Y(i,l)||(M.current=l,ee(i,M))}),[n,L,l,f,m,i,j,ee,s,d,I,b,h,N]),c((()=>{s&&!n&&L&&null!=f&&w(o.reference.current)&&o.reference.current.focus()}),[o.reference,f,n,L,s]),c((()=>{if(s&&!n&&L){var e,t;const n=null==T||null==(e=T.nodesRef.current.find((e=>e.id===O)))||null==(t=e.context)?void 0:t.refs.floating.current;n&&!n.contains(D(y(n)))&&n.focus({preventScroll:!0})}}),[s,n,L,T,O]),c((()=>{A.current=null})),s?{reference:{...h&&n&&null!=l&&{"aria-activedescendant":U},onKeyDown(e){if(K.current=!0,h&&n)return te(e);(0===e.key.indexOf("Arrow")||"Enter"===e.key||" "===e.key||""===e.key)&&(A.current=e.key),m?function(e,t,n){return z(t,n?e===G:e===X,e===H)}(e.key,I,b)&&(F(e),n?(M.current=Z(i,R),a(M.current)):r(!0)):J(e.key,I)&&(null!=f&&(M.current=f),F(e),!n&&k?r(!0):te(e),n&&a(M.current))}},floating:{"aria-orientation":"both"===I?void 0:I,...h&&null!=l&&{"aria-activedescendant":U},onKeyDown:te,onPointerMove(){K.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=i.current.indexOf(t);-1!==n&&a(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...x&&{onMouseMove(e){let{currentTarget:t}=e;const n=t;if(n){const e=i.current.indexOf(n);-1!==e&&a(e)}},onMouseLeave(){var e;K.current||(M.current=-1,ee(i,M),j.current(null),h||null==(e=o.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},e.useRole=function(e,t){let{open:n}=e,{enabled:r=!0,role:o="dialog"}=void 0===t?{}:t;const u=d(),c=d(),i={id:u,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":n?u:void 0},floating:i}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":o,"aria-controls":n?u:void 0,..."listbox"===o&&{role:"combobox"},..."menu"===o&&{id:c}},floating:{...i,..."menu"===o&&{"aria-labelledby":c}}}:{}},e.useTypeahead=function(e,t){var n;let{open:r,dataRef:o}=e,{listRef:i,activeIndex:l,onMatch:a=(()=>{}),enabled:s=!0,findMatch:f=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const g=u.useRef(),p=u.useRef(""),b=u.useRef(null!=(n=null!=m?m:l)?n:-1),h=u.useRef(null);function E(e){if(!e.currentTarget.contains(D(y(e.currentTarget))))return;p.current.length>0&&" "!==p.current[0]&&(o.current.typing=!0," "===e.key&&F(e));const t=i.current;if(null==t||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...v].includes(e.key))return;t.every((e=>{var t,n;return!e||(null==(t=e[0])?void 0:t.toLocaleLowerCase())!==(null==(n=e[1])?void 0:n.toLocaleLowerCase())}))&&p.current===e.key&&(p.current="",b.current=h.current),p.current+=e.key,clearTimeout(g.current),g.current=setTimeout((()=>{p.current="",b.current=h.current,o.current.typing=!1}),d);const n=b.current,r=[...t.slice((null!=n?n:0)+1),...t.slice(0,(null!=n?n:0)+1)],u=f?f(r,p.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(p.current)))),c=u?t.indexOf(u):-1;-1!==c&&(a(c),h.current=c)}return c((()=>{r&&(clearTimeout(g.current),h.current=null,p.current="")}),[r]),c((()=>{var e;r&&""===p.current&&(b.current=null!=(e=null!=m?m:l)?e:-1)}),[r,m,l]),s?{reference:{onKeyDown:E},floating:{onKeyDown:E}}:{}},Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@floating-ui/react-dom-interactions", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"@rollingversions": { | ||
@@ -60,3 +60,3 @@ "baseVersion": [ | ||
"dependencies": { | ||
"@floating-ui/react-dom": "^0.7.0", | ||
"@floating-ui/react-dom": "^0.7.1", | ||
"aria-hidden": "^1.1.3", | ||
@@ -63,0 +63,0 @@ "use-isomorphic-layout-effect": "^1.1.1" |
@@ -1,31 +0,3 @@ | ||
import * as React from 'react'; | ||
import { ComputePositionReturn, VirtualElement } from '@floating-ui/react-dom'; | ||
import type { FloatingContext, Middleware, Placement, Strategy } from './types'; | ||
declare type Data = Omit<ComputePositionReturn, 'x' | 'y'> & { | ||
x: number | null; | ||
y: number | null; | ||
}; | ||
export declare type ReferenceType = Element | VirtualElement; | ||
export declare type UseFloatingReturn<RT extends ReferenceType = ReferenceType> = Data & { | ||
update: () => void; | ||
reference: (node: RT | null) => void; | ||
floating: (node: HTMLElement | null) => void; | ||
refs: { | ||
reference: React.MutableRefObject<RT | null>; | ||
floating: React.MutableRefObject<HTMLElement | null>; | ||
}; | ||
}; | ||
export interface Props<RT extends ReferenceType = ReferenceType> { | ||
open: boolean; | ||
onOpenChange: (open: boolean) => void; | ||
placement: Placement; | ||
middleware: Array<Middleware>; | ||
strategy: Strategy; | ||
nodeId: string; | ||
whileElementsMounted?: (reference: RT, floating: HTMLElement, update: () => void) => void | (() => void); | ||
} | ||
export declare function useFloating<RT extends ReferenceType = ReferenceType>({ open, onOpenChange, whileElementsMounted, placement, middleware, strategy, nodeId, }?: Partial<Props>): UseFloatingReturn<RT> & { | ||
context: FloatingContext<RT>; | ||
}; | ||
export * from '@floating-ui/react-dom'; | ||
export { useFloating } from './useFloating'; | ||
export { useInteractions } from './useInteractions'; | ||
@@ -32,0 +4,0 @@ export { safePolygon } from './safePolygon'; |
import * as React from 'react'; | ||
import type { UseFloatingReturn, ReferenceType } from './'; | ||
import type { ComputePositionReturn, VirtualElement, Placement, Middleware, Strategy } from '@floating-ui/dom'; | ||
export * from '@floating-ui/dom'; | ||
export * from './'; | ||
export * from '@floating-ui/dom'; | ||
export { arrow } from '@floating-ui/react-dom'; | ||
@@ -39,1 +39,24 @@ export interface FloatingEvents { | ||
} | ||
export declare type ReferenceType = Element | VirtualElement; | ||
export declare type UseFloatingData = Omit<ComputePositionReturn, 'x' | 'y'> & { | ||
x: number | null; | ||
y: number | null; | ||
}; | ||
export declare type UseFloatingReturn<RT extends ReferenceType = ReferenceType> = UseFloatingData & { | ||
update: () => void; | ||
reference: (node: RT | null) => void; | ||
floating: (node: HTMLElement | null) => void; | ||
refs: { | ||
reference: React.MutableRefObject<RT | null>; | ||
floating: React.MutableRefObject<HTMLElement | null>; | ||
}; | ||
}; | ||
export interface UseFloatingProps<RT extends ReferenceType = ReferenceType> { | ||
open: boolean; | ||
onOpenChange: (open: boolean) => void; | ||
placement: Placement; | ||
middleware: Array<Middleware>; | ||
strategy: Strategy; | ||
nodeId: string; | ||
whileElementsMounted?: (reference: RT, floating: HTMLElement, update: () => void) => void | (() => void); | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
280780
36
6240