@floating-ui/react-dom-interactions
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,2 +0,2 @@ | ||
import React$1, { useLayoutEffect, useEffect, useMemo, useContext, useRef, useCallback, createContext, useState, forwardRef } from 'react'; | ||
import React, { useLayoutEffect, useEffect, useMemo, useContext, useRef, useCallback, createContext, useState, forwardRef } from 'react'; | ||
import { getOverflowAncestors, useFloating as useFloating$1 } from '@floating-ui/react-dom'; | ||
@@ -473,3 +473,3 @@ export * from '@floating-ui/react-dom'; | ||
if (mounted && portalRef.current) { | ||
return /*#__PURE__*/React$1.createElement(FloatingPortalContext.Provider, { | ||
return /*#__PURE__*/React.createElement(FloatingPortalContext.Provider, { | ||
value: id | ||
@@ -476,0 +476,0 @@ }, /*#__PURE__*/createPortal(children, portalRef.current)); |
@@ -1,1 +0,1 @@ | ||
import e,{useLayoutEffect as n,useEffect as r,useMemo as t,useContext as o,useRef as c,useCallback as u,createContext as i,useState as l,forwardRef as a}from"react";import{getOverflowAncestors as d,useFloating as f}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import{createPortal as s}from"react-dom";var v="undefined"!=typeof document?n:r;function p(){const e=new Map;return{emit(n,r){var t;null==(t=e.get(n))||t.forEach((e=>e(r)))},on(n,r){e.set(n,[...e.get(n)||[],r])},off(n,r){e.set(n,(e.get(n)||[]).filter((e=>e!==r)))}}}let g=0;function m(){return"floating-ui-"+g++}function h(){return t(m,[])}const y=i(null),b=i(null),w=()=>{var e,n;return null!=(e=null==(n=o(y))?void 0:n.id)?e:null},E=()=>o(b),k=()=>{const e=h(),n=E(),r=w();return v((()=>{const t={id:e,parentId:r};return null==n||n.addNode(t),()=>{null==n||n.removeNode(t)}}),[n,e,r]),e},x=e=>{let{children:n,id:r}=e;const t=w();return React.createElement(y.Provider,{value:{id:r,parentId:t}},n)},T=e=>{let{children:n}=e;const r=c([]),t=u((e=>{r.current=[...r.current,e]}),[]),o=u((e=>{r.current=r.current.filter((n=>n!==e))}),[]);return React.createElement(b.Provider,{value:{nodesRef:r,addNode:t,removeNode:o,events:p()}},n)};function I(e){return Object.entries(null!=e?e:{}).reduce(((e,n)=>{let[r,t]=n;return e[r]=[t],e}),{})}function C(e,n,r){const t={reference:"reference"===r?I(e):{},floating:"floating"===r?I(e):{}};return n.forEach((e=>{var n;const o=null!=(n=null==e?void 0:e[r])?n:{};Object.keys(o).forEach((e=>{var n;"function"==typeof o[e]&&(null==t[r][e]&&(t[r][e]=[]),null==(n=t[r][e])||n.push(o[e]))}))})),{..."floating"===r&&{tabIndex:-1},...e,...n.reduce(((e,n)=>(Object.assign(e,null==n?void 0:n[r]),e)),{}),...Object.entries(t[r]).reduce(((e,n)=>{let[r,t]=n;return 0===r.indexOf("on")&&(e[r]=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];t.forEach((e=>e(...n)))}),e}),{})}}const A=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>C(n,e,"reference"),getFloatingProps:n=>C(n,e,"floating")}};var L={exports:{}},R=function(e,n,r,t){var o=e[0],c=e[1],u=!1;void 0===r&&(r=0),void 0===t&&(t=n.length);for(var i=(t-r)/2,l=0,a=i-1;l<i;a=l++){var d=n[r+2*l+0],f=n[r+2*l+1],s=n[r+2*a+0],v=n[r+2*a+1];f>c!=v>c&&o<(s-d)*(c-f)/(v-f)+d&&(u=!u)}return u},D=function(e,n,r,t){var o=e[0],c=e[1],u=!1;void 0===r&&(r=0),void 0===t&&(t=n.length);for(var i=t-r,l=0,a=i-1;l<i;a=l++){var d=n[l+r][0],f=n[l+r][1],s=n[a+r][0],v=n[a+r][1];f>c!=v>c&&o<(s-d)*(c-f)/(v-f)+d&&(u=!u)}return u};L.exports=function(e,n,r,t){return n.length>0&&Array.isArray(n[0])?D(e,n,r,t):R(e,n,r,t)},L.exports.nested=D,L.exports.flat=R;var O=L.exports;function P(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function S(e){var n;return null!=(n=P(e).defaultView)?n:window}function N(e){return!!e&&e instanceof S(e).Element}function j(e){return!!e&&e instanceof S(e).HTMLElement}function B(e,n){var r;let t=null!=(r=null==e?void 0:e.nodesRef.current.filter((e=>{var r;return e.parentId===n&&(null==(r=e.context)?void 0:r.open)})))?r:[],o=t;for(;o.length;){var c;o=null!=(c=null==e?void 0:e.nodesRef.current.filter((e=>{var n;return null==(n=o)?void 0:n.some((n=>{var r;return e.parentId===n.id&&(null==(r=e.context)?void 0:r.open)}))})))?c:[],t=t.concat(o)}return t}function M(e){let n,{timeout:r=0,debug:t=null}=void 0===e?{}:e;return e=>{let{x:o,y:c,placement:u,refs:i,onClose:l,nodeId:a,tree:d}=e;return function(e){var f;if("touch"===e.pointerType)return;const{target:s,clientX:v,clientY:p}=e,g=s;if("pointermove"===e.type&&N(i.reference.current)&&i.reference.current.contains(g)||null!=(f=i.floating.current)&&f.contains(g))return;if(d&&B(d,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(!i.reference.current||!i.floating.current||null==u||null==o||null==c)return;const m=i.reference.current.getBoundingClientRect(),h=i.floating.current.getBoundingClientRect(),y=u.split("-")[0],b=o>h.right-h.width/2,w=c>h.bottom-h.height/2;switch(y){case"top":if(v>=h.left&&v<=h.right&&p>=h.bottom&&p<=m.top)return;break;case"bottom":if(v>=h.left&&v<=h.right&&p>=m.bottom&&p<=h.top)return;break;case"left":if(v>=h.right&&v<=m.left&&p>=h.left&&p<=h.right)return;break;case"right":if(v>=h.right&&v<=m.left&&p>=h.right&&p<=m.left)return}function E(e){let[n,r]=e;const t=h.width>m.width,o=h.height>m.height;switch(y){case"top":{const e=[t?n:b?n+1:n-1,r+1],o=[t?n:b?n-1:n+1,r+1],c=[[h.left,b||t?h.bottom-1:h.top],[h.right,b?t?h.bottom-1:h.top:h.bottom-1]];return b?[e,o,...c]:[e,...c,o]}case"bottom":{const e=[t?n:b?n+1:n-1,r-1],o=[t?n:b?n-1:n+1,r-1],c=[[h.left,b||t?h.top+1:h.bottom],[h.right,b?t?h.top+1:h.bottom:h.top+1]];return b?[e,o,...c]:[e,...c,o]}case"left":{const e=[n+1,o?r:w?r-1:r+1],t=[n+1,o?r:w?r+1:r-1],c=[[w||o?h.right-1:h.left,h.top],[w?o?h.right-1:h.left:h.right-1,h.bottom]];return w?[e,...c,t]:[...c,e,t]}case"right":{const e=[n-1,o?r:w?r+1:r-1],t=[n-1,o?r:w?r-1:r+1],c=[[w||o?h.left+1:h.right,h.top],[w?o?h.left+1:h.right:h.left+1,h.bottom]];return w?[e,t,...c]:[e,...c,t]}}}const k=E([o,c]);"production"!==process.env.NODE_ENV&&(null==t||t(E([o,c]).slice(0,4).join(", "))),O([v,p],k)?r&&(n=setTimeout(l,r)):(clearTimeout(n),l())}}}const K="floating-ui-root",U=i(K),F=n=>{let{children:r,id:t=K}=n;const[o,u]=l(!1),i=c(null);return v((()=>{const e=document.getElementById(t);e?i.current=e:(i.current=document.createElement("div"),i.current.id=t);const n=i.current;document.body.contains(n)||document.body.appendChild(n),u(!0)}),[]),o&&i.current?e.createElement(U.Provider,{value:t},s(r,i.current)):null};function V(){return V=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},V.apply(this,arguments)}const q=a((function(e,n){return React.createElement("div",V({ref:n},e,{style:{position:"fixed",top:0,right:0,bottom:0,left:0,width:"100%",height:"100%",...e.style}}))}));function H(e,n){return"number"==typeof e?e:null==e?void 0:e[n]}const W=function(e,n){let{enabled:t=!0,delay:o=0,handleLeave:u=null,mouseOnly:i=!1,pointerRestMs:l=0}=void 0===n?{}:n;const{open:a,onOpenChange:d,dataRef:f,events:s,refs:p}=e,g=E(),m=c(),h=c(),y=c(),b=c(!0);function w(e){void 0===e&&(e=!0),o?(clearTimeout(m.current),m.current=setTimeout((()=>d(!1)),H(o,"close"))):e&&d(!1)}return v((()=>{a||(f.current.hoveredThenClicked=!1)}),[a]),r((()=>{function e(){clearTimeout(m.current),clearTimeout(y.current),b.current=!0}return s.on("dismiss",e),()=>{s.off("dismiss",e)}}),[s]),t?{reference:{onPointerMove(){0===l||a||(clearTimeout(y.current),y.current=setTimeout((()=>{b.current||d(!0)}),l))},onPointerEnter(e){i&&"mouse"!==e.pointerType||(b.current=!1,f.current.openEvent=e.nativeEvent,o?(clearTimeout(m.current),m.current=setTimeout((()=>{d(!0)}),H(o,"open"))):d(!0))},onPointerLeave(n){var r;if(f.current.hoveredThenClicked||"click"===(null==(r=f.current.openEvent)?void 0:r.type))return;const t=P(p.floating.current);if(clearTimeout(y.current),u)return clearTimeout(m.current),h.current&&t.removeEventListener("pointermove",h.current),h.current=u({...e,tree:g,x:n.clientX,y:n.clientY,onClose(){h.current&&t.removeEventListener("pointermove",h.current),w()}}),h.current(n.nativeEvent),void t.addEventListener("pointermove",h.current);w()}},floating:{onPointerEnter(){clearTimeout(m.current)},onPointerLeave:()=>w(!1)}}:{}},X=i({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),Y=()=>o(X),_=e=>{let{children:n,delay:r}=e;const[t,o]=l({delay:r,initialDelay:r,currentId:null}),c=u((e=>{o((n=>({...n,currentId:e})))}),[]);return React.createElement(X.Provider,{value:{...t,setState:o,setCurrentId:c}},n)},z=(e,n)=>{let{open:t,onOpenChange:o}=e,{id:c}=n;const{currentId:u,initialDelay:i,setState:l}=Y();r((()=>{u&&o&&(l((e=>({...e,delay:{open:0,close:H(i,"close")}}))),u!==c&&o(!1))}),[c,o,l,u,i]),r((()=>{!t&&u===c&&o&&(o(!1),l((e=>({...e,delay:i,currentId:null}))))}),[t,l,u,c,o,i])},G=function(e,n){let{open:r}=e,{enabled:t=!0,role:o="dialog",titleId:c,descriptionId:u}=void 0===n?{}:n;const i=h(),l={id:i,role:o};return t?"tooltip"===o?{reference:{"aria-describedby":r?i:void 0},floating:l}:{reference:{"aria-expanded":r?"true":"false","aria-haspopup":o,"aria-controls":r?i:void 0,..."listbox"===o&&{role:"combobox"}},floating:{...l,..."dialog"===o&&{"aria-labelledby":c,"aria-describedby":u}}}:{}},J=function(e,n){let{open:r,onOpenChange:t,dataRef:o}=e,{enabled:c=!0}=void 0===n?{}:n;return c?{reference:{onClick(e){var n;r?"click"===(null==(n=o.current.openEvent)?void 0:n.type)||o.current.hoveredThenClicked?(o.current.hoveredThenClicked=!1,t(!1)):o.current.hoveredThenClicked=!0:(o.current.openEvent=e.nativeEvent,t(!0))}}}:{}},Q=function(e,n){let{open:t,onOpenChange:o,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:f=!0,outsidePointerDown:s=!0,referencePointerDown:v=!1,ancestorScroll:p=!1}=void 0===n?{}:n;const g=E(),m=u((()=>{j(c.reference.current)&&c.reference.current.focus()}),[c.reference.current]);return r((()=>{if(!t||!a)return;function e(e){"Escape"===e.key&&(i.emit("dismiss"),o(!1),m())}function n(e){var n;const r=g&&B(g,l).some((n=>{var r,t;return null==(r=n.context)||null==(t=r.refs.floating.current)?void 0:t.contains(e.target)}));null!=(n=c.floating.current)&&n.contains(e.target)||N(c.reference.current)&&c.reference.current.contains(e.target)||r||(i.emit("dismiss"),o(!1),m())}function r(){o(!1)}const u=P(c.floating.current);f&&u.addEventListener("keydown",e),s&&u.addEventListener("pointerdown",n);const v=p?[...N(c.reference.current)?d(c.reference.current):[],...N(c.floating.current)?d(c.floating.current):[]]:[];return v.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{f&&u.removeEventListener("keydown",e),s&&u.removeEventListener("pointerdown",n),v.forEach((e=>e.removeEventListener("scroll",r)))}}),[f,s,i,g,l,t,o,m,p,a,c.floating,c.reference]),a?{reference:{onPointerDown(){v&&(i.emit("dismiss"),o(!1))}}}:{}},Z=function(e,n){let{open:t,onOpenChange:o,dataRef:u,refs:i,events:l}=e,{enabled:a=!0,keyboardOnly:d=!0}=void 0===n?{}:n;const f=c(!1);return r((()=>{var e;if(!a)return;const n=null!=(e=P(i.floating.current).defaultView)?e:window;function r(){f.current=!t}function o(){setTimeout((()=>{f.current=!1}))}return n.addEventListener("focus",o),n.addEventListener("blur",r),()=>{n.addEventListener("focus",o),n.removeEventListener("blur",r)}}),[i.floating,t,a]),r((()=>{if(a)return l.on("dismiss",e),()=>{l.off("dismiss",e)};function e(){f.current=!0}}),[l,a]),a?{reference:{onPointerDown(e){let{pointerType:n}=e;f.current=!(!n||!d)},onFocus(e){var n,r;f.current||"focus"===e.type&&"mousedown"===u.current.openEvent&&N(i.reference.current)&&null!=(n=i.reference.current)&&n.contains(null==(r=u.current.openEvent)?void 0:r.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n;const r=e.relatedTarget;null!=(n=i.floating.current)&&n.contains(r)||N(i.reference.current)&&i.reference.current.contains(r)||(f.current=!1,u.current.hoveredThenClicked=!1,o(!1))}}}:{}},$=function(e,n){let{open:t,onOpenChange:i,refs:l,nodeId:a}=e,{enabled:d=!0,initialContentFocus:f=0,order:s=["content"],modal:p=!0,inert:g=!1,scrollLock:m=!1}=void 0===n?{}:n;const h=o(U),y=E(),b=c(0),w=u((()=>s.map((e=>{return j(l.reference.current)&&"reference"===e?l.reference.current:l.floating.current&&"floating"===e?l.floating.current:"content"===e?Array.from(null!=(n=null==(r=l.floating.current)?void 0:r.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable]"))?n:[]):null;var n,r})).filter(Boolean).flat()),[l.floating,l.reference,s]);function k(e){var n;const r=e.relatedTarget;!r||null!=(n=l.floating.current)&&n.contains(r)||!N(l.reference.current)||l.reference.current.contains(r)||i(!1)}return r((()=>{if(!g&&d)if(t){const r=w();var e;if("number"==typeof f)null==(e=r[f])||e.focus({preventScroll:!0});else if(f.current){var n;null==(n=r.find((e=>e===f.current)))||n.focus({preventScroll:!0})}}else p&&j(l.reference.current)&&l.reference.current.focus({preventScroll:!0})}),[w,t,g,p,f,d,l.reference]),r((()=>{if(!p||!d)return;const e=P(l.floating.current);if(!t)return e.removeEventListener("keydown",n),void(b.current=0);function n(e){var n;if((null==y||null==(n=y.nodesRef.current)||!n.filter((e=>{let{parentId:n}=e;return n===a})).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))&&"Tab"===e.key){var r;if(e.preventDefault(),e.stopPropagation(),g)return;const n=w();e.shiftKey?b.current=0===b.current?n.length-1:b.current-1:b.current=b.current===n.length-1?0:b.current+1,null==(r=n[b.current])||r.focus({preventScroll:!0})}}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}}),[w,null==y?void 0:y.nodesRef,a,t,p,g,d,l.floating]),r((()=>{if(!t||!p||!d)return;const e=P(l.floating.current),n=e.querySelector("#"+h),r=e.querySelectorAll("body > *:not(#"+h+")");return r.forEach((e=>{e.setAttribute("aria-hidden","true")})),()=>{(null==n?void 0:n.firstElementChild)===l.floating.current&&r.forEach((e=>{e.removeAttribute("aria-hidden")}))}}),[t,p,m,h,d,l.floating]),v((()=>{if(!t||!d)return;const e=P(l.floating.current);if(m){var n;const r=(null!=(n=e.defaultView)?n:window).innerWidth-e.documentElement.offsetWidth;e.documentElement.style.overflow="hidden",e.body.style.paddingRight=r+"px"}return()=>{m&&(e.documentElement.style.overflow="",e.body.style.paddingRight="")}}),[t,m,d]),d?p?{floating:{"aria-modal":"true"}}:{reference:{onBlur:k},floating:{onBlur:k}}:{}};function ee(e){e.preventDefault(),e.stopPropagation()}function ne(e,n){let{startingIndex:r=-1,decrement:t=!1}=void 0===n?{}:n,o=r;do{var c,u;o+=t?-1:1}while(null!=(c=e.current[o])&&c.hasAttribute("disabled")||"true"===(null==(u=e.current[o])?void 0:u.getAttribute("aria-disabled")));return-1===o?0:o}const re=function(e,n){let{open:r,onOpenChange:t,refs:o}=e,{enabled:i=!0,listRef:l={current:[]},activeIndex:a=null,selectedIndex:d=null,loop:f=!1,nested:s=!1,rtl:p=!1,onNavigate:g=(()=>{})}=void 0===n?{}:n;const m=c(!0),h=c(null!=d?d:0),y=c(""),b=u(((e,n)=>{var r;null==(r=e.current[n.current])||r.focus({preventScroll:!0})}),[]);function w(e){m.current=!e.pointerType}return v((()=>{i&&(null!=d&&(h.current=d),r&&m.current&&(g(h.current),b(l,h)))}),[r,d,l,g,b,i]),v((()=>{i&&r&&null!=a&&(h.current=a,g(h.current),b(l,h))}),[r,a,l,g,b,i]),v((()=>{null==d&&i&&(r&&("ArrowDown"===y.current||"ArrowUp"===y.current||m.current&&(" "===y.current||"Enter"===y.current))&&(h.current="ArrowUp"===y.current?ne(l,{startingIndex:l.current.length,decrement:!0}):ne(l),g(h.current),b(l,h)),y.current="")}),[r,l,d,g,b,i]),v((()=>{var e;i&&(r||null==d||null==(e=o.reference.current)||e.focus({preventScroll:!0}))}),[o.reference,d,r,i]),v((()=>{i&&(r||(m.current=!0,g(null)))}),[r,i]),i?{reference:{onPointerEnter:w,onPointerDown:w,onKeyDown(e){m.current=!0,y.current=e.key,N(o.reference.current)&&"BUTTON"!==o.reference.current.tagName&&("Enter"!==e.key&&" "!==e.key||t(!0)),s?e.key===(p?"ArrowLeft":"ArrowRight")&&(h.current=ne(l),ee(e),t(!0),g(h.current)):"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(h.current=null==d?"ArrowDown"===e.key?ne(l):ne(l,{startingIndex:l.current.length,decrement:!0}):d,ee(e),t(!0),g(h.current))}},floating:{onKeyDown(e){if(s&&e.key===(p?"ArrowRight":"ArrowLeft"))return ee(e),t(!1),void(j(o.reference.current)&&o.reference.current.focus());const n=h.current,r=ne(l),c=ne(l,{decrement:!0,startingIndex:l.current.length});if("Home"===e.key&&(h.current=r,g(h.current),b(l,h)),"End"===e.key&&(h.current=c,g(h.current),b(l,h)),"ArrowDown"===e.key||"ArrowUp"===e.key){if(ee(e),e.currentTarget.ownerDocument.activeElement===e.currentTarget&&null!=d)return h.current=d,g(h.current),void b(l,h);"ArrowDown"===e.key?h.current=f?n===c?r:ne(l,{startingIndex:n}):Math.min(c,ne(l,{startingIndex:n})):h.current=f?n===r?c:ne(l,{startingIndex:n,decrement:!0}):Math.max(r,ne(l,{startingIndex:n,decrement:!0})),g(h.current),b(l,h)}}}}:{}},te=function(e,n){let{open:r}=e,{enabled:t=!0,listRef:o={current:[]},onMatch:u=(()=>{}),onFind:i=null,debounceMs:l=500,ignoreKeys:a=[]}=void 0===n?{}:n;const d=c(),f=c(""),s=c(null),p=c(null);function g(e){if(!e.currentTarget.contains(P(e.currentTarget).activeElement))return;" "===e.key&&f.current.length>0&&(e.preventDefault(),e.stopPropagation());const n=o.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...a].includes(e.key))return;n.every((e=>{var n,r;return!e||(null==(n=e[0])?void 0:n.toLowerCase())!==(null==(r=e[1])?void 0:r.toLowerCase())}))&&f.current===e.key&&(f.current="",s.current=p.current),f.current+=e.key,clearTimeout(d.current),d.current=setTimeout((()=>{f.current="",s.current=p.current}),l);const r=s.current,t=[...n.slice((null!=r?r:0)+1),...n.slice(0,null!=r?r:0)].find((e=>i?i(e,f.current):0===(null==e?void 0:e.toLowerCase().indexOf(f.current)))),c=t?n.indexOf(t):-1;-1!==c&&(u(c),p.current=c)}return v((()=>{r&&(clearTimeout(d.current),s.current=null,p.current=null,f.current="")}),[r]),t?{reference:{onKeyDown:g},floating:{onKeyDown:g}}:{}};function oe(e){let{open:n=!1,onOpenChange:r=(()=>{}),placement:o,middleware:u,strategy:i,nodeId:a}=void 0===e?{}:e;const d=E(),s=c({}),g=l((()=>p()))[0],m=f({placement:o,middleware:u,strategy:i}),h=t((()=>({...m,dataRef:s,nodeId:a,events:g,open:n,onOpenChange:r})),[m,s,a,g,n,r]);return v((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===a));e&&(e.context=h)})),t((()=>({context:h,...m})),[m,h])}export{_ as FloatingDelayGroup,x as FloatingNode,q as FloatingOverlay,F as FloatingPortal,T as FloatingTree,M as safePolygon,G as useAria,J as useClick,z as useDelayGroup,Y as useDelayGroupContext,Q as useDismiss,oe as useFloating,h as useFloatingId,k as useFloatingNodeId,w as useFloatingParentNodeId,E as useFloatingTree,Z as useFocus,$ as useFocusTrap,W as useHover,A as useInteractions,re as useListNavigation,te as useTypeahead}; | ||
import e,{useLayoutEffect as n,useEffect as r,useMemo as t,useContext as o,useRef as c,useCallback as u,createContext as i,useState as l,forwardRef as a}from"react";import{getOverflowAncestors as d,useFloating as f}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import{createPortal as s}from"react-dom";var v="undefined"!=typeof document?n:r;function p(){const e=new Map;return{emit(n,r){var t;null==(t=e.get(n))||t.forEach((e=>e(r)))},on(n,r){e.set(n,[...e.get(n)||[],r])},off(n,r){e.set(n,(e.get(n)||[]).filter((e=>e!==r)))}}}let g=0;function m(){return"floating-ui-"+g++}function h(){return t(m,[])}const y=i(null),b=i(null),w=()=>{var e,n;return null!=(e=null==(n=o(y))?void 0:n.id)?e:null},E=()=>o(b),k=()=>{const e=h(),n=E(),r=w();return v((()=>{const t={id:e,parentId:r};return null==n||n.addNode(t),()=>{null==n||n.removeNode(t)}}),[n,e,r]),e},x=n=>{let{children:r,id:t}=n;const o=w();return e.createElement(y.Provider,{value:{id:t,parentId:o}},r)},T=n=>{let{children:r}=n;const t=c([]),o=u((e=>{t.current=[...t.current,e]}),[]),i=u((e=>{t.current=t.current.filter((n=>n!==e))}),[]);return e.createElement(b.Provider,{value:{nodesRef:t,addNode:o,removeNode:i,events:p()}},r)};function I(e){return Object.entries(null!=e?e:{}).reduce(((e,n)=>{let[r,t]=n;return e[r]=[t],e}),{})}function C(e,n,r){const t={reference:"reference"===r?I(e):{},floating:"floating"===r?I(e):{}};return n.forEach((e=>{var n;const o=null!=(n=null==e?void 0:e[r])?n:{};Object.keys(o).forEach((e=>{var n;"function"==typeof o[e]&&(null==t[r][e]&&(t[r][e]=[]),null==(n=t[r][e])||n.push(o[e]))}))})),{..."floating"===r&&{tabIndex:-1},...e,...n.reduce(((e,n)=>(Object.assign(e,null==n?void 0:n[r]),e)),{}),...Object.entries(t[r]).reduce(((e,n)=>{let[r,t]=n;return 0===r.indexOf("on")&&(e[r]=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];t.forEach((e=>e(...n)))}),e}),{})}}const A=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>C(n,e,"reference"),getFloatingProps:n=>C(n,e,"floating")}};var L={exports:{}},D=function(e,n,r,t){var o=e[0],c=e[1],u=!1;void 0===r&&(r=0),void 0===t&&(t=n.length);for(var i=(t-r)/2,l=0,a=i-1;l<i;a=l++){var d=n[r+2*l+0],f=n[r+2*l+1],s=n[r+2*a+0],v=n[r+2*a+1];f>c!=v>c&&o<(s-d)*(c-f)/(v-f)+d&&(u=!u)}return u},O=function(e,n,r,t){var o=e[0],c=e[1],u=!1;void 0===r&&(r=0),void 0===t&&(t=n.length);for(var i=t-r,l=0,a=i-1;l<i;a=l++){var d=n[l+r][0],f=n[l+r][1],s=n[a+r][0],v=n[a+r][1];f>c!=v>c&&o<(s-d)*(c-f)/(v-f)+d&&(u=!u)}return u};L.exports=function(e,n,r,t){return n.length>0&&Array.isArray(n[0])?O(e,n,r,t):D(e,n,r,t)},L.exports.nested=O,L.exports.flat=D;var P=L.exports;function R(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function S(e){var n;return null!=(n=R(e).defaultView)?n:window}function N(e){return!!e&&e instanceof S(e).Element}function j(e){return!!e&&e instanceof S(e).HTMLElement}function B(e,n){var r;let t=null!=(r=null==e?void 0:e.nodesRef.current.filter((e=>{var r;return e.parentId===n&&(null==(r=e.context)?void 0:r.open)})))?r:[],o=t;for(;o.length;){var c;o=null!=(c=null==e?void 0:e.nodesRef.current.filter((e=>{var n;return null==(n=o)?void 0:n.some((n=>{var r;return e.parentId===n.id&&(null==(r=e.context)?void 0:r.open)}))})))?c:[],t=t.concat(o)}return t}function M(e){let n,{timeout:r=0,debug:t=null}=void 0===e?{}:e;return e=>{let{x:o,y:c,placement:u,refs:i,onClose:l,nodeId:a,tree:d}=e;return function(e){var f;if("touch"===e.pointerType)return;const{target:s,clientX:v,clientY:p}=e,g=s;if("pointermove"===e.type&&N(i.reference.current)&&i.reference.current.contains(g)||null!=(f=i.floating.current)&&f.contains(g))return;if(d&&B(d,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(!i.reference.current||!i.floating.current||null==u||null==o||null==c)return;const m=i.reference.current.getBoundingClientRect(),h=i.floating.current.getBoundingClientRect(),y=u.split("-")[0],b=o>h.right-h.width/2,w=c>h.bottom-h.height/2;switch(y){case"top":if(v>=h.left&&v<=h.right&&p>=h.bottom&&p<=m.top)return;break;case"bottom":if(v>=h.left&&v<=h.right&&p>=m.bottom&&p<=h.top)return;break;case"left":if(v>=h.right&&v<=m.left&&p>=h.left&&p<=h.right)return;break;case"right":if(v>=h.right&&v<=m.left&&p>=h.right&&p<=m.left)return}function E(e){let[n,r]=e;const t=h.width>m.width,o=h.height>m.height;switch(y){case"top":{const e=[t?n:b?n+1:n-1,r+1],o=[t?n:b?n-1:n+1,r+1],c=[[h.left,b||t?h.bottom-1:h.top],[h.right,b?t?h.bottom-1:h.top:h.bottom-1]];return b?[e,o,...c]:[e,...c,o]}case"bottom":{const e=[t?n:b?n+1:n-1,r-1],o=[t?n:b?n-1:n+1,r-1],c=[[h.left,b||t?h.top+1:h.bottom],[h.right,b?t?h.top+1:h.bottom:h.top+1]];return b?[e,o,...c]:[e,...c,o]}case"left":{const e=[n+1,o?r:w?r-1:r+1],t=[n+1,o?r:w?r+1:r-1],c=[[w||o?h.right-1:h.left,h.top],[w?o?h.right-1:h.left:h.right-1,h.bottom]];return w?[e,...c,t]:[...c,e,t]}case"right":{const e=[n-1,o?r:w?r+1:r-1],t=[n-1,o?r:w?r-1:r+1],c=[[w||o?h.left+1:h.right,h.top],[w?o?h.left+1:h.right:h.left+1,h.bottom]];return w?[e,t,...c]:[e,...c,t]}}}const k=E([o,c]);"production"!==process.env.NODE_ENV&&(null==t||t(E([o,c]).slice(0,4).join(", "))),P([v,p],k)?r&&(n=setTimeout(l,r)):(clearTimeout(n),l())}}}const K="floating-ui-root",U=i(K),F=n=>{let{children:r,id:t=K}=n;const[o,u]=l(!1),i=c(null);return v((()=>{const e=document.getElementById(t);e?i.current=e:(i.current=document.createElement("div"),i.current.id=t);const n=i.current;document.body.contains(n)||document.body.appendChild(n),u(!0)}),[]),o&&i.current?e.createElement(U.Provider,{value:t},s(r,i.current)):null};function V(){return V=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},V.apply(this,arguments)}const q=a((function(n,r){return e.createElement("div",V({ref:r},n,{style:{position:"fixed",top:0,right:0,bottom:0,left:0,width:"100%",height:"100%",...n.style}}))}));function H(e,n){return"number"==typeof e?e:null==e?void 0:e[n]}const W=function(e,n){let{enabled:t=!0,delay:o=0,handleLeave:u=null,mouseOnly:i=!1,pointerRestMs:l=0}=void 0===n?{}:n;const{open:a,onOpenChange:d,dataRef:f,events:s,refs:p}=e,g=E(),m=c(),h=c(),y=c(),b=c(!0);function w(e){void 0===e&&(e=!0),o?(clearTimeout(m.current),m.current=setTimeout((()=>d(!1)),H(o,"close"))):e&&d(!1)}return v((()=>{a||(f.current.hoveredThenClicked=!1)}),[a]),r((()=>{function e(){clearTimeout(m.current),clearTimeout(y.current),b.current=!0}return s.on("dismiss",e),()=>{s.off("dismiss",e)}}),[s]),t?{reference:{onPointerMove(){0===l||a||(clearTimeout(y.current),y.current=setTimeout((()=>{b.current||d(!0)}),l))},onPointerEnter(e){i&&"mouse"!==e.pointerType||(b.current=!1,f.current.openEvent=e.nativeEvent,o?(clearTimeout(m.current),m.current=setTimeout((()=>{d(!0)}),H(o,"open"))):d(!0))},onPointerLeave(n){var r;if(f.current.hoveredThenClicked||"click"===(null==(r=f.current.openEvent)?void 0:r.type))return;const t=R(p.floating.current);if(clearTimeout(y.current),u)return clearTimeout(m.current),h.current&&t.removeEventListener("pointermove",h.current),h.current=u({...e,tree:g,x:n.clientX,y:n.clientY,onClose(){h.current&&t.removeEventListener("pointermove",h.current),w()}}),h.current(n.nativeEvent),void t.addEventListener("pointermove",h.current);w()}},floating:{onPointerEnter(){clearTimeout(m.current)},onPointerLeave:()=>w(!1)}}:{}},X=i({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),Y=()=>o(X),_=n=>{let{children:r,delay:t}=n;const[o,c]=l({delay:t,initialDelay:t,currentId:null}),i=u((e=>{c((n=>({...n,currentId:e})))}),[]);return e.createElement(X.Provider,{value:{...o,setState:c,setCurrentId:i}},r)},z=(e,n)=>{let{open:t,onOpenChange:o}=e,{id:c}=n;const{currentId:u,initialDelay:i,setState:l}=Y();r((()=>{u&&o&&(l((e=>({...e,delay:{open:0,close:H(i,"close")}}))),u!==c&&o(!1))}),[c,o,l,u,i]),r((()=>{!t&&u===c&&o&&(o(!1),l((e=>({...e,delay:i,currentId:null}))))}),[t,l,u,c,o,i])},G=function(e,n){let{open:r}=e,{enabled:t=!0,role:o="dialog",titleId:c,descriptionId:u}=void 0===n?{}:n;const i=h(),l={id:i,role:o};return t?"tooltip"===o?{reference:{"aria-describedby":r?i:void 0},floating:l}:{reference:{"aria-expanded":r?"true":"false","aria-haspopup":o,"aria-controls":r?i:void 0,..."listbox"===o&&{role:"combobox"}},floating:{...l,..."dialog"===o&&{"aria-labelledby":c,"aria-describedby":u}}}:{}},J=function(e,n){let{open:r,onOpenChange:t,dataRef:o}=e,{enabled:c=!0}=void 0===n?{}:n;return c?{reference:{onClick(e){var n;r?"click"===(null==(n=o.current.openEvent)?void 0:n.type)||o.current.hoveredThenClicked?(o.current.hoveredThenClicked=!1,t(!1)):o.current.hoveredThenClicked=!0:(o.current.openEvent=e.nativeEvent,t(!0))}}}:{}},Q=function(e,n){let{open:t,onOpenChange:o,refs:c,events:i,nodeId:l}=e,{enabled:a=!0,escapeKey:f=!0,outsidePointerDown:s=!0,referencePointerDown:v=!1,ancestorScroll:p=!1}=void 0===n?{}:n;const g=E(),m=u((()=>{j(c.reference.current)&&c.reference.current.focus()}),[c.reference.current]);return r((()=>{if(!t||!a)return;function e(e){"Escape"===e.key&&(i.emit("dismiss"),o(!1),m())}function n(e){var n;const r=g&&B(g,l).some((n=>{var r,t;return null==(r=n.context)||null==(t=r.refs.floating.current)?void 0:t.contains(e.target)}));null!=(n=c.floating.current)&&n.contains(e.target)||N(c.reference.current)&&c.reference.current.contains(e.target)||r||(i.emit("dismiss"),o(!1),m())}function r(){o(!1)}const u=R(c.floating.current);f&&u.addEventListener("keydown",e),s&&u.addEventListener("pointerdown",n);const v=p?[...N(c.reference.current)?d(c.reference.current):[],...N(c.floating.current)?d(c.floating.current):[]]:[];return v.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{f&&u.removeEventListener("keydown",e),s&&u.removeEventListener("pointerdown",n),v.forEach((e=>e.removeEventListener("scroll",r)))}}),[f,s,i,g,l,t,o,m,p,a,c.floating,c.reference]),a?{reference:{onPointerDown(){v&&(i.emit("dismiss"),o(!1))}}}:{}},Z=function(e,n){let{open:t,onOpenChange:o,dataRef:u,refs:i,events:l}=e,{enabled:a=!0,keyboardOnly:d=!0}=void 0===n?{}:n;const f=c(!1);return r((()=>{var e;if(!a)return;const n=null!=(e=R(i.floating.current).defaultView)?e:window;function r(){f.current=!t}function o(){setTimeout((()=>{f.current=!1}))}return n.addEventListener("focus",o),n.addEventListener("blur",r),()=>{n.addEventListener("focus",o),n.removeEventListener("blur",r)}}),[i.floating,t,a]),r((()=>{if(a)return l.on("dismiss",e),()=>{l.off("dismiss",e)};function e(){f.current=!0}}),[l,a]),a?{reference:{onPointerDown(e){let{pointerType:n}=e;f.current=!(!n||!d)},onFocus(e){var n,r;f.current||"focus"===e.type&&"mousedown"===u.current.openEvent&&N(i.reference.current)&&null!=(n=i.reference.current)&&n.contains(null==(r=u.current.openEvent)?void 0:r.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n;const r=e.relatedTarget;null!=(n=i.floating.current)&&n.contains(r)||N(i.reference.current)&&i.reference.current.contains(r)||(f.current=!1,u.current.hoveredThenClicked=!1,o(!1))}}}:{}},$=function(e,n){let{open:t,onOpenChange:i,refs:l,nodeId:a}=e,{enabled:d=!0,initialContentFocus:f=0,order:s=["content"],modal:p=!0,inert:g=!1,scrollLock:m=!1}=void 0===n?{}:n;const h=o(U),y=E(),b=c(0),w=u((()=>s.map((e=>{return j(l.reference.current)&&"reference"===e?l.reference.current:l.floating.current&&"floating"===e?l.floating.current:"content"===e?Array.from(null!=(n=null==(r=l.floating.current)?void 0:r.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable]"))?n:[]):null;var n,r})).filter(Boolean).flat()),[l.floating,l.reference,s]);function k(e){var n;const r=e.relatedTarget;!r||null!=(n=l.floating.current)&&n.contains(r)||!N(l.reference.current)||l.reference.current.contains(r)||i(!1)}return r((()=>{if(!g&&d)if(t){const r=w();var e;if("number"==typeof f)null==(e=r[f])||e.focus({preventScroll:!0});else if(f.current){var n;null==(n=r.find((e=>e===f.current)))||n.focus({preventScroll:!0})}}else p&&j(l.reference.current)&&l.reference.current.focus({preventScroll:!0})}),[w,t,g,p,f,d,l.reference]),r((()=>{if(!p||!d)return;const e=R(l.floating.current);if(!t)return e.removeEventListener("keydown",n),void(b.current=0);function n(e){var n;if((null==y||null==(n=y.nodesRef.current)||!n.filter((e=>{let{parentId:n}=e;return n===a})).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))&&"Tab"===e.key){var r;if(e.preventDefault(),e.stopPropagation(),g)return;const n=w();e.shiftKey?b.current=0===b.current?n.length-1:b.current-1:b.current=b.current===n.length-1?0:b.current+1,null==(r=n[b.current])||r.focus({preventScroll:!0})}}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}}),[w,null==y?void 0:y.nodesRef,a,t,p,g,d,l.floating]),r((()=>{if(!t||!p||!d)return;const e=R(l.floating.current),n=e.querySelector("#"+h),r=e.querySelectorAll("body > *:not(#"+h+")");return r.forEach((e=>{e.setAttribute("aria-hidden","true")})),()=>{(null==n?void 0:n.firstElementChild)===l.floating.current&&r.forEach((e=>{e.removeAttribute("aria-hidden")}))}}),[t,p,m,h,d,l.floating]),v((()=>{if(!t||!d)return;const e=R(l.floating.current);if(m){var n;const r=(null!=(n=e.defaultView)?n:window).innerWidth-e.documentElement.offsetWidth;e.documentElement.style.overflow="hidden",e.body.style.paddingRight=r+"px"}return()=>{m&&(e.documentElement.style.overflow="",e.body.style.paddingRight="")}}),[t,m,d]),d?p?{floating:{"aria-modal":"true"}}:{reference:{onBlur:k},floating:{onBlur:k}}:{}};function ee(e){e.preventDefault(),e.stopPropagation()}function ne(e,n){let{startingIndex:r=-1,decrement:t=!1}=void 0===n?{}:n,o=r;do{var c,u;o+=t?-1:1}while(null!=(c=e.current[o])&&c.hasAttribute("disabled")||"true"===(null==(u=e.current[o])?void 0:u.getAttribute("aria-disabled")));return-1===o?0:o}const re=function(e,n){let{open:r,onOpenChange:t,refs:o}=e,{enabled:i=!0,listRef:l={current:[]},activeIndex:a=null,selectedIndex:d=null,loop:f=!1,nested:s=!1,rtl:p=!1,onNavigate:g=(()=>{})}=void 0===n?{}:n;const m=c(!0),h=c(null!=d?d:0),y=c(""),b=u(((e,n)=>{var r;null==(r=e.current[n.current])||r.focus({preventScroll:!0})}),[]);function w(e){m.current=!e.pointerType}return v((()=>{i&&(null!=d&&(h.current=d),r&&m.current&&(g(h.current),b(l,h)))}),[r,d,l,g,b,i]),v((()=>{i&&r&&null!=a&&(h.current=a,g(h.current),b(l,h))}),[r,a,l,g,b,i]),v((()=>{null==d&&i&&(r&&("ArrowDown"===y.current||"ArrowUp"===y.current||m.current&&(" "===y.current||"Enter"===y.current))&&(h.current="ArrowUp"===y.current?ne(l,{startingIndex:l.current.length,decrement:!0}):ne(l),g(h.current),b(l,h)),y.current="")}),[r,l,d,g,b,i]),v((()=>{var e;i&&(r||null==d||null==(e=o.reference.current)||e.focus({preventScroll:!0}))}),[o.reference,d,r,i]),v((()=>{i&&(r||(m.current=!0,g(null)))}),[r,i]),i?{reference:{onPointerEnter:w,onPointerDown:w,onKeyDown(e){m.current=!0,y.current=e.key,N(o.reference.current)&&"BUTTON"!==o.reference.current.tagName&&("Enter"!==e.key&&" "!==e.key||t(!0)),s?e.key===(p?"ArrowLeft":"ArrowRight")&&(h.current=ne(l),ee(e),t(!0),g(h.current)):"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(h.current=null==d?"ArrowDown"===e.key?ne(l):ne(l,{startingIndex:l.current.length,decrement:!0}):d,ee(e),t(!0),g(h.current))}},floating:{onKeyDown(e){if(s&&e.key===(p?"ArrowRight":"ArrowLeft"))return ee(e),t(!1),void(j(o.reference.current)&&o.reference.current.focus());const n=h.current,r=ne(l),c=ne(l,{decrement:!0,startingIndex:l.current.length});if("Home"===e.key&&(h.current=r,g(h.current),b(l,h)),"End"===e.key&&(h.current=c,g(h.current),b(l,h)),"ArrowDown"===e.key||"ArrowUp"===e.key){if(ee(e),e.currentTarget.ownerDocument.activeElement===e.currentTarget&&null!=d)return h.current=d,g(h.current),void b(l,h);"ArrowDown"===e.key?h.current=f?n===c?r:ne(l,{startingIndex:n}):Math.min(c,ne(l,{startingIndex:n})):h.current=f?n===r?c:ne(l,{startingIndex:n,decrement:!0}):Math.max(r,ne(l,{startingIndex:n,decrement:!0})),g(h.current),b(l,h)}}}}:{}},te=function(e,n){let{open:r}=e,{enabled:t=!0,listRef:o={current:[]},onMatch:u=(()=>{}),onFind:i=null,debounceMs:l=500,ignoreKeys:a=[]}=void 0===n?{}:n;const d=c(),f=c(""),s=c(null),p=c(null);function g(e){if(!e.currentTarget.contains(R(e.currentTarget).activeElement))return;" "===e.key&&f.current.length>0&&(e.preventDefault(),e.stopPropagation());const n=o.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...a].includes(e.key))return;n.every((e=>{var n,r;return!e||(null==(n=e[0])?void 0:n.toLowerCase())!==(null==(r=e[1])?void 0:r.toLowerCase())}))&&f.current===e.key&&(f.current="",s.current=p.current),f.current+=e.key,clearTimeout(d.current),d.current=setTimeout((()=>{f.current="",s.current=p.current}),l);const r=s.current,t=[...n.slice((null!=r?r:0)+1),...n.slice(0,null!=r?r:0)].find((e=>i?i(e,f.current):0===(null==e?void 0:e.toLowerCase().indexOf(f.current)))),c=t?n.indexOf(t):-1;-1!==c&&(u(c),p.current=c)}return v((()=>{r&&(clearTimeout(d.current),s.current=null,p.current=null,f.current="")}),[r]),t?{reference:{onKeyDown:g},floating:{onKeyDown:g}}:{}};function oe(e){let{open:n=!1,onOpenChange:r=(()=>{}),placement:o,middleware:u,strategy:i,nodeId:a}=void 0===e?{}:e;const d=E(),s=c({}),g=l((()=>p()))[0],m=f({placement:o,middleware:u,strategy:i}),h=t((()=>({...m,dataRef:s,nodeId:a,events:g,open:n,onOpenChange:r})),[m,s,a,g,n,r]);return v((()=>{const e=null==d?void 0:d.nodesRef.current.find((e=>e.id===a));e&&(e.context=h)})),t((()=>({context:h,...m})),[m,h])}export{_ as FloatingDelayGroup,x as FloatingNode,q as FloatingOverlay,F as FloatingPortal,T as FloatingTree,M as safePolygon,G as useAria,J as useClick,z as useDelayGroup,Y as useDelayGroupContext,Q as useDismiss,oe as useFloating,h as useFloatingId,k as useFloatingNodeId,w as useFloatingParentNodeId,E as useFloatingTree,Z as useFocus,$ as useFocusTrap,W as useHover,A as useInteractions,re as useListNavigation,te as useTypeahead}; |
@@ -5,9 +5,9 @@ (function (global, factory) { | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUIReactDOM = {}, global.React, global.FloatingUIReactDOM, global.ReactDOM)); | ||
})(this, (function (exports, React$1, reactDom, reactDom$1) { 'use strict'; | ||
})(this, (function (exports, React, reactDom, reactDom$1) { 'use strict'; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1); | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var index = typeof document !== 'undefined' ? React$1.useLayoutEffect : React$1.useEffect; | ||
var index = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect; | ||
@@ -41,13 +41,13 @@ function createPubSub() { | ||
function useFloatingId() { | ||
return React$1.useMemo(genId, []); | ||
return React.useMemo(genId, []); | ||
} | ||
const FloatingNodeContext = /*#__PURE__*/React$1.createContext(null); | ||
const FloatingTreeContext = /*#__PURE__*/React$1.createContext(null); | ||
const FloatingNodeContext = /*#__PURE__*/React.createContext(null); | ||
const FloatingTreeContext = /*#__PURE__*/React.createContext(null); | ||
const useFloatingParentNodeId = () => { | ||
var _useContext$id, _useContext; | ||
return (_useContext$id = (_useContext = React$1.useContext(FloatingNodeContext)) == null ? void 0 : _useContext.id) != null ? _useContext$id : null; | ||
return (_useContext$id = (_useContext = React.useContext(FloatingNodeContext)) == null ? void 0 : _useContext.id) != null ? _useContext$id : null; | ||
}; | ||
const useFloatingTree = () => React$1.useContext(FloatingTreeContext); | ||
const useFloatingTree = () => React.useContext(FloatingTreeContext); | ||
/** | ||
@@ -84,3 +84,3 @@ * Registers a node into the floating tree, returning its id. | ||
const parentId = useFloatingParentNodeId(); | ||
return /*#__PURE__*/React.createElement(FloatingNodeContext.Provider, { | ||
return /*#__PURE__*/React__default["default"].createElement(FloatingNodeContext.Provider, { | ||
value: { | ||
@@ -103,10 +103,10 @@ id, | ||
} = _ref2; | ||
const nodesRef = React$1.useRef([]); | ||
const addNode = React$1.useCallback(node => { | ||
const nodesRef = React.useRef([]); | ||
const addNode = React.useCallback(node => { | ||
nodesRef.current = [...nodesRef.current, node]; | ||
}, []); | ||
const removeNode = React$1.useCallback(node => { | ||
const removeNode = React.useCallback(node => { | ||
nodesRef.current = nodesRef.current.filter(n => n !== node); | ||
}, []); | ||
return /*#__PURE__*/React.createElement(FloatingTreeContext.Provider, { | ||
return /*#__PURE__*/React__default["default"].createElement(FloatingTreeContext.Provider, { | ||
value: { | ||
@@ -448,4 +448,4 @@ nodesRef, | ||
const DEFAULT_ID = 'floating-ui-root'; | ||
const FloatingPortalContext = /*#__PURE__*/React$1.createContext(DEFAULT_ID); | ||
const useFloatingPortalId = () => React$1.useContext(FloatingPortalContext); | ||
const FloatingPortalContext = /*#__PURE__*/React.createContext(DEFAULT_ID); | ||
const useFloatingPortalId = () => React.useContext(FloatingPortalContext); | ||
/** | ||
@@ -461,4 +461,4 @@ * Portals your floating element outside of the main app node. | ||
} = _ref; | ||
const [mounted, setMounted] = React$1.useState(false); | ||
const portalRef = React$1.useRef(null); | ||
const [mounted, setMounted] = React.useState(false); | ||
const portalRef = React.useRef(null); | ||
index(() => { | ||
@@ -517,4 +517,4 @@ const root = document.getElementById(id); | ||
const FloatingOverlay = /*#__PURE__*/React$1.forwardRef(function FloatingOverlay(props, ref) { | ||
return /*#__PURE__*/React.createElement("div", _extends({ | ||
const FloatingOverlay = /*#__PURE__*/React.forwardRef(function FloatingOverlay(props, ref) { | ||
return /*#__PURE__*/React__default["default"].createElement("div", _extends({ | ||
ref: ref | ||
@@ -563,6 +563,6 @@ }, props, { | ||
const tree = useFloatingTree(); | ||
const timeoutRef = React$1.useRef(); | ||
const handlerRef = React$1.useRef(); | ||
const pointerRestTimeoutRef = React$1.useRef(); | ||
const blockPointerMoveRef = React$1.useRef(true); | ||
const timeoutRef = React.useRef(); | ||
const handlerRef = React.useRef(); | ||
const pointerRestTimeoutRef = React.useRef(); | ||
const blockPointerMoveRef = React.useRef(true); | ||
index(() => { | ||
@@ -573,3 +573,3 @@ if (!open) { | ||
}, [open]); | ||
React$1.useEffect(() => { | ||
React.useEffect(() => { | ||
function onDismiss() { | ||
@@ -680,3 +680,3 @@ clearTimeout(timeoutRef.current); | ||
const FloatingDelayGroupContext = /*#__PURE__*/React$1.createContext({ | ||
const FloatingDelayGroupContext = /*#__PURE__*/React.createContext({ | ||
delay: 1000, | ||
@@ -688,3 +688,3 @@ initialDelay: 1000, | ||
}); | ||
const useDelayGroupContext = () => React$1.useContext(FloatingDelayGroupContext); | ||
const useDelayGroupContext = () => React.useContext(FloatingDelayGroupContext); | ||
/** | ||
@@ -701,3 +701,3 @@ * Provides context for a group of floating elements that should share a | ||
} = _ref; | ||
const [state, setState] = React$1.useState({ | ||
const [state, setState] = React.useState({ | ||
delay, | ||
@@ -707,3 +707,3 @@ initialDelay: delay, | ||
}); | ||
const setCurrentId = React$1.useCallback(currentId => { | ||
const setCurrentId = React.useCallback(currentId => { | ||
setState(state => ({ ...state, | ||
@@ -713,3 +713,3 @@ currentId | ||
}, []); | ||
return /*#__PURE__*/React.createElement(FloatingDelayGroupContext.Provider, { | ||
return /*#__PURE__*/React__default["default"].createElement(FloatingDelayGroupContext.Provider, { | ||
value: { ...state, | ||
@@ -734,3 +734,3 @@ setState, | ||
} = useDelayGroupContext(); | ||
React$1.useEffect(() => { | ||
React.useEffect(() => { | ||
if (currentId && onOpenChange) { | ||
@@ -749,3 +749,3 @@ setState(state => ({ ...state, | ||
}, [id, onOpenChange, setState, currentId, initialDelay]); | ||
React$1.useEffect(() => { | ||
React.useEffect(() => { | ||
if (!open && currentId === id && onOpenChange) { | ||
@@ -872,3 +872,3 @@ onOpenChange(false); | ||
const tree = useFloatingTree(); | ||
const focusReference = React$1.useCallback(() => { | ||
const focusReference = React.useCallback(() => { | ||
if (isHTMLElement(refs.reference.current)) { | ||
@@ -879,3 +879,3 @@ refs.reference.current.focus(); | ||
}, [refs.reference.current]); | ||
React$1.useEffect(() => { | ||
React.useEffect(() => { | ||
if (!open || !enabled) { | ||
@@ -962,4 +962,4 @@ return; | ||
} = _temp === void 0 ? {} : _temp; | ||
const blockFocusRef = React$1.useRef(false); | ||
React$1.useEffect(() => { | ||
const blockFocusRef = React.useRef(false); | ||
React.useEffect(() => { | ||
var _doc$defaultView; | ||
@@ -991,3 +991,3 @@ | ||
}, [refs.floating, open, enabled]); | ||
React$1.useEffect(() => { | ||
React.useEffect(() => { | ||
if (!enabled) { | ||
@@ -1084,4 +1084,4 @@ return; | ||
const tree = useFloatingTree(); | ||
const indexRef = React$1.useRef(0); | ||
const getFocusableElements = React$1.useCallback(() => { | ||
const indexRef = React.useRef(0); | ||
const getFocusableElements = React.useCallback(() => { | ||
return order.map(type => { | ||
@@ -1105,3 +1105,3 @@ if (isHTMLElement(refs.reference.current) && type === 'reference') { | ||
}, [refs.floating, refs.reference, order]); | ||
React$1.useEffect(() => { | ||
React.useEffect(() => { | ||
if (inert || !enabled) { | ||
@@ -1133,3 +1133,3 @@ return; | ||
}, [getFocusableElements, open, inert, modal, initialContentFocus, enabled, refs.reference]); | ||
React$1.useEffect(() => { | ||
React.useEffect(() => { | ||
if (!modal || !enabled) { | ||
@@ -1204,3 +1204,3 @@ return; | ||
React$1.useEffect(() => { | ||
React.useEffect(() => { | ||
if (!open || !modal || !enabled) { | ||
@@ -1313,6 +1313,6 @@ return; | ||
} = _temp2 === void 0 ? {} : _temp2; | ||
const focusOnOpenRef = React$1.useRef(true); | ||
const indexRef = React$1.useRef(selectedIndex != null ? selectedIndex : 0); | ||
const keyRef = React$1.useRef(''); | ||
const focusItem = React$1.useCallback((listRef, indexRef) => { | ||
const focusOnOpenRef = React.useRef(true); | ||
const indexRef = React.useRef(selectedIndex != null ? selectedIndex : 0); | ||
const keyRef = React.useRef(''); | ||
const focusItem = React.useCallback((listRef, indexRef) => { | ||
var _listRef$current$inde3; | ||
@@ -1537,6 +1537,6 @@ | ||
} = _temp === void 0 ? {} : _temp; | ||
const timeoutIdRef = React$1.useRef(); | ||
const stringRef = React$1.useRef(''); | ||
const prevIndexRef = React$1.useRef(null); | ||
const matchIndexRef = React$1.useRef(null); | ||
const timeoutIdRef = React.useRef(); | ||
const stringRef = React.useRef(''); | ||
const prevIndexRef = React.useRef(null); | ||
const matchIndexRef = React.useRef(null); | ||
index(() => { | ||
@@ -1621,4 +1621,4 @@ if (open) { | ||
const tree = useFloatingTree(); | ||
const dataRef = React$1.useRef({}); | ||
const events = React$1.useState(() => createPubSub())[0]; | ||
const dataRef = React.useRef({}); | ||
const events = React.useState(() => createPubSub())[0]; | ||
const floating = reactDom.useFloating({ | ||
@@ -1629,3 +1629,3 @@ placement, | ||
}); | ||
const context = React$1.useMemo(() => ({ ...floating, | ||
const context = React.useMemo(() => ({ ...floating, | ||
dataRef, | ||
@@ -1644,3 +1644,3 @@ nodeId, | ||
}); | ||
return React$1.useMemo(() => ({ | ||
return React.useMemo(() => ({ | ||
context, | ||
@@ -1647,0 +1647,0 @@ ...floating |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("@floating-ui/react-dom"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","@floating-ui/react-dom","react-dom"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.React,e.FloatingUIReactDOM,e.ReactDOM)}(this,(function(e,n,t,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=o(n),c="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;function l(){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 i=0;function a(){return"floating-ui-"+i++}function s(){return n.useMemo(a,[])}const f=n.createContext(null),d=n.createContext(null),v=()=>{var e,t;return null!=(e=null==(t=n.useContext(f))?void 0:t.id)?e:null},g=()=>n.useContext(d);function p(e){return Object.entries(null!=e?e:{}).reduce(((e,n)=>{let[t,r]=n;return e[t]=[r],e}),{})}function m(e,n,t){const r={reference:"reference"===t?p(e):{},floating:"floating"===t?p(e):{}};return n.forEach((e=>{var n;const o=null!=(n=null==e?void 0:e[t])?n:{};Object.keys(o).forEach((e=>{var n;"function"==typeof o[e]&&(null==r[t][e]&&(r[t][e]=[]),null==(n=r[t][e])||n.push(o[e]))}))})),{..."floating"===t&&{tabIndex:-1},...e,...n.reduce(((e,n)=>(Object.assign(e,null==n?void 0:n[t]),e)),{}),...Object.entries(r[t]).reduce(((e,n)=>{let[t,r]=n;return 0===t.indexOf("on")&&(e[t]=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];r.forEach((e=>e(...n)))}),e}),{})}}var h={exports:{}},y=function(e,n,t,r){var o=e[0],u=e[1],c=!1;void 0===t&&(t=0),void 0===r&&(r=n.length);for(var l=(r-t)/2,i=0,a=l-1;i<l;a=i++){var s=n[t+2*i+0],f=n[t+2*i+1],d=n[t+2*a+0],v=n[t+2*a+1];f>u!=v>u&&o<(d-s)*(u-f)/(v-f)+s&&(c=!c)}return c},b=function(e,n,t,r){var o=e[0],u=e[1],c=!1;void 0===t&&(t=0),void 0===r&&(r=n.length);for(var l=r-t,i=0,a=l-1;i<l;a=i++){var s=n[i+t][0],f=n[i+t][1],d=n[a+t][0],v=n[a+t][1];f>u!=v>u&&o<(d-s)*(u-f)/(v-f)+s&&(c=!c)}return c};h.exports=function(e,n,t,r){return n.length>0&&Array.isArray(n[0])?b(e,n,t,r):y(e,n,t,r)},h.exports.nested=b,h.exports.flat=y;var E=h.exports;function w(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function x(e){var n;return null!=(n=w(e).defaultView)?n:window}function k(e){return!!e&&e instanceof x(e).Element}function R(e){return!!e&&e instanceof x(e).HTMLElement}function C(e,n){var t;let r=null!=(t=null==e?void 0:e.nodesRef.current.filter((e=>{var t;return e.parentId===n&&(null==(t=e.context)?void 0:t.open)})))?t:[],o=r;for(;o.length;){var u;o=null!=(u=null==e?void 0:e.nodesRef.current.filter((e=>{var n;return null==(n=o)?void 0:n.some((n=>{var t;return e.parentId===n.id&&(null==(t=e.context)?void 0:t.open)}))})))?u:[],r=r.concat(o)}return r}const T="floating-ui-root",I=n.createContext(T);function O(){return O=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},O.apply(this,arguments)}const D=n.forwardRef((function(e,n){return React.createElement("div",O({ref:n},e,{style:{position:"fixed",top:0,right:0,bottom:0,left:0,width:"100%",height:"100%",...e.style}}))}));function A(e,n){return"number"==typeof e?e:null==e?void 0:e[n]}const L=n.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),P=()=>n.useContext(L);function F(e){e.preventDefault(),e.stopPropagation()}function S(e,n){let{startingIndex:t=-1,decrement:r=!1}=void 0===n?{}:n,o=t;do{var u,c;o+=r?-1:1}while(null!=(u=e.current[o])&&u.hasAttribute("disabled")||"true"===(null==(c=e.current[o])?void 0:c.getAttribute("aria-disabled")));return-1===o?0:o}e.FloatingDelayGroup=e=>{let{children:t,delay:r}=e;const[o,u]=n.useState({delay:r,initialDelay:r,currentId:null}),c=n.useCallback((e=>{u((n=>({...n,currentId:e})))}),[]);return React.createElement(L.Provider,{value:{...o,setState:u,setCurrentId:c}},t)},e.FloatingNode=e=>{let{children:n,id:t}=e;const r=v();return React.createElement(f.Provider,{value:{id:t,parentId:r}},n)},e.FloatingOverlay=D,e.FloatingPortal=e=>{let{children:t,id:o=T}=e;const[l,i]=n.useState(!1),a=n.useRef(null);return c((()=>{const e=document.getElementById(o);e?a.current=e:(a.current=document.createElement("div"),a.current.id=o);const n=a.current;document.body.contains(n)||document.body.appendChild(n),i(!0)}),[]),l&&a.current?u.default.createElement(I.Provider,{value:o},r.createPortal(t,a.current)):null},e.FloatingTree=e=>{let{children:t}=e;const r=n.useRef([]),o=n.useCallback((e=>{r.current=[...r.current,e]}),[]),u=n.useCallback((e=>{r.current=r.current.filter((n=>n!==e))}),[]);return React.createElement(d.Provider,{value:{nodesRef:r,addNode:o,removeNode:u,events:l()}},t)},e.safePolygon=function(e){let n,{timeout:t=0,debug:r=null}=void 0===e?{}:e;return e=>{let{x:o,y:u,placement:c,refs:l,onClose:i,nodeId:a,tree:s}=e;return function(e){var f;if("touch"===e.pointerType)return;const{target:d,clientX:v,clientY:g}=e,p=d;if("pointermove"===e.type&&k(l.reference.current)&&l.reference.current.contains(p)||null!=(f=l.floating.current)&&f.contains(p))return;if(s&&C(s,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(!l.reference.current||!l.floating.current||null==c||null==o||null==u)return;const m=l.reference.current.getBoundingClientRect(),h=l.floating.current.getBoundingClientRect(),y=c.split("-")[0],b=o>h.right-h.width/2,w=u>h.bottom-h.height/2;switch(y){case"top":if(v>=h.left&&v<=h.right&&g>=h.bottom&&g<=m.top)return;break;case"bottom":if(v>=h.left&&v<=h.right&&g>=m.bottom&&g<=h.top)return;break;case"left":if(v>=h.right&&v<=m.left&&g>=h.left&&g<=h.right)return;break;case"right":if(v>=h.right&&v<=m.left&&g>=h.right&&g<=m.left)return}function x(e){let[n,t]=e;const r=h.width>m.width,o=h.height>m.height;switch(y){case"top":{const e=[r?n:b?n+1:n-1,t+1],o=[r?n:b?n-1:n+1,t+1],u=[[h.left,b||r?h.bottom-1:h.top],[h.right,b?r?h.bottom-1:h.top:h.bottom-1]];return b?[e,o,...u]:[e,...u,o]}case"bottom":{const e=[r?n:b?n+1:n-1,t-1],o=[r?n:b?n-1:n+1,t-1],u=[[h.left,b||r?h.top+1:h.bottom],[h.right,b?r?h.top+1:h.bottom:h.top+1]];return b?[e,o,...u]:[e,...u,o]}case"left":{const e=[n+1,o?t:w?t-1:t+1],r=[n+1,o?t:w?t+1:t-1],u=[[w||o?h.right-1:h.left,h.top],[w?o?h.right-1:h.left:h.right-1,h.bottom]];return w?[e,...u,r]:[...u,e,r]}case"right":{const e=[n-1,o?t:w?t+1:t-1],r=[n-1,o?t:w?t-1:t+1],u=[[w||o?h.left+1:h.right,h.top],[w?o?h.left+1:h.right:h.left+1,h.bottom]];return w?[e,r,...u]:[e,...u,r]}}}const R=x([o,u]);"production"!==process.env.NODE_ENV&&(null==r||r(x([o,u]).slice(0,4).join(", "))),E([v,g],R)?t&&(n=setTimeout(i,t)):(clearTimeout(n),i())}}},e.useAria=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog",titleId:u,descriptionId:c}=void 0===n?{}:n;const l=s(),i={id:l,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?l:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?l:void 0,..."listbox"===o&&{role:"combobox"}},floating:{...i,..."dialog"===o&&{"aria-labelledby":u,"aria-describedby":c}}}:{}},e.useClick=function(e,n){let{open:t,onOpenChange:r,dataRef:o}=e,{enabled:u=!0}=void 0===n?{}:n;return u?{reference:{onClick(e){var n;t?"click"===(null==(n=o.current.openEvent)?void 0:n.type)||o.current.hoveredThenClicked?(o.current.hoveredThenClicked=!1,r(!1)):o.current.hoveredThenClicked=!0:(o.current.openEvent=e.nativeEvent,r(!0))}}}:{}},e.useDelayGroup=(e,t)=>{let{open:r,onOpenChange:o}=e,{id:u}=t;const{currentId:c,initialDelay:l,setState:i}=P();n.useEffect((()=>{c&&o&&(i((e=>({...e,delay:{open:0,close:A(l,"close")}}))),c!==u&&o(!1))}),[u,o,i,c,l]),n.useEffect((()=>{!r&&c===u&&o&&(o(!1),i((e=>({...e,delay:l,currentId:null}))))}),[r,i,c,u,o,l])},e.useDelayGroupContext=P,e.useDismiss=function(e,r){let{open:o,onOpenChange:u,refs:c,events:l,nodeId:i}=e,{enabled:a=!0,escapeKey:s=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:v=!1}=void 0===r?{}:r;const p=g(),m=n.useCallback((()=>{R(c.reference.current)&&c.reference.current.focus()}),[c.reference.current]);return n.useEffect((()=>{if(!o||!a)return;function e(e){"Escape"===e.key&&(l.emit("dismiss"),u(!1),m())}function n(e){var n;const t=p&&C(p,i).some((n=>{var t,r;return null==(t=n.context)||null==(r=t.refs.floating.current)?void 0:r.contains(e.target)}));null!=(n=c.floating.current)&&n.contains(e.target)||k(c.reference.current)&&c.reference.current.contains(e.target)||t||(l.emit("dismiss"),u(!1),m())}function r(){u(!1)}const d=w(c.floating.current);s&&d.addEventListener("keydown",e),f&&d.addEventListener("pointerdown",n);const g=v?[...k(c.reference.current)?t.getOverflowAncestors(c.reference.current):[],...k(c.floating.current)?t.getOverflowAncestors(c.floating.current):[]]:[];return g.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{s&&d.removeEventListener("keydown",e),f&&d.removeEventListener("pointerdown",n),g.forEach((e=>e.removeEventListener("scroll",r)))}}),[s,f,l,p,i,o,u,m,v,a,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(l.emit("dismiss"),u(!1))}}}:{}},e.useFloating=function(e){let{open:r=!1,onOpenChange:o=(()=>{}),placement:u,middleware:i,strategy:a,nodeId:s}=void 0===e?{}:e;const f=g(),d=n.useRef({}),v=n.useState((()=>l()))[0],p=t.useFloating({placement:u,middleware:i,strategy:a}),m=n.useMemo((()=>({...p,dataRef:d,nodeId:s,events:v,open:r,onOpenChange:o})),[p,d,s,v,r,o]);return c((()=>{const e=null==f?void 0:f.nodesRef.current.find((e=>e.id===s));e&&(e.context=m)})),n.useMemo((()=>({context:m,...p})),[p,m])},e.useFloatingId=s,e.useFloatingNodeId=()=>{const e=s(),n=g(),t=v();return c((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},e.useFloatingParentNodeId=v,e.useFloatingTree=g,e.useFocus=function(e,t){let{open:r,onOpenChange:o,dataRef:u,refs:c,events:l}=e,{enabled:i=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const s=n.useRef(!1);return n.useEffect((()=>{var e;if(!i)return;const n=null!=(e=w(c.floating.current).defaultView)?e:window;function t(){s.current=!r}function o(){setTimeout((()=>{s.current=!1}))}return n.addEventListener("focus",o),n.addEventListener("blur",t),()=>{n.addEventListener("focus",o),n.removeEventListener("blur",t)}}),[c.floating,r,i]),n.useEffect((()=>{if(i)return l.on("dismiss",e),()=>{l.off("dismiss",e)};function e(){s.current=!0}}),[l,i]),i?{reference:{onPointerDown(e){let{pointerType:n}=e;s.current=!(!n||!a)},onFocus(e){var n,t;s.current||"focus"===e.type&&"mousedown"===u.current.openEvent&&k(c.reference.current)&&null!=(n=c.reference.current)&&n.contains(null==(t=u.current.openEvent)?void 0:t.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n;const t=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(t)||k(c.reference.current)&&c.reference.current.contains(t)||(s.current=!1,u.current.hoveredThenClicked=!1,o(!1))}}}:{}},e.useFocusTrap=function(e,t){let{open:r,onOpenChange:o,refs:u,nodeId:l}=e,{enabled:i=!0,initialContentFocus:a=0,order:s=["content"],modal:f=!0,inert:d=!1,scrollLock:v=!1}=void 0===t?{}:t;const p=n.useContext(I),m=g(),h=n.useRef(0),y=n.useCallback((()=>s.map((e=>{return R(u.reference.current)&&"reference"===e?u.reference.current:u.floating.current&&"floating"===e?u.floating.current:"content"===e?Array.from(null!=(n=null==(t=u.floating.current)?void 0:t.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable]"))?n:[]):null;var n,t})).filter(Boolean).flat()),[u.floating,u.reference,s]);function b(e){var n;const t=e.relatedTarget;!t||null!=(n=u.floating.current)&&n.contains(t)||!k(u.reference.current)||u.reference.current.contains(t)||o(!1)}return n.useEffect((()=>{if(!d&&i)if(r){const t=y();var e;if("number"==typeof a)null==(e=t[a])||e.focus({preventScroll:!0});else if(a.current){var n;null==(n=t.find((e=>e===a.current)))||n.focus({preventScroll:!0})}}else f&&R(u.reference.current)&&u.reference.current.focus({preventScroll:!0})}),[y,r,d,f,a,i,u.reference]),n.useEffect((()=>{if(!f||!i)return;const e=w(u.floating.current);if(!r)return e.removeEventListener("keydown",n),void(h.current=0);function n(e){var n;if((null==m||null==(n=m.nodesRef.current)||!n.filter((e=>{let{parentId:n}=e;return n===l})).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))&&"Tab"===e.key){var t;if(e.preventDefault(),e.stopPropagation(),d)return;const n=y();e.shiftKey?h.current=0===h.current?n.length-1:h.current-1:h.current=h.current===n.length-1?0:h.current+1,null==(t=n[h.current])||t.focus({preventScroll:!0})}}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}}),[y,null==m?void 0:m.nodesRef,l,r,f,d,i,u.floating]),n.useEffect((()=>{if(!r||!f||!i)return;const e=w(u.floating.current),n=e.querySelector("#"+p),t=e.querySelectorAll("body > *:not(#"+p+")");return t.forEach((e=>{e.setAttribute("aria-hidden","true")})),()=>{(null==n?void 0:n.firstElementChild)===u.floating.current&&t.forEach((e=>{e.removeAttribute("aria-hidden")}))}}),[r,f,v,p,i,u.floating]),c((()=>{if(!r||!i)return;const e=w(u.floating.current);if(v){var n;const t=(null!=(n=e.defaultView)?n:window).innerWidth-e.documentElement.offsetWidth;e.documentElement.style.overflow="hidden",e.body.style.paddingRight=t+"px"}return()=>{v&&(e.documentElement.style.overflow="",e.body.style.paddingRight="")}}),[r,v,i]),i?f?{floating:{"aria-modal":"true"}}:{reference:{onBlur:b},floating:{onBlur:b}}:{}},e.useHover=function(e,t){let{enabled:r=!0,delay:o=0,handleLeave:u=null,mouseOnly:l=!1,pointerRestMs:i=0}=void 0===t?{}:t;const{open:a,onOpenChange:s,dataRef:f,events:d,refs:v}=e,p=g(),m=n.useRef(),h=n.useRef(),y=n.useRef(),b=n.useRef(!0);function E(e){void 0===e&&(e=!0),o?(clearTimeout(m.current),m.current=setTimeout((()=>s(!1)),A(o,"close"))):e&&s(!1)}return c((()=>{a||(f.current.hoveredThenClicked=!1)}),[a]),n.useEffect((()=>{function e(){clearTimeout(m.current),clearTimeout(y.current),b.current=!0}return d.on("dismiss",e),()=>{d.off("dismiss",e)}}),[d]),r?{reference:{onPointerMove(){0===i||a||(clearTimeout(y.current),y.current=setTimeout((()=>{b.current||s(!0)}),i))},onPointerEnter(e){l&&"mouse"!==e.pointerType||(b.current=!1,f.current.openEvent=e.nativeEvent,o?(clearTimeout(m.current),m.current=setTimeout((()=>{s(!0)}),A(o,"open"))):s(!0))},onPointerLeave(n){var t;if(f.current.hoveredThenClicked||"click"===(null==(t=f.current.openEvent)?void 0:t.type))return;const r=w(v.floating.current);if(clearTimeout(y.current),u)return clearTimeout(m.current),h.current&&r.removeEventListener("pointermove",h.current),h.current=u({...e,tree:p,x:n.clientX,y:n.clientY,onClose(){h.current&&r.removeEventListener("pointermove",h.current),E()}}),h.current(n.nativeEvent),void r.addEventListener("pointermove",h.current);E()}},floating:{onPointerEnter(){clearTimeout(m.current)},onPointerLeave:()=>E(!1)}}:{}},e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>m(n,e,"reference"),getFloatingProps:n=>m(n,e,"floating")}},e.useListNavigation=function(e,t){let{open:r,onOpenChange:o,refs:u}=e,{enabled:l=!0,listRef:i={current:[]},activeIndex:a=null,selectedIndex:s=null,loop:f=!1,nested:d=!1,rtl:v=!1,onNavigate:g=(()=>{})}=void 0===t?{}:t;const p=n.useRef(!0),m=n.useRef(null!=s?s:0),h=n.useRef(""),y=n.useCallback(((e,n)=>{var t;null==(t=e.current[n.current])||t.focus({preventScroll:!0})}),[]);function b(e){p.current=!e.pointerType}return c((()=>{l&&(null!=s&&(m.current=s),r&&p.current&&(g(m.current),y(i,m)))}),[r,s,i,g,y,l]),c((()=>{l&&r&&null!=a&&(m.current=a,g(m.current),y(i,m))}),[r,a,i,g,y,l]),c((()=>{null==s&&l&&(r&&("ArrowDown"===h.current||"ArrowUp"===h.current||p.current&&(" "===h.current||"Enter"===h.current))&&(m.current="ArrowUp"===h.current?S(i,{startingIndex:i.current.length,decrement:!0}):S(i),g(m.current),y(i,m)),h.current="")}),[r,i,s,g,y,l]),c((()=>{var e;l&&(r||null==s||null==(e=u.reference.current)||e.focus({preventScroll:!0}))}),[u.reference,s,r,l]),c((()=>{l&&(r||(p.current=!0,g(null)))}),[r,l]),l?{reference:{onPointerEnter:b,onPointerDown:b,onKeyDown(e){p.current=!0,h.current=e.key,k(u.reference.current)&&"BUTTON"!==u.reference.current.tagName&&("Enter"!==e.key&&" "!==e.key||o(!0)),d?e.key===(v?"ArrowLeft":"ArrowRight")&&(m.current=S(i),F(e),o(!0),g(m.current)):"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(m.current=null==s?"ArrowDown"===e.key?S(i):S(i,{startingIndex:i.current.length,decrement:!0}):s,F(e),o(!0),g(m.current))}},floating:{onKeyDown(e){if(d&&e.key===(v?"ArrowRight":"ArrowLeft"))return F(e),o(!1),void(R(u.reference.current)&&u.reference.current.focus());const n=m.current,t=S(i),r=S(i,{decrement:!0,startingIndex:i.current.length});if("Home"===e.key&&(m.current=t,g(m.current),y(i,m)),"End"===e.key&&(m.current=r,g(m.current),y(i,m)),"ArrowDown"===e.key||"ArrowUp"===e.key){if(F(e),e.currentTarget.ownerDocument.activeElement===e.currentTarget&&null!=s)return m.current=s,g(m.current),void y(i,m);"ArrowDown"===e.key?m.current=f?n===r?t:S(i,{startingIndex:n}):Math.min(r,S(i,{startingIndex:n})):m.current=f?n===t?r:S(i,{startingIndex:n,decrement:!0}):Math.max(t,S(i,{startingIndex:n,decrement:!0})),g(m.current),y(i,m)}}}}:{}},e.useTypeahead=function(e,t){let{open:r}=e,{enabled:o=!0,listRef:u={current:[]},onMatch:l=(()=>{}),onFind:i=null,debounceMs:a=500,ignoreKeys:s=[]}=void 0===t?{}:t;const f=n.useRef(),d=n.useRef(""),v=n.useRef(null),g=n.useRef(null);function p(e){if(!e.currentTarget.contains(w(e.currentTarget).activeElement))return;" "===e.key&&d.current.length>0&&(e.preventDefault(),e.stopPropagation());const n=u.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...s].includes(e.key))return;n.every((e=>{var n,t;return!e||(null==(n=e[0])?void 0:n.toLowerCase())!==(null==(t=e[1])?void 0:t.toLowerCase())}))&&d.current===e.key&&(d.current="",v.current=g.current),d.current+=e.key,clearTimeout(f.current),f.current=setTimeout((()=>{d.current="",v.current=g.current}),a);const t=v.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,null!=t?t:0)].find((e=>i?i(e,d.current):0===(null==e?void 0:e.toLowerCase().indexOf(d.current)))),o=r?n.indexOf(r):-1;-1!==o&&(l(o),g.current=o)}return c((()=>{r&&(clearTimeout(f.current),v.current=null,g.current=null,d.current="")}),[r]),o?{reference:{onKeyDown:p},floating:{onKeyDown:p}}:{}},Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react"),require("@floating-ui/react-dom"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","@floating-ui/react-dom","react-dom"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.React,e.FloatingUIReactDOM,e.ReactDOM)}(this,(function(e,n,t,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=o(n),c="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;function l(){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 i=0;function a(){return"floating-ui-"+i++}function f(){return n.useMemo(a,[])}const s=n.createContext(null),d=n.createContext(null),v=()=>{var e,t;return null!=(e=null==(t=n.useContext(s))?void 0:t.id)?e:null},g=()=>n.useContext(d);function p(e){return Object.entries(null!=e?e:{}).reduce(((e,n)=>{let[t,r]=n;return e[t]=[r],e}),{})}function m(e,n,t){const r={reference:"reference"===t?p(e):{},floating:"floating"===t?p(e):{}};return n.forEach((e=>{var n;const o=null!=(n=null==e?void 0:e[t])?n:{};Object.keys(o).forEach((e=>{var n;"function"==typeof o[e]&&(null==r[t][e]&&(r[t][e]=[]),null==(n=r[t][e])||n.push(o[e]))}))})),{..."floating"===t&&{tabIndex:-1},...e,...n.reduce(((e,n)=>(Object.assign(e,null==n?void 0:n[t]),e)),{}),...Object.entries(r[t]).reduce(((e,n)=>{let[t,r]=n;return 0===t.indexOf("on")&&(e[t]=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];r.forEach((e=>e(...n)))}),e}),{})}}var h={exports:{}},y=function(e,n,t,r){var o=e[0],u=e[1],c=!1;void 0===t&&(t=0),void 0===r&&(r=n.length);for(var l=(r-t)/2,i=0,a=l-1;i<l;a=i++){var f=n[t+2*i+0],s=n[t+2*i+1],d=n[t+2*a+0],v=n[t+2*a+1];s>u!=v>u&&o<(d-f)*(u-s)/(v-s)+f&&(c=!c)}return c},b=function(e,n,t,r){var o=e[0],u=e[1],c=!1;void 0===t&&(t=0),void 0===r&&(r=n.length);for(var l=r-t,i=0,a=l-1;i<l;a=i++){var f=n[i+t][0],s=n[i+t][1],d=n[a+t][0],v=n[a+t][1];s>u!=v>u&&o<(d-f)*(u-s)/(v-s)+f&&(c=!c)}return c};h.exports=function(e,n,t,r){return n.length>0&&Array.isArray(n[0])?b(e,n,t,r):y(e,n,t,r)},h.exports.nested=b,h.exports.flat=y;var E=h.exports;function w(e){var n;return null!=(n=null==e?void 0:e.ownerDocument)?n:document}function x(e){var n;return null!=(n=w(e).defaultView)?n:window}function k(e){return!!e&&e instanceof x(e).Element}function C(e){return!!e&&e instanceof x(e).HTMLElement}function T(e,n){var t;let r=null!=(t=null==e?void 0:e.nodesRef.current.filter((e=>{var t;return e.parentId===n&&(null==(t=e.context)?void 0:t.open)})))?t:[],o=r;for(;o.length;){var u;o=null!=(u=null==e?void 0:e.nodesRef.current.filter((e=>{var n;return null==(n=o)?void 0:n.some((n=>{var t;return e.parentId===n.id&&(null==(t=e.context)?void 0:t.open)}))})))?u:[],r=r.concat(o)}return r}const R="floating-ui-root",I=n.createContext(R);function O(){return O=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},O.apply(this,arguments)}const D=n.forwardRef((function(e,n){return u.default.createElement("div",O({ref:n},e,{style:{position:"fixed",top:0,right:0,bottom:0,left:0,width:"100%",height:"100%",...e.style}}))}));function A(e,n){return"number"==typeof e?e:null==e?void 0:e[n]}const L=n.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),P=()=>n.useContext(L);function F(e){e.preventDefault(),e.stopPropagation()}function S(e,n){let{startingIndex:t=-1,decrement:r=!1}=void 0===n?{}:n,o=t;do{var u,c;o+=r?-1:1}while(null!=(u=e.current[o])&&u.hasAttribute("disabled")||"true"===(null==(c=e.current[o])?void 0:c.getAttribute("aria-disabled")));return-1===o?0:o}e.FloatingDelayGroup=e=>{let{children:t,delay:r}=e;const[o,c]=n.useState({delay:r,initialDelay:r,currentId:null}),l=n.useCallback((e=>{c((n=>({...n,currentId:e})))}),[]);return u.default.createElement(L.Provider,{value:{...o,setState:c,setCurrentId:l}},t)},e.FloatingNode=e=>{let{children:n,id:t}=e;const r=v();return u.default.createElement(s.Provider,{value:{id:t,parentId:r}},n)},e.FloatingOverlay=D,e.FloatingPortal=e=>{let{children:t,id:o=R}=e;const[l,i]=n.useState(!1),a=n.useRef(null);return c((()=>{const e=document.getElementById(o);e?a.current=e:(a.current=document.createElement("div"),a.current.id=o);const n=a.current;document.body.contains(n)||document.body.appendChild(n),i(!0)}),[]),l&&a.current?u.default.createElement(I.Provider,{value:o},r.createPortal(t,a.current)):null},e.FloatingTree=e=>{let{children:t}=e;const r=n.useRef([]),o=n.useCallback((e=>{r.current=[...r.current,e]}),[]),c=n.useCallback((e=>{r.current=r.current.filter((n=>n!==e))}),[]);return u.default.createElement(d.Provider,{value:{nodesRef:r,addNode:o,removeNode:c,events:l()}},t)},e.safePolygon=function(e){let n,{timeout:t=0,debug:r=null}=void 0===e?{}:e;return e=>{let{x:o,y:u,placement:c,refs:l,onClose:i,nodeId:a,tree:f}=e;return function(e){var s;if("touch"===e.pointerType)return;const{target:d,clientX:v,clientY:g}=e,p=d;if("pointermove"===e.type&&k(l.reference.current)&&l.reference.current.contains(p)||null!=(s=l.floating.current)&&s.contains(p))return;if(f&&T(f,a).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))return;if(!l.reference.current||!l.floating.current||null==c||null==o||null==u)return;const m=l.reference.current.getBoundingClientRect(),h=l.floating.current.getBoundingClientRect(),y=c.split("-")[0],b=o>h.right-h.width/2,w=u>h.bottom-h.height/2;switch(y){case"top":if(v>=h.left&&v<=h.right&&g>=h.bottom&&g<=m.top)return;break;case"bottom":if(v>=h.left&&v<=h.right&&g>=m.bottom&&g<=h.top)return;break;case"left":if(v>=h.right&&v<=m.left&&g>=h.left&&g<=h.right)return;break;case"right":if(v>=h.right&&v<=m.left&&g>=h.right&&g<=m.left)return}function x(e){let[n,t]=e;const r=h.width>m.width,o=h.height>m.height;switch(y){case"top":{const e=[r?n:b?n+1:n-1,t+1],o=[r?n:b?n-1:n+1,t+1],u=[[h.left,b||r?h.bottom-1:h.top],[h.right,b?r?h.bottom-1:h.top:h.bottom-1]];return b?[e,o,...u]:[e,...u,o]}case"bottom":{const e=[r?n:b?n+1:n-1,t-1],o=[r?n:b?n-1:n+1,t-1],u=[[h.left,b||r?h.top+1:h.bottom],[h.right,b?r?h.top+1:h.bottom:h.top+1]];return b?[e,o,...u]:[e,...u,o]}case"left":{const e=[n+1,o?t:w?t-1:t+1],r=[n+1,o?t:w?t+1:t-1],u=[[w||o?h.right-1:h.left,h.top],[w?o?h.right-1:h.left:h.right-1,h.bottom]];return w?[e,...u,r]:[...u,e,r]}case"right":{const e=[n-1,o?t:w?t+1:t-1],r=[n-1,o?t:w?t-1:t+1],u=[[w||o?h.left+1:h.right,h.top],[w?o?h.left+1:h.right:h.left+1,h.bottom]];return w?[e,r,...u]:[e,...u,r]}}}const C=x([o,u]);"production"!==process.env.NODE_ENV&&(null==r||r(x([o,u]).slice(0,4).join(", "))),E([v,g],C)?t&&(n=setTimeout(i,t)):(clearTimeout(n),i())}}},e.useAria=function(e,n){let{open:t}=e,{enabled:r=!0,role:o="dialog",titleId:u,descriptionId:c}=void 0===n?{}:n;const l=f(),i={id:l,role:o};return r?"tooltip"===o?{reference:{"aria-describedby":t?l:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":o,"aria-controls":t?l:void 0,..."listbox"===o&&{role:"combobox"}},floating:{...i,..."dialog"===o&&{"aria-labelledby":u,"aria-describedby":c}}}:{}},e.useClick=function(e,n){let{open:t,onOpenChange:r,dataRef:o}=e,{enabled:u=!0}=void 0===n?{}:n;return u?{reference:{onClick(e){var n;t?"click"===(null==(n=o.current.openEvent)?void 0:n.type)||o.current.hoveredThenClicked?(o.current.hoveredThenClicked=!1,r(!1)):o.current.hoveredThenClicked=!0:(o.current.openEvent=e.nativeEvent,r(!0))}}}:{}},e.useDelayGroup=(e,t)=>{let{open:r,onOpenChange:o}=e,{id:u}=t;const{currentId:c,initialDelay:l,setState:i}=P();n.useEffect((()=>{c&&o&&(i((e=>({...e,delay:{open:0,close:A(l,"close")}}))),c!==u&&o(!1))}),[u,o,i,c,l]),n.useEffect((()=>{!r&&c===u&&o&&(o(!1),i((e=>({...e,delay:l,currentId:null}))))}),[r,i,c,u,o,l])},e.useDelayGroupContext=P,e.useDismiss=function(e,r){let{open:o,onOpenChange:u,refs:c,events:l,nodeId:i}=e,{enabled:a=!0,escapeKey:f=!0,outsidePointerDown:s=!0,referencePointerDown:d=!1,ancestorScroll:v=!1}=void 0===r?{}:r;const p=g(),m=n.useCallback((()=>{C(c.reference.current)&&c.reference.current.focus()}),[c.reference.current]);return n.useEffect((()=>{if(!o||!a)return;function e(e){"Escape"===e.key&&(l.emit("dismiss"),u(!1),m())}function n(e){var n;const t=p&&T(p,i).some((n=>{var t,r;return null==(t=n.context)||null==(r=t.refs.floating.current)?void 0:r.contains(e.target)}));null!=(n=c.floating.current)&&n.contains(e.target)||k(c.reference.current)&&c.reference.current.contains(e.target)||t||(l.emit("dismiss"),u(!1),m())}function r(){u(!1)}const d=w(c.floating.current);f&&d.addEventListener("keydown",e),s&&d.addEventListener("pointerdown",n);const g=v?[...k(c.reference.current)?t.getOverflowAncestors(c.reference.current):[],...k(c.floating.current)?t.getOverflowAncestors(c.floating.current):[]]:[];return g.forEach((e=>e.addEventListener("scroll",r,{passive:!0}))),()=>{f&&d.removeEventListener("keydown",e),s&&d.removeEventListener("pointerdown",n),g.forEach((e=>e.removeEventListener("scroll",r)))}}),[f,s,l,p,i,o,u,m,v,a,c.floating,c.reference]),a?{reference:{onPointerDown(){d&&(l.emit("dismiss"),u(!1))}}}:{}},e.useFloating=function(e){let{open:r=!1,onOpenChange:o=(()=>{}),placement:u,middleware:i,strategy:a,nodeId:f}=void 0===e?{}:e;const s=g(),d=n.useRef({}),v=n.useState((()=>l()))[0],p=t.useFloating({placement:u,middleware:i,strategy:a}),m=n.useMemo((()=>({...p,dataRef:d,nodeId:f,events:v,open:r,onOpenChange:o})),[p,d,f,v,r,o]);return c((()=>{const e=null==s?void 0:s.nodesRef.current.find((e=>e.id===f));e&&(e.context=m)})),n.useMemo((()=>({context:m,...p})),[p,m])},e.useFloatingId=f,e.useFloatingNodeId=()=>{const e=f(),n=g(),t=v();return c((()=>{const r={id:e,parentId:t};return null==n||n.addNode(r),()=>{null==n||n.removeNode(r)}}),[n,e,t]),e},e.useFloatingParentNodeId=v,e.useFloatingTree=g,e.useFocus=function(e,t){let{open:r,onOpenChange:o,dataRef:u,refs:c,events:l}=e,{enabled:i=!0,keyboardOnly:a=!0}=void 0===t?{}:t;const f=n.useRef(!1);return n.useEffect((()=>{var e;if(!i)return;const n=null!=(e=w(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.addEventListener("focus",o),n.removeEventListener("blur",t)}}),[c.floating,r,i]),n.useEffect((()=>{if(i)return l.on("dismiss",e),()=>{l.off("dismiss",e)};function e(){f.current=!0}}),[l,i]),i?{reference:{onPointerDown(e){let{pointerType:n}=e;f.current=!(!n||!a)},onFocus(e){var n,t;f.current||"focus"===e.type&&"mousedown"===u.current.openEvent&&k(c.reference.current)&&null!=(n=c.reference.current)&&n.contains(null==(t=u.current.openEvent)?void 0:t.target)||(u.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var n;const t=e.relatedTarget;null!=(n=c.floating.current)&&n.contains(t)||k(c.reference.current)&&c.reference.current.contains(t)||(f.current=!1,u.current.hoveredThenClicked=!1,o(!1))}}}:{}},e.useFocusTrap=function(e,t){let{open:r,onOpenChange:o,refs:u,nodeId:l}=e,{enabled:i=!0,initialContentFocus:a=0,order:f=["content"],modal:s=!0,inert:d=!1,scrollLock:v=!1}=void 0===t?{}:t;const p=n.useContext(I),m=g(),h=n.useRef(0),y=n.useCallback((()=>f.map((e=>{return C(u.reference.current)&&"reference"===e?u.reference.current:u.floating.current&&"floating"===e?u.floating.current:"content"===e?Array.from(null!=(n=null==(t=u.floating.current)?void 0:t.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable]"))?n:[]):null;var n,t})).filter(Boolean).flat()),[u.floating,u.reference,f]);function b(e){var n;const t=e.relatedTarget;!t||null!=(n=u.floating.current)&&n.contains(t)||!k(u.reference.current)||u.reference.current.contains(t)||o(!1)}return n.useEffect((()=>{if(!d&&i)if(r){const t=y();var e;if("number"==typeof a)null==(e=t[a])||e.focus({preventScroll:!0});else if(a.current){var n;null==(n=t.find((e=>e===a.current)))||n.focus({preventScroll:!0})}}else s&&C(u.reference.current)&&u.reference.current.focus({preventScroll:!0})}),[y,r,d,s,a,i,u.reference]),n.useEffect((()=>{if(!s||!i)return;const e=w(u.floating.current);if(!r)return e.removeEventListener("keydown",n),void(h.current=0);function n(e){var n;if((null==m||null==(n=m.nodesRef.current)||!n.filter((e=>{let{parentId:n}=e;return n===l})).some((e=>{let{context:n}=e;return null==n?void 0:n.open})))&&"Tab"===e.key){var t;if(e.preventDefault(),e.stopPropagation(),d)return;const n=y();e.shiftKey?h.current=0===h.current?n.length-1:h.current-1:h.current=h.current===n.length-1?0:h.current+1,null==(t=n[h.current])||t.focus({preventScroll:!0})}}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}}),[y,null==m?void 0:m.nodesRef,l,r,s,d,i,u.floating]),n.useEffect((()=>{if(!r||!s||!i)return;const e=w(u.floating.current),n=e.querySelector("#"+p),t=e.querySelectorAll("body > *:not(#"+p+")");return t.forEach((e=>{e.setAttribute("aria-hidden","true")})),()=>{(null==n?void 0:n.firstElementChild)===u.floating.current&&t.forEach((e=>{e.removeAttribute("aria-hidden")}))}}),[r,s,v,p,i,u.floating]),c((()=>{if(!r||!i)return;const e=w(u.floating.current);if(v){var n;const t=(null!=(n=e.defaultView)?n:window).innerWidth-e.documentElement.offsetWidth;e.documentElement.style.overflow="hidden",e.body.style.paddingRight=t+"px"}return()=>{v&&(e.documentElement.style.overflow="",e.body.style.paddingRight="")}}),[r,v,i]),i?s?{floating:{"aria-modal":"true"}}:{reference:{onBlur:b},floating:{onBlur:b}}:{}},e.useHover=function(e,t){let{enabled:r=!0,delay:o=0,handleLeave:u=null,mouseOnly:l=!1,pointerRestMs:i=0}=void 0===t?{}:t;const{open:a,onOpenChange:f,dataRef:s,events:d,refs:v}=e,p=g(),m=n.useRef(),h=n.useRef(),y=n.useRef(),b=n.useRef(!0);function E(e){void 0===e&&(e=!0),o?(clearTimeout(m.current),m.current=setTimeout((()=>f(!1)),A(o,"close"))):e&&f(!1)}return c((()=>{a||(s.current.hoveredThenClicked=!1)}),[a]),n.useEffect((()=>{function e(){clearTimeout(m.current),clearTimeout(y.current),b.current=!0}return d.on("dismiss",e),()=>{d.off("dismiss",e)}}),[d]),r?{reference:{onPointerMove(){0===i||a||(clearTimeout(y.current),y.current=setTimeout((()=>{b.current||f(!0)}),i))},onPointerEnter(e){l&&"mouse"!==e.pointerType||(b.current=!1,s.current.openEvent=e.nativeEvent,o?(clearTimeout(m.current),m.current=setTimeout((()=>{f(!0)}),A(o,"open"))):f(!0))},onPointerLeave(n){var t;if(s.current.hoveredThenClicked||"click"===(null==(t=s.current.openEvent)?void 0:t.type))return;const r=w(v.floating.current);if(clearTimeout(y.current),u)return clearTimeout(m.current),h.current&&r.removeEventListener("pointermove",h.current),h.current=u({...e,tree:p,x:n.clientX,y:n.clientY,onClose(){h.current&&r.removeEventListener("pointermove",h.current),E()}}),h.current(n.nativeEvent),void r.addEventListener("pointermove",h.current);E()}},floating:{onPointerEnter(){clearTimeout(m.current)},onPointerLeave:()=>E(!1)}}:{}},e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:n=>m(n,e,"reference"),getFloatingProps:n=>m(n,e,"floating")}},e.useListNavigation=function(e,t){let{open:r,onOpenChange:o,refs:u}=e,{enabled:l=!0,listRef:i={current:[]},activeIndex:a=null,selectedIndex:f=null,loop:s=!1,nested:d=!1,rtl:v=!1,onNavigate:g=(()=>{})}=void 0===t?{}:t;const p=n.useRef(!0),m=n.useRef(null!=f?f:0),h=n.useRef(""),y=n.useCallback(((e,n)=>{var t;null==(t=e.current[n.current])||t.focus({preventScroll:!0})}),[]);function b(e){p.current=!e.pointerType}return c((()=>{l&&(null!=f&&(m.current=f),r&&p.current&&(g(m.current),y(i,m)))}),[r,f,i,g,y,l]),c((()=>{l&&r&&null!=a&&(m.current=a,g(m.current),y(i,m))}),[r,a,i,g,y,l]),c((()=>{null==f&&l&&(r&&("ArrowDown"===h.current||"ArrowUp"===h.current||p.current&&(" "===h.current||"Enter"===h.current))&&(m.current="ArrowUp"===h.current?S(i,{startingIndex:i.current.length,decrement:!0}):S(i),g(m.current),y(i,m)),h.current="")}),[r,i,f,g,y,l]),c((()=>{var e;l&&(r||null==f||null==(e=u.reference.current)||e.focus({preventScroll:!0}))}),[u.reference,f,r,l]),c((()=>{l&&(r||(p.current=!0,g(null)))}),[r,l]),l?{reference:{onPointerEnter:b,onPointerDown:b,onKeyDown(e){p.current=!0,h.current=e.key,k(u.reference.current)&&"BUTTON"!==u.reference.current.tagName&&("Enter"!==e.key&&" "!==e.key||o(!0)),d?e.key===(v?"ArrowLeft":"ArrowRight")&&(m.current=S(i),F(e),o(!0),g(m.current)):"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(m.current=null==f?"ArrowDown"===e.key?S(i):S(i,{startingIndex:i.current.length,decrement:!0}):f,F(e),o(!0),g(m.current))}},floating:{onKeyDown(e){if(d&&e.key===(v?"ArrowRight":"ArrowLeft"))return F(e),o(!1),void(C(u.reference.current)&&u.reference.current.focus());const n=m.current,t=S(i),r=S(i,{decrement:!0,startingIndex:i.current.length});if("Home"===e.key&&(m.current=t,g(m.current),y(i,m)),"End"===e.key&&(m.current=r,g(m.current),y(i,m)),"ArrowDown"===e.key||"ArrowUp"===e.key){if(F(e),e.currentTarget.ownerDocument.activeElement===e.currentTarget&&null!=f)return m.current=f,g(m.current),void y(i,m);"ArrowDown"===e.key?m.current=s?n===r?t:S(i,{startingIndex:n}):Math.min(r,S(i,{startingIndex:n})):m.current=s?n===t?r:S(i,{startingIndex:n,decrement:!0}):Math.max(t,S(i,{startingIndex:n,decrement:!0})),g(m.current),y(i,m)}}}}:{}},e.useTypeahead=function(e,t){let{open:r}=e,{enabled:o=!0,listRef:u={current:[]},onMatch:l=(()=>{}),onFind:i=null,debounceMs:a=500,ignoreKeys:f=[]}=void 0===t?{}:t;const s=n.useRef(),d=n.useRef(""),v=n.useRef(null),g=n.useRef(null);function p(e){if(!e.currentTarget.contains(w(e.currentTarget).activeElement))return;" "===e.key&&d.current.length>0&&(e.preventDefault(),e.stopPropagation());const n=u.current;if(null==n||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...f].includes(e.key))return;n.every((e=>{var n,t;return!e||(null==(n=e[0])?void 0:n.toLowerCase())!==(null==(t=e[1])?void 0:t.toLowerCase())}))&&d.current===e.key&&(d.current="",v.current=g.current),d.current+=e.key,clearTimeout(s.current),s.current=setTimeout((()=>{d.current="",v.current=g.current}),a);const t=v.current,r=[...n.slice((null!=t?t:0)+1),...n.slice(0,null!=t?t:0)].find((e=>i?i(e,d.current):0===(null==e?void 0:e.toLowerCase().indexOf(d.current)))),o=r?n.indexOf(r):-1;-1!==o&&(l(o),g.current=o)}return c((()=>{r&&(clearTimeout(s.current),v.current=null,g.current=null,d.current="")}),[r]),o?{reference:{onKeyDown:p},floating:{onKeyDown:p}}:{}},Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@floating-ui/react-dom-interactions", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"@rollingversions": { | ||
@@ -58,3 +58,2 @@ "baseVersion": [ | ||
"peerDependencies": { | ||
"@floating-ui/react-dom": "*", | ||
"react": ">=16.8.0", | ||
@@ -65,3 +64,4 @@ "react-dom": ">=16.8.0" | ||
"point-in-polygon": "^1.1.0", | ||
"use-isomorphic-layout-effect": "^1.1.1" | ||
"use-isomorphic-layout-effect": "^1.1.1", | ||
"@floating-ui/react-dom": "^0.6.0" | ||
}, | ||
@@ -68,0 +68,0 @@ "devDependencies": { |
@@ -1,2 +0,2 @@ | ||
import { SetStateAction } from 'react'; | ||
import React, { SetStateAction } from 'react'; | ||
import type { FloatingContext } from './types'; | ||
@@ -3,0 +3,0 @@ declare type Delay = number | Partial<{ |
@@ -8,2 +8,2 @@ /// <reference types="react" /> | ||
*/ | ||
export declare const FloatingOverlay: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLProps<HTMLDivElement>, "start" | "name" | "data" | "width" | "height" | "size" | "open" | "className" | "id" | "prefix" | "slot" | "children" | "value" | "cite" | "form" | "label" | "span" | "style" | "summary" | "title" | "pattern" | "key" | "target" | "dir" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "as" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "classID" | "cols" | "colSpan" | "content" | "controls" | "coords" | "crossOrigin" | "dateTime" | "default" | "defer" | "disabled" | "download" | "encType" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "list" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "nonce" | "noValidate" | "optimum" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "sizes" | "src" | "srcDoc" | "srcLang" | "srcSet" | "step" | "type" | "useMap" | "wmode" | "wrap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "lang" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & import("react").RefAttributes<HTMLDivElement>>; | ||
export declare const FloatingOverlay: import("react").ForwardRefExoticComponent<Pick<React.HTMLProps<HTMLDivElement>, string | number | symbol> & import("react").RefAttributes<HTMLDivElement>>; |
@@ -1,2 +0,2 @@ | ||
/// <reference types="react" /> | ||
import React from 'react'; | ||
import type { FloatingTreeType } from './types'; | ||
@@ -3,0 +3,0 @@ export declare const useFloatingParentNodeId: () => string; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195016
4608
+ Added@floating-ui/core@0.6.2(transitive)
+ Added@floating-ui/dom@0.4.5(transitive)
+ Added@floating-ui/react-dom@0.6.3(transitive)
- Removed@floating-ui/core@1.6.8(transitive)
- Removed@floating-ui/dom@1.6.12(transitive)
- Removed@floating-ui/react-dom@2.1.2(transitive)
- Removed@floating-ui/utils@0.2.8(transitive)