@floating-ui/react-dom-interactions
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -441,17 +441,10 @@ import * as React from 'react'; | ||
const DEFAULT_ID = 'floating-ui-root'; | ||
/** | ||
* Portals your floating element outside of the main app node. | ||
* @see https://floating-ui.com/docs/FloatingPortal | ||
*/ | ||
const FloatingPortal = _ref => { | ||
const useFloatingPortalNode = function (_temp) { | ||
let { | ||
children, | ||
id = DEFAULT_ID, | ||
root = null | ||
} = _ref; | ||
const [mounted, setMounted] = React.useState(false); | ||
enabled = true | ||
} = _temp === void 0 ? {} : _temp; | ||
const portalRef = React.useRef(null); | ||
index(() => { | ||
if (root) { | ||
if (!enabled) { | ||
return; | ||
@@ -472,5 +465,28 @@ } | ||
} | ||
}, [id, enabled]); | ||
return portalRef.current; | ||
}; | ||
/** | ||
* Portals your floating element outside of the main app node. | ||
* @see https://floating-ui.com/docs/FloatingPortal | ||
*/ | ||
const FloatingPortal = _ref => { | ||
let { | ||
children, | ||
id = DEFAULT_ID, | ||
root = null | ||
} = _ref; | ||
const [mounted, setMounted] = React.useState(false); | ||
const portalNode = useFloatingPortalNode({ | ||
id, | ||
enabled: !root | ||
}); | ||
index(() => { | ||
if (root) { | ||
return; | ||
} | ||
setMounted(true); | ||
}, [id, root]); | ||
}, [root]); | ||
@@ -481,4 +497,4 @@ if (root) { | ||
if (mounted && portalRef.current) { | ||
return /*#__PURE__*/createPortal(children, portalRef.current); | ||
if (mounted && portalNode) { | ||
return /*#__PURE__*/createPortal(children, portalNode); | ||
} | ||
@@ -2040,2 +2056,3 @@ | ||
onOpenChange = () => {}, | ||
whileElementsMounted, | ||
placement, | ||
@@ -2052,3 +2069,4 @@ middleware, | ||
middleware, | ||
strategy | ||
strategy, | ||
whileElementsMounted | ||
}); | ||
@@ -2075,2 +2093,2 @@ const context = React.useMemo(() => ({ ...floating, | ||
export { FloatingDelayGroup, FloatingFocusManager, FloatingNode, FloatingOverlay, FloatingPortal, FloatingTree, safePolygon, useClick, useDelayGroup, useDelayGroupContext, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useFocus, useHover, useId, useInteractions, useListNavigation, useRole, useTypeahead }; | ||
export { FloatingDelayGroup, FloatingFocusManager, FloatingNode, FloatingOverlay, FloatingPortal, FloatingTree, safePolygon, useClick, useDelayGroup, useDelayGroupContext, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingPortalNode, useFloatingTree, useFocus, useHover, useId, useInteractions, useListNavigation, useRole, useTypeahead }; |
@@ -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 f=!1,s=0;const d=()=>"floating-ui-"+s++;const v=e["useId".toString()],m=null!=v?v:function(){const[n,t]=e.useState((()=>f?d():void 0));return l((()=>{null==n&&t(d())}),[]),e.useEffect((()=>{f||(f=!0)}),[]),n},g=e.createContext(null),p=e.createContext(null),h=()=>{var n,t;return null!=(n=null==(t=e.useContext(g))?void 0:t.id)?n:null},b=()=>e.useContext(p),y=()=>{const e=m(),n=b(),t=h();return l((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},E=n=>{let{children:t,id:r}=n;const o=h();return e.createElement(g.Provider,{value:e.useMemo((()=>({id:r,parentId:o})),[r,o])},t)},w=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(p.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 k(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function L(e){var n;return null!=(n=k(e).defaultView)?n:window}function T(e){return!!e&&e instanceof L(e).Element}function C(e){return!!e&&e instanceof L(e).HTMLElement}function I(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=0,debug:o=null}=void 0===e?{}:e,u=!1,c=!1,i=!1;return e=>{let{x:o,y:l,placement:a,refs:f,onClose:s,nodeId:d,tree:v}=e;return function(e){var m;if(clearTimeout(n),!u)return void(i||(i=!0,setTimeout((()=>{u=!0}),1e3/60)));function g(){clearTimeout(n),s()}if(e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:p,clientY:h}=e,b="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&T(f.reference.current)&&f.reference.current.contains(b))return;if(v&&I(v,d).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(null!=(m=f.floating.current)&&m.contains(b))return void(c=!0);if(!f.reference.current||!f.floating.current||null==a||null==o||null==l)return;const y=f.reference.current.getBoundingClientRect(),E=f.floating.current.getBoundingClientRect(),w=a.split("-")[0],x=o>E.right-E.width/2,R=l>E.bottom-E.height/2;if("top"===w&&l>=y.bottom-1||"bottom"===w&&l<=y.top+1||"left"===w&&o>=y.right-1||"right"===w&&o<=y.left+1)return g();switch(w){case"top":if(p>=E.left&&p<=E.right&&h>=E.bottom&&h<=y.top)return;break;case"bottom":if(p>=E.left&&p<=E.right&&h>=y.bottom&&h<=E.top)return;break;case"left":if(p>=E.right&&p<=y.left&&h>=E.top&&h<=E.bottom)return;break;case"right":if(p>=y.right&&p<=E.left&&h>=E.top&&h<=E.bottom)return}if(c)return g();const k=function(e){let[n,t]=e;const o=E.width>y.width,u=E.height>y.height;switch(w){case"top":return[[o?n+r/2:x?n+4*r:n-4*r,t+r+1],[o?n-r/2:x?n+4*r:n-4*r,t+r+1],...[[E.left,x||o?E.bottom-r:E.top],[E.right,x?o?E.bottom-r:E.top:E.bottom-r]]];case"bottom":return[[o?n+r/2:x?n+4*r:n-4*r,t-r],[o?n-r/2:x?n+4*r:n-4*r,t-r],...[[E.left,x||o?E.top+r:E.bottom],[E.right,x?o?E.top+r:E.bottom:E.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?E.right-r:E.left,E.top],[R?u?E.right-r:E.left:E.right-r,E.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?E.left+r:E.right,E.top],[R?u?E.left+r:E.right:E.left+r,E.bottom]]]}}([o,l]);!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,h],k)?g():t&&(n=setTimeout(s,t))}}}const O="floating-ui-root",P=n=>{let{children:t,id:r=O,root:o=null}=n;const[u,i]=e.useState(!1),a=e.useRef(null);return l((()=>{if(o)return;const e=document.getElementById(r);e?a.current=e:(a.current=document.createElement("div"),a.current.id=r),document.body.contains(a.current)||document.body.appendChild(a.current),i(!0)}),[r,o]),o?c(t,o):u&&a.current?c(t,a.current):null};function D(){return D=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},D.apply(this,arguments)}const M="data-floating-ui-scroll-lock",S=e.forwardRef((function(n,t){let{lockScroll:r=!1,...o}=n;return l((()=>{if(!r)return;const e=window.pageXOffset,n=window.pageYOffset,t=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;return document.body.hasAttribute(M)?void 0:(Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:"-"+n+"px",left:"-"+e+"px",right:"0",[t]:o+"px"}),document.body.setAttribute(M,""),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[t]:""}),document.body.removeAttribute(M),window.scrollTo(e,n)})}),[r]),e.createElement("div",D({ref:t},o,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...o.style}}))}));function F(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 K(e){e.preventDefault(),e.stopPropagation()}function N(e){const n=r(e);return l((()=>{n.current=e})),n}function j(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const B=e.forwardRef((function(n,t){return e.createElement("span",D({},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:f=0,returnFocus:s=!0,modal:d=!0}=n;const v=N(c),m=N(o),g=b(),p=e.useCallback((()=>v.current.map((e=>{return C(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(C(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[v,t.floating,t.reference]);return e.useEffect((()=>{const e=0===p().filter((e=>e!==t.floating.current&&e!==t.reference.current)).length;function n(n){if("Tab"===n.key){(a||e)&&K(n);const r=p(),o="composedPath"in n?n.composedPath()[0]:n.target;"reference"===v.current[0]&&o===t.reference.current&&(K(n),n.shiftKey?j(r[r.length-1]):j(r[1])),"floating"===v.current[1]&&o===t.floating.current&&n.shiftKey&&(K(n),j(r[0]))}}const r=k(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[a,p,v,t.floating,t.reference]),e.useEffect((()=>{function e(e){var n;const o=e.relatedTarget;null!=(n=t.floating.current)&&n.contains(o)||!T(t.reference.current)||t.reference.current.contains(o)||g&&I(g,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&&C(o)){!d&&n.addEventListener("focusout",e);const t=d?i(n):null;return()=>{!d&&n.removeEventListener("focusout",e),null==t||t()}}}),[r,g,d,m,p,f,t.floating,t.reference]),e.useEffect((()=>{var e;if(a)return;const n=t.floating.current,r=null!=(e=F(k(n)))?e:F(document);var o;if("number"==typeof f)j(null!=(o=p()[f])?o:n);else if(C(null==f?void 0:f.current)){var u;j(null!=(u=f.current)?u:n)}return()=>{s&&C(r)&&j(r)}}),[a,p,f,d,s,t.floating]),e.createElement(e.Fragment,null,d&&e.createElement(B,{onFocus:e=>{K(e);const n=p();"reference"===c[0]?j(n[0]):j(n[n.length-1])}}),e.cloneElement(u,c.includes("floating")?{tabIndex:0}:{}),d&&l&&e.createElement(B,{onFocus:e=>{K(e),j(p()[0])}}))}function H(e,n,t){return t&&"mouse"!==t?0:"number"==typeof e?e:null==e?void 0:e[n]}const V=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:f,dataRef:s,events:d,refs:v}=n,m=b(),g=N(f),p=N(u),h=e.useRef(),y=e.useRef(),E=e.useRef(),w=e.useRef(),x=e.useRef(!0);l((()=>{r&&(a||(h.current=void 0))})),e.useEffect((()=>{if(r)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(y.current),clearTimeout(w.current),x.current=!0}}),[r,d,v.floating]),e.useEffect((()=>{if(!r||!p.current)return;function e(){var e;null!=(e=s.current.openEvent)&&e.type.includes("mouse")&&g.current(!1)}const n=k(v.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[v.floating,g,r,p,s]);const R=e.useCallback((function(e){void 0===e&&(e=!0),o&&!E.current?(clearTimeout(y.current),y.current=setTimeout((()=>g.current(!1)),H(o,"close",h.current))):e&&g.current(!1)}),[o,g]),L=e.useCallback((()=>{E.current&&(k(v.floating.current).removeEventListener("pointermove",E.current),E.current=void 0)}),[v.floating]);if(e.useEffect((()=>{a||L()}),[a,r,L]),e.useEffect((()=>{if(!r)return;function e(e){clearTimeout(y.current),x.current=!1,a||c&&"mouse"!==h.current||i>0&&0===H(o,"open")||(s.current.openEvent=e,o?y.current=setTimeout((()=>{g.current(!0)}),H(o,"open",h.current)):g.current(!0))}function t(e){var t,r;if("click"===(null==(t=s.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=s.current.openEvent)?void 0:r.type))return;const o=k(v.floating.current);if(clearTimeout(w.current),p.current)return clearTimeout(y.current),E.current&&o.removeEventListener("pointermove",E.current),E.current=p.current({...n,tree:m,x:e.clientX,y:e.clientY,onClose(){L(),R()}}),void o.addEventListener("pointermove",E.current);R()}const u=v.reference.current;return T(u)?(u.addEventListener("mousemove",e,{once:!0}),u.addEventListener("mouseenter",e),u.addEventListener("mouseleave",t),()=>{u.removeEventListener("mousemove",e),u.removeEventListener("mouseenter",e),u.removeEventListener("mouseleave",t)}):void 0}),[r,R,n,o,p,s,c,g,a,m,i,L,v.reference,v.floating]),!r)return{};function C(e){h.current=e.pointerType}return{reference:{onPointerDown:C,onPointerEnter:C,onMouseMove(){a||0===i||(clearTimeout(w.current),w.current=setTimeout((()=>{x.current||f(!0)}),i))}},floating:{onMouseEnter(){clearTimeout(y.current)},onMouseLeave:()=>R(!1)}}},X=e.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),Y=()=>e.useContext(X),q=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(X.Provider,{value:e.useMemo((()=>({...o,setState:u,setCurrentId:c})),[o,u,c])},t)},W=(n,t)=>{let{open:r,onOpenChange:o}=n,{id:u}=t;const{currentId:c,initialDelay:i,setState:l}=Y(),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])},z=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}}}:{}},G=function(n,t){let{open:r,onOpenChange:o,dataRef:u,refs:c}=n,{enabled:i=!0,pointerDown:l=!1,toggle:a=!0,ignoreMouse:f=!1}=void 0===t?{}:t;const s=e.useRef();function d(){return C(c.reference.current)&&"BUTTON"===c.reference.current.tagName}return i?{reference:{onPointerDown(e){if(s.current=e.pointerType,("mouse"!==s.current||!f)&&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&&s.current)s.current=void 0;else if("mouse"!==s.current||!f){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){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 J(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 Q=function(n,t){let{open:r,onOpenChange:u,refs:c,events:i,nodeId:l}=n,{enabled:a=!0,escapeKey:f=!0,outsidePointerDown:s=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===t?{}:t;const g=b(),p=N(u),h=e.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(F(k(c.floating.current)))}),[c.floating]),y=e.useCallback((()=>{C(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&&!h())return;i.emit("dismiss"),p.current(!1),y()}}function n(e){const n=g&&I(g,l).some((n=>{var t;return J(e,null==(t=n.context)?void 0:t.refs.floating.current)}));J(e,c.floating.current)||T(c.reference.current)&&J(e,c.reference.current)||n||(m||h())&&(i.emit("dismiss"),p.current(!1),y())}function t(){p.current(!1)}const u=k(c.floating.current);f&&u.addEventListener("keydown",e),s&&u.addEventListener("mousedown",n);const d=(v?[...T(c.reference.current)?o(c.reference.current):[],...T(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}))),()=>{f&&u.removeEventListener("keydown",e),s&&u.removeEventListener("mousedown",n),d.forEach((e=>e.removeEventListener("scroll",t)))}}),[f,s,i,g,l,r,p,y,v,a,m,h,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),u(!1))}}}:{}},Z=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 f=e.useRef(!1);return e.useEffect((()=>{var e;if(!l)return;const n=null!=(e=k(c.floating.current).defaultView)?e:window;function t(){f.current=!r}function o(){setTimeout((()=>{f.current=!1}))}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;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 $(e,n){let{startingIndex:t=-1,decrement:r=!1}=void 0===n?{}:n;const o=e.current;let u=t;do{var c,i;u+=r?-1:1}while(u>=0&&u<=o.length-1&&(null==o[u]||null!=(c=o[u])&&c.hasAttribute("disabled")||"true"===(null==(i=o[u])?void 0:i.getAttribute("aria-disabled"))));return u}function _(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function ee(e,n){return _(n,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function ne(e,n,t){return _(n,"ArrowDown"===e,t?"ArrowLeft"===e:"ArrowRight"===e)}function te(e){return $(e)}function re(e){return $(e,{decrement:!0,startingIndex:e.current.length})}const oe=function(n,t){let{open:o,onOpenChange:u,refs:c}=n,{listRef:i,activeIndex:a,onNavigate:f,enabled:s=!0,selectedIndex:d=null,allowEscape:v=!1,loop:m=!1,nested:g=!1,rtl:p=!1,virtual:y=!1,focusItemOnOpen:E="auto",focusItemOnHover:w=!0,orientation:x="vertical"}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const R=h(),L=b(),T=function(e){const n=r();return l((()=>{n.current=e}),[e]),n.current}(o),I=e.useRef("auto"!==E&&E),A=e.useRef(null!=d?d:-1),O=e.useRef(""),P=N(f),D=e.useRef(!1),[M,S]=e.useState(),j=e.useCallback(((e,n)=>{var t,r;y?S(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}),[y]);function B(e){if(D.current=!0,g&&function(e,n,t){return _(n,t?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(e.key,x,p))return K(e),u(!1),void(C(c.reference.current)&&c.reference.current.focus());const n=A.current,t=te(i),r=re(i);if("Home"===e.key&&(A.current=t,f(A.current)),"End"===e.key&&(A.current=r,f(A.current)),ee(e.key,x)){if(K(e),!y&&F(e.currentTarget.ownerDocument)===e.currentTarget)return A.current=null!=d?d:ne(e.key,x,p)?t:r,void f(A.current);ne(e.key,x,p)?A.current=m?n>=r?v&&n!==i.current.length?-1:t:$(i,{startingIndex:n}):Math.min(r,$(i,{startingIndex:n})):A.current=m?n<=t?v&&-1!==n?i.current.length:r:$(i,{startingIndex:n,decrement:!0}):Math.max(t,$(i,{startingIndex:n,decrement:!0})),f(A.current)}}return l((()=>{s&&(null!=d&&(A.current=d),!T&&o&&I.current&&(P.current(A.current),j(i,A)))}),[o,T,d,i,P,j,s]),l((()=>{s&&o&&(null==a?(!T&&I.current&&null==d||v)&&(A.current=v?-1:te(i),P.current(a),j(i,A)):(A.current=a,P.current(a),j(i,A)))}),[o,T,a,d,g,i,P,j,s,R,v,c.floating,null==L?void 0:L.nodesRef]),l((()=>{if(null==d&&s){if(o&&(ee(O.current,x)||I.current&&(" "===O.current||"Enter"===O.current))){const e=te(i),n=re(i);A.current=function(e,n,t){return _(n,"ArrowUp"===e,t?"ArrowRight"===e:"ArrowLeft"===e)}(O.current,x,p)?v?i.current.length:n:v?-1:e,P.current(A.current),j(i,A)}O.current=""}}),[o,i,d,P,j,s,x,p,v]),l((()=>{s&&!o&&T&&null!=d&&C(c.reference.current)&&c.reference.current.focus()}),[c.reference,d,o,T,s]),l((()=>{var e;s&&(o||(A.current=null!=(e=null!=d?d:a)?e:-1,P.current(null)))}),[o,d,a,s,E,P]),l((()=>{if(s&&!o&&T){var e,n;const t=null==L||null==(e=L.nodesRef.current.find((e=>e.id===R)))||null==(n=e.context)?void 0:n.refs.floating.current;t&&!t.contains(F(k(t)))&&t.focus({preventScroll:!0})}}),[s,o,T,L,R]),l((()=>{I.current=!1,O.current=""})),s?{reference:{...y&&o&&null!=a&&{"aria-activedescendant":M},onKeyDown(e){if(D.current=!0,y&&o)return B(e);"auto"===E&&(I.current=!0),O.current=e.key,g?function(e,n,t){return _(n,t?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(e.key,x,p)&&(K(e),o?(A.current=te(i),f(A.current)):u(!0)):(ee(e.key,x)&&(A.current=null==d?ne(e.key,x,p)?te(i):re(i):d,K(e),u(!0),f(A.current)),y&&!o&&B(e))}},floating:{"aria-orientation":"both"===x?void 0:x,...y&&null!=a&&{"aria-activedescendant":M},onKeyDown:B,onPointerMove(){D.current=!1}},item:{onFocus(e){let{currentTarget:n}=e;const t=i.current.indexOf(n);-1!==t&&f(t)},onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...w&&{onPointerMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=i.current.indexOf(t);-1!==e&&f(e)}},onPointerLeave(){var e;D.current||(f(null),y?(A.current=-1,j(i,A)):null==(e=c.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},ue=function(n,t){var r;let{open:o,dataRef:u}=n,{listRef:c,activeIndex:i,onMatch:a=(()=>{}),enabled:f=!0,findMatch:s=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const g=e.useRef(),p=e.useRef(""),h=e.useRef(null!=(r=null!=m?m:i)?r:-1),b=e.useRef(null);function y(e){if(!e.currentTarget.contains(F(k(e.currentTarget))))return;p.current.length>0&&" "!==p.current[0]&&(u.current.typing=!0," "===e.key&&K(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())}))&&p.current===e.key&&(p.current="",h.current=b.current),p.current+=e.key,clearTimeout(g.current),g.current=setTimeout((()=>{p.current="",h.current=b.current,u.current.typing=!1}),d);const t=h.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],o=s?s(r,p.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(p.current)))),i=o?n.indexOf(o):-1;-1!==i&&(a(i),b.current=i)}return l((()=>{o&&(clearTimeout(g.current),b.current=null,p.current="")}),[o]),l((()=>{var e;o&&""===p.current&&(h.current=null!=(e=null!=m?m:i)?e:-1)}),[o,m,i]),f?{reference:{onKeyDown:y},floating:{onKeyDown:y}}:{}};function ce(n){let{open:t=!1,onOpenChange:r=(()=>{}),placement:o,middleware:c,strategy:i,nodeId:f}=void 0===n?{}:n;const s=b(),d=e.useRef({}),v=e.useState((()=>a()))[0],m=u({placement:o,middleware:c,strategy:i}),g=e.useMemo((()=>({...m,dataRef:d,nodeId:f,events:v,open:t,onOpenChange:r})),[m,d,f,v,t,r]);return l((()=>{const e=null==s?void 0:s.nodesRef.current.find((e=>e.id===f));e&&(e.context=g)})),e.useMemo((()=>({context:g,...m})),[m,g])}export{q as FloatingDelayGroup,U as FloatingFocusManager,E as FloatingNode,S as FloatingOverlay,P as FloatingPortal,w as FloatingTree,A as safePolygon,G as useClick,W as useDelayGroup,Y as useDelayGroupContext,Q as useDismiss,ce as useFloating,y as useFloatingNodeId,h as useFloatingParentNodeId,b as useFloatingTree,Z as useFocus,V as useHover,m as useId,R as useInteractions,oe as useListNavigation,z as useRole,ue as useTypeahead}; | ||
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 f=!1,s=0;const d=()=>"floating-ui-"+s++;const v=e["useId".toString()],m=null!=v?v:function(){const[n,t]=e.useState((()=>f?d():void 0));return l((()=>{null==n&&t(d())}),[]),e.useEffect((()=>{f||(f=!0)}),[]),n},g=e.createContext(null),p=e.createContext(null),h=()=>{var n,t;return null!=(n=null==(t=e.useContext(g))?void 0:t.id)?n:null},b=()=>e.useContext(p),y=()=>{const e=m(),n=b(),t=h();return l((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},E=n=>{let{children:t,id:r}=n;const o=h();return e.createElement(g.Provider,{value:e.useMemo((()=>({id:r,parentId:o})),[r,o])},t)},w=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(p.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 k(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function L(e){var n;return null!=(n=k(e).defaultView)?n:window}function T(e){return!!e&&e instanceof L(e).Element}function C(e){return!!e&&e instanceof L(e).HTMLElement}function I(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=0,debug:o=null}=void 0===e?{}:e,u=!1,c=!1,i=!1;return e=>{let{x:o,y:l,placement:a,refs:f,onClose:s,nodeId:d,tree:v}=e;return function(e){var m;if(clearTimeout(n),!u)return void(i||(i=!0,setTimeout((()=>{u=!0}),1e3/60)));function g(){clearTimeout(n),s()}if(e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:p,clientY:h}=e,b="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&T(f.reference.current)&&f.reference.current.contains(b))return;if(v&&I(v,d).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(null!=(m=f.floating.current)&&m.contains(b))return void(c=!0);if(!f.reference.current||!f.floating.current||null==a||null==o||null==l)return;const y=f.reference.current.getBoundingClientRect(),E=f.floating.current.getBoundingClientRect(),w=a.split("-")[0],x=o>E.right-E.width/2,R=l>E.bottom-E.height/2;if("top"===w&&l>=y.bottom-1||"bottom"===w&&l<=y.top+1||"left"===w&&o>=y.right-1||"right"===w&&o<=y.left+1)return g();switch(w){case"top":if(p>=E.left&&p<=E.right&&h>=E.bottom&&h<=y.top)return;break;case"bottom":if(p>=E.left&&p<=E.right&&h>=y.bottom&&h<=E.top)return;break;case"left":if(p>=E.right&&p<=y.left&&h>=E.top&&h<=E.bottom)return;break;case"right":if(p>=y.right&&p<=E.left&&h>=E.top&&h<=E.bottom)return}if(c)return g();const k=function(e){let[n,t]=e;const o=E.width>y.width,u=E.height>y.height;switch(w){case"top":return[[o?n+r/2:x?n+4*r:n-4*r,t+r+1],[o?n-r/2:x?n+4*r:n-4*r,t+r+1],...[[E.left,x||o?E.bottom-r:E.top],[E.right,x?o?E.bottom-r:E.top:E.bottom-r]]];case"bottom":return[[o?n+r/2:x?n+4*r:n-4*r,t-r],[o?n-r/2:x?n+4*r:n-4*r,t-r],...[[E.left,x||o?E.top+r:E.bottom],[E.right,x?o?E.top+r:E.bottom:E.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?E.right-r:E.left,E.top],[R?u?E.right-r:E.left:E.right-r,E.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?E.left+r:E.right,E.top],[R?u?E.left+r:E.right:E.left+r,E.bottom]]]}}([o,l]);!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,h],k)?g():t&&(n=setTimeout(s,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},P=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 D(){return D=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},D.apply(this,arguments)}const S="data-floating-ui-scroll-lock",F=e.forwardRef((function(n,t){let{lockScroll:r=!1,...o}=n;return l((()=>{if(!r)return;const e=window.pageXOffset,n=window.pageYOffset,t=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;return document.body.hasAttribute(S)?void 0:(Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:"-"+n+"px",left:"-"+e+"px",right:"0",[t]:o+"px"}),document.body.setAttribute(S,""),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[t]:""}),document.body.removeAttribute(S),window.scrollTo(e,n)})}),[r]),e.createElement("div",D({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 N(e){e.preventDefault(),e.stopPropagation()}function j(e){const n=r(e);return l((()=>{n.current=e})),n}function B(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const U=e.forwardRef((function(n,t){return e.createElement("span",D({},n,{ref:t,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function H(n){let{context:{refs:t,nodeId:r,onOpenChange:o},children:u,order:c=["content"],endGuard:l=!0,preventTabbing:a=!1,initialFocus:f=0,returnFocus:s=!0,modal:d=!0}=n;const v=j(c),m=j(o),g=b(),p=e.useCallback((()=>v.current.map((e=>{return C(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(C(e)){var n;return"-"!==(null!=(n=e.getAttribute("tabindex"))?n:"0")[0].trim()}}))),[v,t.floating,t.reference]);return e.useEffect((()=>{const e=0===p().filter((e=>e!==t.floating.current&&e!==t.reference.current)).length;function n(n){if("Tab"===n.key){(a||e)&&N(n);const r=p(),o="composedPath"in n?n.composedPath()[0]:n.target;"reference"===v.current[0]&&o===t.reference.current&&(N(n),n.shiftKey?B(r[r.length-1]):B(r[1])),"floating"===v.current[1]&&o===t.floating.current&&n.shiftKey&&(N(n),B(r[0]))}}const r=k(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[a,p,v,t.floating,t.reference]),e.useEffect((()=>{function e(e){var n;const o=e.relatedTarget;null!=(n=t.floating.current)&&n.contains(o)||!T(t.reference.current)||t.reference.current.contains(o)||g&&I(g,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&&C(o)){!d&&n.addEventListener("focusout",e);const t=d?i(n):null;return()=>{!d&&n.removeEventListener("focusout",e),null==t||t()}}}),[r,g,d,m,p,f,t.floating,t.reference]),e.useEffect((()=>{var e;if(a)return;const n=t.floating.current,r=null!=(e=K(k(n)))?e:K(document);var o;if("number"==typeof f)B(null!=(o=p()[f])?o:n);else if(C(null==f?void 0:f.current)){var u;B(null!=(u=f.current)?u:n)}return()=>{s&&C(r)&&B(r)}}),[a,p,f,d,s,t.floating]),e.createElement(e.Fragment,null,d&&e.createElement(U,{onFocus:e=>{N(e);const n=p();"reference"===c[0]?B(n[0]):B(n[n.length-1])}}),e.cloneElement(u,c.includes("floating")?{tabIndex:0}:{}),d&&l&&e.createElement(U,{onFocus:e=>{N(e),B(p()[0])}}))}function V(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:f,dataRef:s,events:d,refs:v}=n,m=b(),g=j(f),p=j(u),h=e.useRef(),y=e.useRef(),E=e.useRef(),w=e.useRef(),x=e.useRef(!0);l((()=>{r&&(a||(h.current=void 0))})),e.useEffect((()=>{if(r)return d.on("dismiss",e),()=>{d.off("dismiss",e)};function e(){clearTimeout(y.current),clearTimeout(w.current),x.current=!0}}),[r,d,v.floating]),e.useEffect((()=>{if(!r||!p.current)return;function e(){var e;null!=(e=s.current.openEvent)&&e.type.includes("mouse")&&g.current(!1)}const n=k(v.floating.current).documentElement;return n.addEventListener("mouseleave",e),()=>{n.removeEventListener("mouseleave",e)}}),[v.floating,g,r,p,s]);const R=e.useCallback((function(e){void 0===e&&(e=!0),o&&!E.current?(clearTimeout(y.current),y.current=setTimeout((()=>g.current(!1)),V(o,"close",h.current))):e&&g.current(!1)}),[o,g]),L=e.useCallback((()=>{E.current&&(k(v.floating.current).removeEventListener("pointermove",E.current),E.current=void 0)}),[v.floating]);if(e.useEffect((()=>{a||L()}),[a,r,L]),e.useEffect((()=>{if(!r)return;function e(e){clearTimeout(y.current),x.current=!1,a||c&&"mouse"!==h.current||i>0&&0===V(o,"open")||(s.current.openEvent=e,o?y.current=setTimeout((()=>{g.current(!0)}),V(o,"open",h.current)):g.current(!0))}function t(e){var t,r;if("click"===(null==(t=s.current.openEvent)?void 0:t.type)||"pointerdown"===(null==(r=s.current.openEvent)?void 0:r.type))return;const o=k(v.floating.current);if(clearTimeout(w.current),p.current)return clearTimeout(y.current),E.current&&o.removeEventListener("pointermove",E.current),E.current=p.current({...n,tree:m,x:e.clientX,y:e.clientY,onClose(){L(),R()}}),void o.addEventListener("pointermove",E.current);R()}const u=v.reference.current;return T(u)?(u.addEventListener("mousemove",e,{once:!0}),u.addEventListener("mouseenter",e),u.addEventListener("mouseleave",t),()=>{u.removeEventListener("mousemove",e),u.removeEventListener("mouseenter",e),u.removeEventListener("mouseleave",t)}):void 0}),[r,R,n,o,p,s,c,g,a,m,i,L,v.reference,v.floating]),!r)return{};function C(e){h.current=e.pointerType}return{reference:{onPointerDown:C,onPointerEnter:C,onMouseMove(){a||0===i||(clearTimeout(w.current),w.current=setTimeout((()=>{x.current||f(!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=j(o);e.useEffect((()=>{c&&a.current&&(l((e=>({...e,delay:{open:1,close:V(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:f=!1}=void 0===t?{}:t;const s=e.useRef();function d(){return C(c.reference.current)&&"BUTTON"===c.reference.current.tagName}return i?{reference:{onPointerDown(e){if(s.current=e.pointerType,("mouse"!==s.current||!f)&&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&&s.current)s.current=void 0;else if("mouse"!==s.current||!f){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){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:f=!0,outsidePointerDown:s=!0,referencePointerDown:d=!1,ancestorScroll:v=!1,bubbles:m=!0}=void 0===t?{}:t;const g=b(),p=j(u),h=e.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(K(k(c.floating.current)))}),[c.floating]),y=e.useCallback((()=>{C(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&&!h())return;i.emit("dismiss"),p.current(!1),y()}}function n(e){const n=g&&I(g,l).some((n=>{var t;return Q(e,null==(t=n.context)?void 0:t.refs.floating.current)}));Q(e,c.floating.current)||T(c.reference.current)&&Q(e,c.reference.current)||n||(m||h())&&(i.emit("dismiss"),p.current(!1),y())}function t(){p.current(!1)}const u=k(c.floating.current);f&&u.addEventListener("keydown",e),s&&u.addEventListener("mousedown",n);const d=(v?[...T(c.reference.current)?o(c.reference.current):[],...T(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}))),()=>{f&&u.removeEventListener("keydown",e),s&&u.removeEventListener("mousedown",n),d.forEach((e=>e.removeEventListener("scroll",t)))}}),[f,s,i,g,l,r,p,y,v,a,m,h,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 f=e.useRef(!1);return e.useEffect((()=>{var e;if(!l)return;const n=null!=(e=k(c.floating.current).defaultView)?e:window;function t(){f.current=!r}function o(){setTimeout((()=>{f.current=!1}))}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;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 _(e,n){let{startingIndex:t=-1,decrement:r=!1}=void 0===n?{}:n;const o=e.current;let u=t;do{var c,i;u+=r?-1:1}while(u>=0&&u<=o.length-1&&(null==o[u]||null!=(c=o[u])&&c.hasAttribute("disabled")||"true"===(null==(i=o[u])?void 0:i.getAttribute("aria-disabled"))));return u}function ee(e,n,t){switch(e){case"vertical":return n;case"horizontal":return t;default:return n||t}}function ne(e,n){return ee(n,"ArrowUp"===e||"ArrowDown"===e,"ArrowLeft"===e||"ArrowRight"===e)}function te(e,n,t){return ee(n,"ArrowDown"===e,t?"ArrowLeft"===e:"ArrowRight"===e)}function re(e){return _(e)}function oe(e){return _(e,{decrement:!0,startingIndex:e.current.length})}const ue=function(n,t){let{open:o,onOpenChange:u,refs:c}=n,{listRef:i,activeIndex:a,onNavigate:f,enabled:s=!0,selectedIndex:d=null,allowEscape:v=!1,loop:m=!1,nested:g=!1,rtl:p=!1,virtual:y=!1,focusItemOnOpen:E="auto",focusItemOnHover:w=!0,orientation:x="vertical"}=void 0===t?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:t;const R=h(),L=b(),T=function(e){const n=r();return l((()=>{n.current=e}),[e]),n.current}(o),I=e.useRef("auto"!==E&&E),A=e.useRef(null!=d?d:-1),O=e.useRef(""),M=j(f),P=e.useRef(!1),[D,S]=e.useState(),F=e.useCallback(((e,n)=>{var t,r;y?S(null==(t=e.current[n.current])?void 0:t.id):null==(r=e.current[n.current])||r.focus({preventScroll:!0})}),[y]);function B(e){if(P.current=!0,g&&function(e,n,t){return ee(n,t?"ArrowRight"===e:"ArrowLeft"===e,"ArrowUp"===e)}(e.key,x,p))return N(e),u(!1),void(C(c.reference.current)&&c.reference.current.focus());const n=A.current,t=re(i),r=oe(i);if("Home"===e.key&&(A.current=t,f(A.current)),"End"===e.key&&(A.current=r,f(A.current)),ne(e.key,x)){if(N(e),!y&&K(e.currentTarget.ownerDocument)===e.currentTarget)return A.current=null!=d?d:te(e.key,x,p)?t:r,void f(A.current);te(e.key,x,p)?A.current=m?n>=r?v&&n!==i.current.length?-1:t:_(i,{startingIndex:n}):Math.min(r,_(i,{startingIndex:n})):A.current=m?n<=t?v&&-1!==n?i.current.length:r:_(i,{startingIndex:n,decrement:!0}):Math.max(t,_(i,{startingIndex:n,decrement:!0})),f(A.current)}}return l((()=>{s&&(null!=d&&(A.current=d),!T&&o&&I.current&&(M.current(A.current),F(i,A)))}),[o,T,d,i,M,F,s]),l((()=>{s&&o&&(null==a?(!T&&I.current&&null==d||v)&&(A.current=v?-1:re(i),M.current(a),F(i,A)):(A.current=a,M.current(a),F(i,A)))}),[o,T,a,d,g,i,M,F,s,R,v,c.floating,null==L?void 0:L.nodesRef]),l((()=>{if(null==d&&s){if(o&&(ne(O.current,x)||I.current&&(" "===O.current||"Enter"===O.current))){const e=re(i),n=oe(i);A.current=function(e,n,t){return ee(n,"ArrowUp"===e,t?"ArrowRight"===e:"ArrowLeft"===e)}(O.current,x,p)?v?i.current.length:n:v?-1:e,M.current(A.current),F(i,A)}O.current=""}}),[o,i,d,M,F,s,x,p,v]),l((()=>{s&&!o&&T&&null!=d&&C(c.reference.current)&&c.reference.current.focus()}),[c.reference,d,o,T,s]),l((()=>{var e;s&&(o||(A.current=null!=(e=null!=d?d:a)?e:-1,M.current(null)))}),[o,d,a,s,E,M]),l((()=>{if(s&&!o&&T){var e,n;const t=null==L||null==(e=L.nodesRef.current.find((e=>e.id===R)))||null==(n=e.context)?void 0:n.refs.floating.current;t&&!t.contains(K(k(t)))&&t.focus({preventScroll:!0})}}),[s,o,T,L,R]),l((()=>{I.current=!1,O.current=""})),s?{reference:{...y&&o&&null!=a&&{"aria-activedescendant":D},onKeyDown(e){if(P.current=!0,y&&o)return B(e);"auto"===E&&(I.current=!0),O.current=e.key,g?function(e,n,t){return ee(n,t?"ArrowLeft"===e:"ArrowRight"===e,"ArrowDown"===e)}(e.key,x,p)&&(N(e),o?(A.current=re(i),f(A.current)):u(!0)):(ne(e.key,x)&&(A.current=null==d?te(e.key,x,p)?re(i):oe(i):d,N(e),u(!0),f(A.current)),y&&!o&&B(e))}},floating:{"aria-orientation":"both"===x?void 0:x,...y&&null!=a&&{"aria-activedescendant":D},onKeyDown:B,onPointerMove(){P.current=!1}},item:{onFocus(e){let{currentTarget:n}=e;const t=i.current.indexOf(n);-1!==t&&f(t)},onClick:e=>{let{currentTarget:n}=e;return n.focus({preventScroll:!0})},...w&&{onPointerMove(e){let{currentTarget:n}=e;const t=n;if(t){const e=i.current.indexOf(t);-1!==e&&f(e)}},onPointerLeave(){var e;P.current||(f(null),y?(A.current=-1,F(i,A)):null==(e=c.floating.current)||e.focus({preventScroll:!0}))}}}}:{}},ce=function(n,t){var r;let{open:o,dataRef:u}=n,{listRef:c,activeIndex:i,onMatch:a=(()=>{}),enabled:f=!0,findMatch:s=null,resetMs:d=1e3,ignoreKeys:v=[],selectedIndex:m=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const g=e.useRef(),p=e.useRef(""),h=e.useRef(null!=(r=null!=m?m:i)?r:-1),b=e.useRef(null);function y(e){if(!e.currentTarget.contains(K(k(e.currentTarget))))return;p.current.length>0&&" "!==p.current[0]&&(u.current.typing=!0," "===e.key&&N(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())}))&&p.current===e.key&&(p.current="",h.current=b.current),p.current+=e.key,clearTimeout(g.current),g.current=setTimeout((()=>{p.current="",h.current=b.current,u.current.typing=!1}),d);const t=h.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,(null!=t?t:0)+1)],o=s?s(r,p.current):r.find((e=>0===(null==e?void 0:e.toLocaleLowerCase().indexOf(p.current)))),i=o?n.indexOf(o):-1;-1!==i&&(a(i),b.current=i)}return l((()=>{o&&(clearTimeout(g.current),b.current=null,p.current="")}),[o]),l((()=>{var e;o&&""===p.current&&(h.current=null!=(e=null!=m?m:i)?e:-1)}),[o,m,i]),f?{reference:{onKeyDown:y},floating:{onKeyDown:y}}:{}};function ie(n){let{open:t=!1,onOpenChange:r=(()=>{}),whileElementsMounted:o,placement:c,middleware:i,strategy:f,nodeId:s}=void 0===n?{}:n;const d=b(),v=e.useRef({}),m=e.useState((()=>a()))[0],g=u({placement:c,middleware:i,strategy:f,whileElementsMounted:o}),p=e.useMemo((()=>({...g,dataRef:v,nodeId:s,events:m,open:t,onOpenChange:r})),[g,v,s,m,t,r]);return l((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===s));e&&(e.context=p)})),e.useMemo((()=>({context:p,...g})),[g,p])}export{W as FloatingDelayGroup,H as FloatingFocusManager,E as FloatingNode,F as FloatingOverlay,P as FloatingPortal,w as FloatingTree,A as safePolygon,J as useClick,z as useDelayGroup,q as useDelayGroupContext,Z as useDismiss,ie as useFloating,y as useFloatingNodeId,h as useFloatingParentNodeId,M as useFloatingPortalNode,b as useFloatingTree,$ as useFocus,X as useHover,m as useId,R as useInteractions,ue as useListNavigation,G as useRole,ce as useTypeahead}; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(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"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.React,e.FloatingUIReactDOM,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(t),c="undefined"!=typeof document?t.useLayoutEffect:t.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),g=u.createContext(null),m=()=>{var e,t;return null!=(e=null==(t=u.useContext(v))?void 0:t.id)?e:null},p=()=>u.useContext(g);function y(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 h(e){var t;return null!=(t=null==e?void 0:e.ownerDocument)?t:document}function b(e){var t;return null!=(t=h(e).defaultView)?t:window}function E(e){return!!e&&e instanceof b(e).Element}function w(e){return!!e&&e instanceof b(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";function R(){return R=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},R.apply(this,arguments)}const O="data-floating-ui-scroll-lock",T=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return c((()=>{if(!n)return;const e=window.pageXOffset,t=window.pageYOffset,r=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;return document.body.hasAttribute(O)?void 0:(Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:"-"+t+"px",left:"-"+e+"px",right:"0",[r]:o+"px"}),document.body.setAttribute(O,""),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[r]:""}),document.body.removeAttribute(O),window.scrollTo(e,t)})}),[n]),u.createElement("div",R({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var I=new WeakMap,C=new WeakMap,L={},M=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];L[n]||(L[n]=new WeakMap);var o=L[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=(I.get(e)||0)+1,a=(o.get(e)||0)+1;I.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(),M++,function(){u.forEach((function(e){var t=I.get(e)-1,r=o.get(e)-1;I.set(e,t),o.set(e,r),t||(C.has(e)||e.removeAttribute("aria-hidden"),C.delete(e)),r||e.removeAttribute(n)})),--M||(I=new WeakMap,I=new WeakMap,C=new WeakMap,L={})}};function A(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 D(e){e.preventDefault(),e.stopPropagation()}function F(e){const n=t.useRef(e);return c((()=>{n.current=e})),n}function S(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const j=u.forwardRef((function(e,t){return u.createElement("span",R({},e,{ref:t,tabIndex:0,style:{position:"fixed",opacity:"0",pointerEvents:"none",outline:"0"}}))}));function N(e,t,n){return n&&"mouse"!==n?0:"number"==typeof e?e:null==e?void 0:e[t]}const K=u.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),W=()=>u.useContext(K);function B(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)}const U="ArrowUp",q="ArrowDown",H="ArrowLeft",G="ArrowRight";function V(e,t){let{startingIndex:n=-1,decrement:r=!1}=void 0===t?{}:t;const o=e.current;let u=n;do{var c,i;u+=r?-1:1}while(u>=0&&u<=o.length-1&&(null==o[u]||null!=(c=o[u])&&c.hasAttribute("disabled")||"true"===(null==(i=o[u])?void 0:i.getAttribute("aria-disabled"))));return u}function _(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function X(e,t){return _(t,e===U||e===q,e===H||e===G)}function Y(e,t,n){return _(t,e===q,n?e===H:e===G)}function z(e){return V(e)}function J(e){return V(e,{decrement:!0,startingIndex:e.current.length})}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(K.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=F(c),v=F(r),g=p(),m=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]);return u.useEffect((()=>{const e=0===m().filter((e=>e!==t.floating.current&&e!==t.reference.current)).length;function n(n){if("Tab"===n.key){(l||e)&&D(n);const r=m(),o="composedPath"in n?n.composedPath()[0]:n.target;"reference"===d.current[0]&&o===t.reference.current&&(D(n),n.shiftKey?S(r[r.length-1]):S(r[1])),"floating"===d.current[1]&&o===t.floating.current&&n.shiftKey&&(D(n),S(r[0]))}}const r=h(t.floating.current);return r.addEventListener("keydown",n),()=>{r.removeEventListener("keydown",n)}}),[l,m,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)||g&&x(g,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)){!f&&r.addEventListener("focusout",e);const t=f?P(r):null;return()=>{!f&&r.removeEventListener("focusout",e),null==t||t()}}}),[n,g,f,v,m,a,t.floating,t.reference]),u.useEffect((()=>{var e;if(l)return;const n=t.floating.current,r=null!=(e=A(h(n)))?e:A(document);var o;if("number"==typeof a)S(null!=(o=m()[a])?o:n);else if(w(null==a?void 0:a.current)){var u;S(null!=(u=a.current)?u:n)}return()=>{s&&w(r)&&S(r)}}),[l,m,a,f,s,t.floating]),u.createElement(u.Fragment,null,f&&u.createElement(j,{onFocus:e=>{D(e);const t=m();"reference"===c[0]?S(t[0]):S(t[t.length-1])}}),u.cloneElement(o,c.includes("floating")?{tabIndex:0}:{}),f&&i&&u.createElement(j,{onFocus:e=>{D(e),S(m()[0])}}))},e.FloatingNode=e=>{let{children:t,id:n}=e;const r=m();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=u.useRef(null);return c((()=>{if(o)return;const e=document.getElementById(n);e?a.current=e:(a.current=document.createElement("div"),a.current.id=n),document.body.contains(a.current)||document.body.appendChild(a.current),l(!0)}),[n,o]),o?r.createPortal(t,o):i&&a.current?r.createPortal(t,a.current):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(g.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=0,debug:o=null}=void 0===e?{}:e,u=!1,c=!1,i=!1;return e=>{let{x:o,y:l,placement:a,refs:s,onClose:f,nodeId:d,tree:v}=e;return function(e){var g;if(clearTimeout(t),!u)return void(i||(i=!0,setTimeout((()=>{u=!0}),1e3/60)));function m(){clearTimeout(t),f()}if(e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:p,clientY:y}=e,h="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&E(s.reference.current)&&s.reference.current.contains(h))return;if(v&&x(v,d).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if(null!=(g=s.floating.current)&&g.contains(h))return void(c=!0);if(!s.reference.current||!s.floating.current||null==a||null==o||null==l)return;const b=s.reference.current.getBoundingClientRect(),w=s.floating.current.getBoundingClientRect(),k=a.split("-")[0],R=o>w.right-w.width/2,O=l>w.bottom-w.height/2;if("top"===k&&l>=b.bottom-1||"bottom"===k&&l<=b.top+1||"left"===k&&o>=b.right-1||"right"===k&&o<=b.left+1)return m();switch(k){case"top":if(p>=w.left&&p<=w.right&&y>=w.bottom&&y<=b.top)return;break;case"bottom":if(p>=w.left&&p<=w.right&&y>=b.bottom&&y<=w.top)return;break;case"left":if(p>=w.right&&p<=b.left&&y>=w.top&&y<=w.bottom)return;break;case"right":if(p>=b.right&&p<=w.left&&y>=w.top&&y<=w.bottom)return}if(c)return m();const T=function(e){let[t,n]=e;const o=w.width>b.width,u=w.height>b.height;switch(k){case"top":return[[o?t+r/2:R?t+4*r:t-4*r,n+r+1],[o?t-r/2:R?t+4*r:t-4*r,n+r+1],...[[w.left,R||o?w.bottom-r:w.top],[w.right,R?o?w.bottom-r:w.top:w.bottom-r]]];case"bottom":return[[o?t+r/2:R?t+4*r:t-4*r,n-r],[o?t-r/2:R?t+4*r:t-4*r,n-r],...[[w.left,R||o?w.top+r:w.bottom],[w.right,R?o?w.top+r:w.bottom:w.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:O?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:O?n+4*r:n-4*r];return[...[[O||u?w.right-r:w.left,w.top],[O?u?w.right-r:w.left:w.right-r,w.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:O?n+4*r:n-4*r],[t-r,u?n-r/2:O?n+4*r:n-4*r],...[[O||u?w.left+r:w.right,w.top],[O?u?w.left+r:w.right:w.left+r,w.bottom]]]}}([o,l]);!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}([p,y],T)?m():n&&(t=setTimeout(f,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){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}=W(),a=F(r);u.useEffect((()=>{c&&a.current&&(l((e=>({...e,delay:{open:1,close:N(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=W,e.useDismiss=function(e,t){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:g=!0}=void 0===t?{}:t;const m=p(),y=F(o),b=u.useCallback((()=>{var e;return null==(e=c.floating.current)?void 0:e.contains(A(h(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(!g&&!b())return;i.emit("dismiss"),y.current(!1),k()}}function t(e){const t=m&&x(m,l).some((t=>{var n;return B(e,null==(n=t.context)?void 0:n.refs.floating.current)}));B(e,c.floating.current)||E(c.reference.current)&&B(e,c.reference.current)||t||(g||b())&&(i.emit("dismiss"),y.current(!1),k())}function o(){y.current(!1)}const u=h(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("mousedown",t);const d=(v?[...E(c.reference.current)?n.getOverflowAncestors(c.reference.current):[],...E(c.floating.current)?n.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",t),d.forEach((e=>e.removeEventListener("scroll",o)))}}),[s,f,i,m,l,r,y,k,v,a,g,b,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),o(!1))}}}:{}},e.useFloating=function(e){let{open:t=!1,onOpenChange:r=(()=>{}),placement:o,middleware:l,strategy:a,nodeId:s}=void 0===e?{}:e;const f=p(),d=u.useRef({}),v=u.useState((()=>i()))[0],g=n.useFloating({placement:o,middleware:l,strategy:a}),m=u.useMemo((()=>({...g,dataRef:d,nodeId:s,events:v,open:t,onOpenChange:r})),[g,d,s,v,t,r]);return c((()=>{const e=null==f?void 0:f.nodesRef.current.find((e=>e.id===s));e&&(e.context=m)})),u.useMemo((()=>({context:m,...g})),[g,m])},e.useFloatingNodeId=()=>{const e=d(),t=p(),n=m();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=m,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(!1);return u.useEffect((()=>{var e;if(!l)return;const t=null!=(e=h(c.floating.current).defaultView)?e:window;function r(){s.current=!n}function o(){setTimeout((()=>{s.current=!1}))}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(){s.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:t}=e;s.current=!(!t||!a)},onFocus(e){var t,n,u;s.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)||(s.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,g=p(),m=F(s),y=F(o),b=u.useRef(),w=u.useRef(),x=u.useRef(),k=u.useRef(),R=u.useRef(!0);c((()=>{n&&(a||(b.current=void 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||!y.current)return;function e(){var e;null!=(e=f.current.openEvent)&&e.type.includes("mouse")&&m.current(!1)}const t=h(v.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[v.floating,m,n,y,f]);const O=u.useCallback((function(e){void 0===e&&(e=!0),r&&!x.current?(clearTimeout(w.current),w.current=setTimeout((()=>m.current(!1)),N(r,"close",b.current))):e&&m.current(!1)}),[r,m]),T=u.useCallback((()=>{x.current&&(h(v.floating.current).removeEventListener("pointermove",x.current),x.current=void 0)}),[v.floating]);if(u.useEffect((()=>{a||T()}),[a,n,T]),u.useEffect((()=>{if(!n)return;function t(e){clearTimeout(w.current),R.current=!1,a||i&&"mouse"!==b.current||l>0&&0===N(r,"open")||(f.current.openEvent=e,r?w.current=setTimeout((()=>{m.current(!0)}),N(r,"open",b.current)):m.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=h(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:g,x:t.clientX,y:t.clientY,onClose(){T(),O()}}),void o.addEventListener("pointermove",x.current);O()}const u=v.reference.current;return E(u)?(u.addEventListener("mousemove",t,{once:!0}),u.addEventListener("mouseenter",t),u.addEventListener("mouseleave",o),()=>{u.removeEventListener("mousemove",t),u.removeEventListener("mouseenter",t),u.removeEventListener("mouseleave",o)}):void 0}),[n,O,e,r,y,f,i,m,a,g,l,T,v.reference,v.floating]),!n)return{};function I(e){b.current=e.pointerType}return{reference:{onPointerDown:I,onPointerEnter:I,onMouseMove(){a||0===l||(clearTimeout(k.current),k.current=setTimeout((()=>{R.current||s(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(w.current)},onMouseLeave:()=>O(!1)}}},e.useId=d,e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:t=>y(t,e,"reference"),getFloatingProps:t=>y(t,e,"floating"),getItemProps:t=>y(t,e,"item")}},e.useListNavigation=function(e,n){let{open:r,onOpenChange:o,refs:i}=e,{listRef:l,activeIndex:a,onNavigate:s,enabled:f=!0,selectedIndex:d=null,allowEscape:v=!1,loop:g=!1,nested:y=!1,rtl:b=!1,virtual:E=!1,focusItemOnOpen:x="auto",focusItemOnHover:k=!0,orientation:R="vertical"}=void 0===n?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:n;const O=m(),T=p(),I=function(e){const n=t.useRef();return c((()=>{n.current=e}),[e]),n.current}(r),C=u.useRef("auto"!==x&&x),L=u.useRef(null!=d?d:-1),M=u.useRef(""),P=F(s),S=u.useRef(!1),[j,N]=u.useState(),K=u.useCallback(((e,t)=>{var n,r;E?N(null==(n=e.current[t.current])?void 0:n.id):null==(r=e.current[t.current])||r.focus({preventScroll:!0})}),[E]);function W(e){if(S.current=!0,y&&function(e,t,n){return _(t,n?e===G:e===H,e===U)}(e.key,R,b))return D(e),o(!1),void(w(i.reference.current)&&i.reference.current.focus());const t=L.current,n=z(l),r=J(l);if("Home"===e.key&&(L.current=n,s(L.current)),"End"===e.key&&(L.current=r,s(L.current)),X(e.key,R)){if(D(e),!E&&A(e.currentTarget.ownerDocument)===e.currentTarget)return L.current=null!=d?d:Y(e.key,R,b)?n:r,void s(L.current);Y(e.key,R,b)?L.current=g?t>=r?v&&t!==l.current.length?-1:n:V(l,{startingIndex:t}):Math.min(r,V(l,{startingIndex:t})):L.current=g?t<=n?v&&-1!==t?l.current.length:r:V(l,{startingIndex:t,decrement:!0}):Math.max(n,V(l,{startingIndex:t,decrement:!0})),s(L.current)}}return c((()=>{f&&(null!=d&&(L.current=d),!I&&r&&C.current&&(P.current(L.current),K(l,L)))}),[r,I,d,l,P,K,f]),c((()=>{f&&r&&(null==a?(!I&&C.current&&null==d||v)&&(L.current=v?-1:z(l),P.current(a),K(l,L)):(L.current=a,P.current(a),K(l,L)))}),[r,I,a,d,y,l,P,K,f,O,v,i.floating,null==T?void 0:T.nodesRef]),c((()=>{if(null==d&&f){if(r&&(X(M.current,R)||C.current&&(" "===M.current||"Enter"===M.current))){const e=z(l),t=J(l);L.current=function(e,t,n){return _(t,e===U,n?e===G:e===H)}(M.current,R,b)?v?l.current.length:t:v?-1:e,P.current(L.current),K(l,L)}M.current=""}}),[r,l,d,P,K,f,R,b,v]),c((()=>{f&&!r&&I&&null!=d&&w(i.reference.current)&&i.reference.current.focus()}),[i.reference,d,r,I,f]),c((()=>{var e;f&&(r||(L.current=null!=(e=null!=d?d:a)?e:-1,P.current(null)))}),[r,d,a,f,x,P]),c((()=>{if(f&&!r&&I){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(A(h(n)))&&n.focus({preventScroll:!0})}}),[f,r,I,T,O]),c((()=>{C.current=!1,M.current=""})),f?{reference:{...E&&r&&null!=a&&{"aria-activedescendant":j},onKeyDown(e){if(S.current=!0,E&&r)return W(e);"auto"===x&&(C.current=!0),M.current=e.key,y?function(e,t,n){return _(t,n?e===H:e===G,e===q)}(e.key,R,b)&&(D(e),r?(L.current=z(l),s(L.current)):o(!0)):(X(e.key,R)&&(L.current=null==d?Y(e.key,R,b)?z(l):J(l):d,D(e),o(!0),s(L.current)),E&&!r&&W(e))}},floating:{"aria-orientation":"both"===R?void 0:R,...E&&null!=a&&{"aria-activedescendant":j},onKeyDown:W,onPointerMove(){S.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=l.current.indexOf(t);-1!==n&&s(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...k&&{onPointerMove(e){let{currentTarget:t}=e;const n=t;if(n){const e=l.current.indexOf(n);-1!==e&&s(e)}},onPointerLeave(){var e;S.current||(s(null),E?(L.current=-1,K(l,L)):null==(e=i.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:g=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const m=u.useRef(),p=u.useRef(""),y=u.useRef(null!=(n=null!=g?g:l)?n:-1),b=u.useRef(null);function E(e){if(!e.currentTarget.contains(A(h(e.currentTarget))))return;p.current.length>0&&" "!==p.current[0]&&(o.current.typing=!0," "===e.key&&D(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="",y.current=b.current),p.current+=e.key,clearTimeout(m.current),m.current=setTimeout((()=>{p.current="",y.current=b.current,o.current.typing=!1}),d);const n=y.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),b.current=c)}return c((()=>{r&&(clearTimeout(m.current),b.current=null,p.current="")}),[r]),c((()=>{var e;r&&""===p.current&&(y.current=null!=(e=null!=g?g:l)?e:-1)}),[r,g,l]),s?{reference:{onKeyDown:E},floating:{onKeyDown:E}}:{}},Object.keys(n).forEach((function(t){"default"===t||e.hasOwnProperty(t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(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"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.React,e.FloatingUIReactDOM,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(t),c="undefined"!=typeof document?t.useLayoutEffect:t.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),g=u.createContext(null),m=()=>{var e,t;return null!=(e=null==(t=u.useContext(v))?void 0:t.id)?e:null},p=()=>u.useContext(g);function h(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 b(e){var t;return null!=(t=y(e).defaultView)?t:window}function E(e){return!!e&&e instanceof b(e).Element}function w(e){return!!e&&e instanceof b(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 O(){return O=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},O.apply(this,arguments)}const T="data-floating-ui-scroll-lock",I=u.forwardRef((function(e,t){let{lockScroll:n=!1,...r}=e;return c((()=>{if(!n)return;const e=window.pageXOffset,t=window.pageYOffset,r=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",o=window.innerWidth-document.documentElement.clientWidth;return document.body.hasAttribute(T)?void 0:(Object.assign(document.body.style,{position:"fixed",overflow:"hidden",top:"-"+t+"px",left:"-"+e+"px",right:"0",[r]:o+"px"}),document.body.setAttribute(T,""),()=>{Object.assign(document.body.style,{position:"",overflow:"",top:"",left:"",right:"",[r]:""}),document.body.removeAttribute(T),window.scrollTo(e,t)})}),[n]),u.createElement("div",O({ref:t},r,{style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...r.style}}))}));var C=new WeakMap,L=new WeakMap,M={},P=0,A=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=(C.get(e)||0)+1,a=(o.get(e)||0)+1;C.set(e,i),o.set(e,a),u.push(e),1===i&&r&&L.set(e,!0),1===a&&e.setAttribute(n,"true"),r||e.setAttribute("aria-hidden","true")}}))};return l(t),c.clear(),P++,function(){u.forEach((function(e){var t=C.get(e)-1,r=o.get(e)-1;C.set(e,t),o.set(e,r),t||(L.has(e)||e.removeAttribute("aria-hidden"),L.delete(e)),r||e.removeAttribute(n)})),--P||(C=new WeakMap,C=new WeakMap,L=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 n=t.useRef(e);return c((()=>{n.current=e})),n}function j(e){requestAnimationFrame((()=>{null==e||e.focus()}))}const N=u.forwardRef((function(e,t){return u.createElement("span",O({},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:()=>{}}),B=()=>u.useContext(W);function U(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)}const q="ArrowUp",H="ArrowDown",G="ArrowLeft",V="ArrowRight";function _(e,t){let{startingIndex:n=-1,decrement:r=!1}=void 0===t?{}:t;const o=e.current;let u=n;do{var c,i;u+=r?-1:1}while(u>=0&&u<=o.length-1&&(null==o[u]||null!=(c=o[u])&&c.hasAttribute("disabled")||"true"===(null==(i=o[u])?void 0:i.getAttribute("aria-disabled"))));return u}function X(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Y(e,t){return X(t,e===q||e===H,e===G||e===V)}function z(e,t,n){return X(t,e===H,n?e===G:e===V)}function J(e){return _(e)}function Q(e){return _(e,{decrement:!0,startingIndex:e.current.length})}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),g=p(),m=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]);return u.useEffect((()=>{const e=0===m().filter((e=>e!==t.floating.current&&e!==t.reference.current)).length;function n(n){if("Tab"===n.key){(l||e)&&F(n);const r=m(),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,m,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)||g&&x(g,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)){!f&&r.addEventListener("focusout",e);const t=f?A(r):null;return()=>{!f&&r.removeEventListener("focusout",e),null==t||t()}}}),[n,g,f,v,m,a,t.floating,t.reference]),u.useEffect((()=>{var e;if(l)return;const n=t.floating.current,r=null!=(e=D(y(n)))?e:D(document);var o;if("number"==typeof a)j(null!=(o=m()[a])?o:n);else if(w(null==a?void 0:a.current)){var u;j(null!=(u=a.current)?u:n)}return()=>{s&&w(r)&&j(r)}}),[l,m,a,f,s,t.floating]),u.createElement(u.Fragment,null,f&&u.createElement(N,{onFocus:e=>{F(e);const t=m();"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=>{F(e),j(m()[0])}}))},e.FloatingNode=e=>{let{children:t,id:n}=e;const r=m();return u.createElement(v.Provider,{value:u.useMemo((()=>({id:n,parentId:r})),[n,r])},t)},e.FloatingOverlay=I,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(g.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=0,debug:o=null}=void 0===e?{}:e,u=!1,c=!1,i=!1;return e=>{let{x:o,y:l,placement:a,refs:s,onClose:f,nodeId:d,tree:v}=e;return function(e){var g;if(clearTimeout(t),!u)return void(i||(i=!0,setTimeout((()=>{u=!0}),1e3/60)));function m(){clearTimeout(t),f()}if(e.pointerType&&"mouse"!==e.pointerType)return;const{clientX:p,clientY:h}=e,y="composedPath"in e?e.composedPath()[0]:e.target;if("pointermove"===e.type&&E(s.reference.current)&&s.reference.current.contains(y))return;if(v&&x(v,d).some((e=>{let{context:t}=e;return null==t?void 0:t.open})))return;if(null!=(g=s.floating.current)&&g.contains(y))return void(c=!0);if(!s.reference.current||!s.floating.current||null==a||null==o||null==l)return;const b=s.reference.current.getBoundingClientRect(),w=s.floating.current.getBoundingClientRect(),k=a.split("-")[0],R=o>w.right-w.width/2,O=l>w.bottom-w.height/2;if("top"===k&&l>=b.bottom-1||"bottom"===k&&l<=b.top+1||"left"===k&&o>=b.right-1||"right"===k&&o<=b.left+1)return m();switch(k){case"top":if(p>=w.left&&p<=w.right&&h>=w.bottom&&h<=b.top)return;break;case"bottom":if(p>=w.left&&p<=w.right&&h>=b.bottom&&h<=w.top)return;break;case"left":if(p>=w.right&&p<=b.left&&h>=w.top&&h<=w.bottom)return;break;case"right":if(p>=b.right&&p<=w.left&&h>=w.top&&h<=w.bottom)return}if(c)return m();const T=function(e){let[t,n]=e;const o=w.width>b.width,u=w.height>b.height;switch(k){case"top":return[[o?t+r/2:R?t+4*r:t-4*r,n+r+1],[o?t-r/2:R?t+4*r:t-4*r,n+r+1],...[[w.left,R||o?w.bottom-r:w.top],[w.right,R?o?w.bottom-r:w.top:w.bottom-r]]];case"bottom":return[[o?t+r/2:R?t+4*r:t-4*r,n-r],[o?t-r/2:R?t+4*r:t-4*r,n-r],...[[w.left,R||o?w.top+r:w.bottom],[w.right,R?o?w.top+r:w.bottom:w.top+r]]];case"left":{const e=[t+r+1,u?n+r/2:O?n+4*r:n-4*r],o=[t+r+1,u?n-r/2:O?n+4*r:n-4*r];return[...[[O||u?w.right-r:w.left,w.top],[O?u?w.right-r:w.left:w.right-r,w.bottom]],e,o]}case"right":return[[t-r,u?n+r/2:O?n+4*r:n-4*r],[t-r,u?n-r/2:O?n+4*r:n-4*r],...[[O||u?w.left+r:w.right,w.top],[O?u?w.left+r:w.right:w.left+r,w.bottom]]]}}([o,l]);!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}([p,h],T)?m():n&&(t=setTimeout(f,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){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}=B(),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=B,e.useDismiss=function(e,t){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:g=!0}=void 0===t?{}:t;const m=p(),h=S(o),b=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(!g&&!b())return;i.emit("dismiss"),h.current(!1),k()}}function t(e){const t=m&&x(m,l).some((t=>{var n;return U(e,null==(n=t.context)?void 0:n.refs.floating.current)}));U(e,c.floating.current)||E(c.reference.current)&&U(e,c.reference.current)||t||(g||b())&&(i.emit("dismiss"),h.current(!1),k())}function o(){h.current(!1)}const u=y(c.floating.current);s&&u.addEventListener("keydown",e),f&&u.addEventListener("mousedown",t);const d=(v?[...E(c.reference.current)?n.getOverflowAncestors(c.reference.current):[],...E(c.floating.current)?n.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",t),d.forEach((e=>e.removeEventListener("scroll",o)))}}),[s,f,i,m,l,r,h,k,v,a,g,b,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(i.emit("dismiss"),o(!1))}}}:{}},e.useFloating=function(e){let{open:t=!1,onOpenChange:r=(()=>{}),whileElementsMounted:o,placement:l,middleware:a,strategy:s,nodeId:f}=void 0===e?{}:e;const d=p(),v=u.useRef({}),g=u.useState((()=>i()))[0],m=n.useFloating({placement:l,middleware:a,strategy:s,whileElementsMounted:o}),h=u.useMemo((()=>({...m,dataRef:v,nodeId:f,events:g,open:t,onOpenChange:r})),[m,v,f,g,t,r]);return c((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===f));e&&(e.context=h)})),u.useMemo((()=>({context:h,...m})),[m,h])},e.useFloatingNodeId=()=>{const e=d(),t=p(),n=m();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=m,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(!1);return u.useEffect((()=>{var e;if(!l)return;const t=null!=(e=y(c.floating.current).defaultView)?e:window;function r(){s.current=!n}function o(){setTimeout((()=>{s.current=!1}))}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(){s.current=!0}}),[i,l]),l?{reference:{onPointerDown(e){let{pointerType:t}=e;s.current=!(!t||!a)},onFocus(e){var t,n,u;s.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)||(s.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,g=p(),m=S(s),h=S(o),b=u.useRef(),w=u.useRef(),x=u.useRef(),k=u.useRef(),R=u.useRef(!0);c((()=>{n&&(a||(b.current=void 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||!h.current)return;function e(){var e;null!=(e=f.current.openEvent)&&e.type.includes("mouse")&&m.current(!1)}const t=y(v.floating.current).documentElement;return t.addEventListener("mouseleave",e),()=>{t.removeEventListener("mouseleave",e)}}),[v.floating,m,n,h,f]);const O=u.useCallback((function(e){void 0===e&&(e=!0),r&&!x.current?(clearTimeout(w.current),w.current=setTimeout((()=>m.current(!1)),K(r,"close",b.current))):e&&m.current(!1)}),[r,m]),T=u.useCallback((()=>{x.current&&(y(v.floating.current).removeEventListener("pointermove",x.current),x.current=void 0)}),[v.floating]);if(u.useEffect((()=>{a||T()}),[a,n,T]),u.useEffect((()=>{if(!n)return;function t(e){clearTimeout(w.current),R.current=!1,a||i&&"mouse"!==b.current||l>0&&0===K(r,"open")||(f.current.openEvent=e,r?w.current=setTimeout((()=>{m.current(!0)}),K(r,"open",b.current)):m.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),h.current)return clearTimeout(w.current),x.current&&o.removeEventListener("pointermove",x.current),x.current=h.current({...e,tree:g,x:t.clientX,y:t.clientY,onClose(){T(),O()}}),void o.addEventListener("pointermove",x.current);O()}const u=v.reference.current;return E(u)?(u.addEventListener("mousemove",t,{once:!0}),u.addEventListener("mouseenter",t),u.addEventListener("mouseleave",o),()=>{u.removeEventListener("mousemove",t),u.removeEventListener("mouseenter",t),u.removeEventListener("mouseleave",o)}):void 0}),[n,O,e,r,h,f,i,m,a,g,l,T,v.reference,v.floating]),!n)return{};function I(e){b.current=e.pointerType}return{reference:{onPointerDown:I,onPointerEnter:I,onMouseMove(){a||0===l||(clearTimeout(k.current),k.current=setTimeout((()=>{R.current||s(!0)}),l))}},floating:{onMouseEnter(){clearTimeout(w.current)},onMouseLeave:()=>O(!1)}}},e.useId=d,e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:t=>h(t,e,"reference"),getFloatingProps:t=>h(t,e,"floating"),getItemProps:t=>h(t,e,"item")}},e.useListNavigation=function(e,n){let{open:r,onOpenChange:o,refs:i}=e,{listRef:l,activeIndex:a,onNavigate:s,enabled:f=!0,selectedIndex:d=null,allowEscape:v=!1,loop:g=!1,nested:h=!1,rtl:b=!1,virtual:E=!1,focusItemOnOpen:x="auto",focusItemOnHover:k=!0,orientation:R="vertical"}=void 0===n?{listRef:{current:[]},activeIndex:null,onNavigate:()=>{}}:n;const O=m(),T=p(),I=function(e){const n=t.useRef();return c((()=>{n.current=e}),[e]),n.current}(r),C=u.useRef("auto"!==x&&x),L=u.useRef(null!=d?d:-1),M=u.useRef(""),P=S(s),A=u.useRef(!1),[j,N]=u.useState(),K=u.useCallback(((e,t)=>{var n,r;E?N(null==(n=e.current[t.current])?void 0:n.id):null==(r=e.current[t.current])||r.focus({preventScroll:!0})}),[E]);function W(e){if(A.current=!0,h&&function(e,t,n){return X(t,n?e===V:e===G,e===q)}(e.key,R,b))return F(e),o(!1),void(w(i.reference.current)&&i.reference.current.focus());const t=L.current,n=J(l),r=Q(l);if("Home"===e.key&&(L.current=n,s(L.current)),"End"===e.key&&(L.current=r,s(L.current)),Y(e.key,R)){if(F(e),!E&&D(e.currentTarget.ownerDocument)===e.currentTarget)return L.current=null!=d?d:z(e.key,R,b)?n:r,void s(L.current);z(e.key,R,b)?L.current=g?t>=r?v&&t!==l.current.length?-1:n:_(l,{startingIndex:t}):Math.min(r,_(l,{startingIndex:t})):L.current=g?t<=n?v&&-1!==t?l.current.length:r:_(l,{startingIndex:t,decrement:!0}):Math.max(n,_(l,{startingIndex:t,decrement:!0})),s(L.current)}}return c((()=>{f&&(null!=d&&(L.current=d),!I&&r&&C.current&&(P.current(L.current),K(l,L)))}),[r,I,d,l,P,K,f]),c((()=>{f&&r&&(null==a?(!I&&C.current&&null==d||v)&&(L.current=v?-1:J(l),P.current(a),K(l,L)):(L.current=a,P.current(a),K(l,L)))}),[r,I,a,d,h,l,P,K,f,O,v,i.floating,null==T?void 0:T.nodesRef]),c((()=>{if(null==d&&f){if(r&&(Y(M.current,R)||C.current&&(" "===M.current||"Enter"===M.current))){const e=J(l),t=Q(l);L.current=function(e,t,n){return X(t,e===q,n?e===V:e===G)}(M.current,R,b)?v?l.current.length:t:v?-1:e,P.current(L.current),K(l,L)}M.current=""}}),[r,l,d,P,K,f,R,b,v]),c((()=>{f&&!r&&I&&null!=d&&w(i.reference.current)&&i.reference.current.focus()}),[i.reference,d,r,I,f]),c((()=>{var e;f&&(r||(L.current=null!=(e=null!=d?d:a)?e:-1,P.current(null)))}),[r,d,a,f,x,P]),c((()=>{if(f&&!r&&I){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})}}),[f,r,I,T,O]),c((()=>{C.current=!1,M.current=""})),f?{reference:{...E&&r&&null!=a&&{"aria-activedescendant":j},onKeyDown(e){if(A.current=!0,E&&r)return W(e);"auto"===x&&(C.current=!0),M.current=e.key,h?function(e,t,n){return X(t,n?e===G:e===V,e===H)}(e.key,R,b)&&(F(e),r?(L.current=J(l),s(L.current)):o(!0)):(Y(e.key,R)&&(L.current=null==d?z(e.key,R,b)?J(l):Q(l):d,F(e),o(!0),s(L.current)),E&&!r&&W(e))}},floating:{"aria-orientation":"both"===R?void 0:R,...E&&null!=a&&{"aria-activedescendant":j},onKeyDown:W,onPointerMove(){A.current=!1}},item:{onFocus(e){let{currentTarget:t}=e;const n=l.current.indexOf(t);-1!==n&&s(n)},onClick:e=>{let{currentTarget:t}=e;return t.focus({preventScroll:!0})},...k&&{onPointerMove(e){let{currentTarget:t}=e;const n=t;if(n){const e=l.current.indexOf(n);-1!==e&&s(e)}},onPointerLeave(){var e;A.current||(s(null),E?(L.current=-1,K(l,L)):null==(e=i.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:g=null}=void 0===t?{listRef:{current:[]},activeIndex:null}:t;const m=u.useRef(),p=u.useRef(""),h=u.useRef(null!=(n=null!=g?g:l)?n:-1),b=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="",h.current=b.current),p.current+=e.key,clearTimeout(m.current),m.current=setTimeout((()=>{p.current="",h.current=b.current,o.current.typing=!1}),d);const n=h.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),b.current=c)}return c((()=>{r&&(clearTimeout(m.current),b.current=null,p.current="")}),[r]),c((()=>{var e;r&&""===p.current&&(h.current=null!=(e=null!=g?g:l)?e:-1)}),[r,g,l]),s?{reference:{onKeyDown:E},floating:{onKeyDown:E}}:{}},Object.keys(n).forEach((function(t){"default"===t||e.hasOwnProperty(t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@floating-ui/react-dom-interactions", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"@rollingversions": { | ||
@@ -15,13 +15,14 @@ "baseVersion": [ | ||
}, | ||
"main": "dist/floating-ui.react-dom-interactions.js", | ||
"module": "dist/floating-ui.react-dom-interactions.esm.js", | ||
"unpkg": "dist/floating-ui.react-dom-interactions.min.js", | ||
"type": "module", | ||
"main": "./dist/floating-ui.react-dom-interactions.js", | ||
"module": "./dist/floating-ui.react-dom-interactions.esm.js", | ||
"unpkg": "./dist/floating-ui.react-dom-interactions.min.js", | ||
"types": "./index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/floating-ui.react-dom-interactions.esm.js", | ||
"require": "./dist/floating-ui.react-dom-interactions.cjs" | ||
"types": "./index.d.ts", | ||
"module": "./dist/floating-ui.react-dom-interactions.esm.js", | ||
"import": "./dist/floating-ui.react-dom-interactions.mjs", | ||
"default": "./dist/floating-ui.react-dom-interactions.js" | ||
}, | ||
"./package.json": "./package.json", | ||
"./src/index.ts": "./src/index.ts" | ||
"./package.json": "./package.json" | ||
}, | ||
@@ -60,3 +61,3 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@floating-ui/react-dom": "^0.6.3", | ||
"@floating-ui/react-dom": "^0.7.0", | ||
"aria-hidden": "^1.1.3", | ||
@@ -63,0 +64,0 @@ "use-isomorphic-layout-effect": "^1.1.1" |
import * as React from 'react'; | ||
export declare const useFloatingPortalNode: ({ id, enabled, }?: { | ||
id?: string; | ||
enabled?: boolean; | ||
}) => HTMLElement; | ||
/** | ||
@@ -3,0 +7,0 @@ * Portals your floating element outside of the main app node. |
@@ -18,3 +18,3 @@ import * as React from 'react'; | ||
}; | ||
export interface Props { | ||
export interface Props<RT extends ReferenceType = ReferenceType> { | ||
open: boolean; | ||
@@ -26,4 +26,5 @@ onOpenChange: (open: boolean) => void; | ||
nodeId: string; | ||
whileElementsMounted?: (reference: RT, floating: HTMLElement, update: () => void) => void | (() => void); | ||
} | ||
export declare function useFloating<RT extends ReferenceType = ReferenceType>({ open, onOpenChange, placement, middleware, strategy, nodeId, }?: Partial<Props>): UseFloatingReturn<RT> & { | ||
export declare function useFloating<RT extends ReferenceType = ReferenceType>({ open, onOpenChange, whileElementsMounted, placement, middleware, strategy, nodeId, }?: Partial<Props>): UseFloatingReturn<RT> & { | ||
context: FloatingContext<RT>; | ||
@@ -34,3 +35,3 @@ }; | ||
export { safePolygon } from './safePolygon'; | ||
export { FloatingPortal } from './FloatingPortal'; | ||
export { FloatingPortal, useFloatingPortalNode } from './FloatingPortal'; | ||
export { FloatingOverlay } from './FloatingOverlay'; | ||
@@ -37,0 +38,0 @@ export { FloatingFocusManager } from './FloatingFocusManager'; |
@@ -1,9 +0,9 @@ | ||
import type { FloatingContext, FloatingTreeType } from './types'; | ||
export declare function safePolygon({ restMs, buffer, debug, }?: Partial<{ | ||
import type { FloatingContext, FloatingTreeType, ReferenceType } from './types'; | ||
export declare function safePolygon<RT extends ReferenceType = ReferenceType>({ restMs, buffer, debug, }?: Partial<{ | ||
restMs: number; | ||
buffer: number; | ||
debug: null | ((points?: string | null) => void); | ||
}>): ({ x, y, placement, refs, onClose, nodeId, tree, }: FloatingContext<import("@floating-ui/dom/src/types").ReferenceElement> & { | ||
}>): ({ x, y, placement, refs, onClose, nodeId, tree, }: FloatingContext<RT> & { | ||
onClose: () => void; | ||
tree?: FloatingTreeType | null; | ||
tree?: FloatingTreeType<RT> | null; | ||
}) => (event: PointerEvent) => void; |
@@ -1,2 +0,2 @@ | ||
import type { FloatingTreeType } from '../types'; | ||
export declare function getChildren(tree: FloatingTreeType, id: string | undefined): import("../types").FloatingNodeType<import("@floating-ui/dom/src/types").ReferenceElement>[]; | ||
import type { FloatingTreeType, ReferenceType } from '../types'; | ||
export declare function getChildren<RT extends ReferenceType = ReferenceType>(tree: FloatingTreeType<RT>, id: string | undefined): import("../types").FloatingNodeType<RT>[]; |
Sorry, the diff of this file is too big to display
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
6009
266938
No
+ Added@floating-ui/core@0.7.3(transitive)
+ Added@floating-ui/dom@0.5.4(transitive)
+ Added@floating-ui/react-dom@0.7.2(transitive)
- Removed@floating-ui/core@0.6.2(transitive)
- Removed@floating-ui/dom@0.4.5(transitive)
- Removed@floating-ui/react-dom@0.6.3(transitive)