Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@floating-ui/react-dom-interactions

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@floating-ui/react-dom-interactions - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

src/createTree.d.ts

61

dist/floating-ui.react-dom-interactions.esm.js
import { useLayoutEffect, useEffect, useState, useRef, useContext, useCallback, createContext, useMemo } from 'react';
import { isElement, contains, getWindow, isHTMLElement, getOverflowAncestors, useFloating as useFloating$1 } from '@floating-ui/react-dom';
import { getOverflowAncestors, useFloating as useFloating$1 } from '@floating-ui/react-dom';
export * from '@floating-ui/react-dom';

@@ -16,3 +16,3 @@ import { createPortal } from 'react-dom';

function getPreservedProps(userProps, propsArr, elementKey) {
function mergeProps(userProps, propsList, elementKey) {
const mergePropsMap = {

@@ -22,3 +22,3 @@ reference: elementKey === 'reference' ? reducePropsToArrayWithInitValue(userProps) : {},

};
propsArr.forEach(props => {
propsList.forEach(props => {
var _props$elementKey;

@@ -43,3 +43,3 @@

...userProps,
...propsArr.reduce((acc, props) => {
...propsList.reduce((acc, props) => {
Object.assign(acc, props == null ? void 0 : props[elementKey]);

@@ -66,8 +66,12 @@ return acc;

function createPropGetters(propsArr) {
const useInteractions = function (propsList) {
if (propsList === void 0) {
propsList = [];
}
return {
getReferenceProps: userProps => getPreservedProps(userProps, propsArr, 'reference'),
getFloatingProps: userProps => getPreservedProps(userProps, propsArr, 'floating')
getReferenceProps: userProps => mergeProps(userProps, propsList, 'reference'),
getFloatingProps: userProps => mergeProps(userProps, propsList, 'floating')
};
}
};

@@ -148,2 +152,21 @@ function createTree(nodes) {

function getDocument(floating) {
var _floating$ownerDocume;
return (_floating$ownerDocume = floating == null ? void 0 : floating.ownerDocument) != null ? _floating$ownerDocume : document;
}
function getWindow(value) {
var _getDocument$defaultV;
return (_getDocument$defaultV = getDocument(value).defaultView) != null ? _getDocument$defaultV : window;
}
function isElement(value) {
return value ? value instanceof getWindow(value).Element : false;
}
function isHTMLElement(value) {
return value ? value instanceof getWindow(value).HTMLElement : false;
}
function safePolygon(_temp) {

@@ -179,3 +202,3 @@ let {

if (event.type === 'pointermove' && isElement(refs.reference.current) && contains(refs.reference.current, targetNode) || (_refs$floating$curren = refs.floating.current) != null && _refs$floating$curren.contains(targetNode)) {
if (event.type === 'pointermove' && isElement(refs.reference.current) && refs.reference.current.contains(targetNode) || (_refs$floating$curren = refs.floating.current) != null && _refs$floating$curren.contains(targetNode)) {
return;

@@ -351,6 +374,2 @@ } // If any child has a menu open, abort

function getDocument(floating) {
return floating != null ? getWindow(floating).document : document;
}
function getDelay(value, prop) {

@@ -707,3 +726,5 @@ if (typeof value === 'number') {

function onPointerDown(event) {
if (contains(refs.floating.current, event.target) || isElement(refs.reference.current) && contains(refs.reference.current, event.target) || isAnyChildNodeOpen()) {
var _refs$floating$curren;
if ((_refs$floating$curren = refs.floating.current) != null && _refs$floating$curren.contains(event.target) || isElement(refs.reference.current) && refs.reference.current.contains(event.target) || isAnyChildNodeOpen()) {
return;

@@ -724,3 +745,3 @@ }

const doc = refs.floating.current != null ? getWindow(refs.floating.current).document : document;
const doc = getDocument(refs.floating.current);
escapeKey && doc.addEventListener('keydown', onKeyDown);

@@ -797,2 +818,4 @@ outsidePointerDown && doc.addEventListener('pointerdown', onPointerDown);

onBlur(event) {
var _refs$floating$curren;
const target = event.relatedTarget; // When focusing the reference element (e.g. regular click), then

@@ -802,3 +825,3 @@ // clicking into the floating element, prevent it from hiding.

if (contains(refs.floating.current, target) || isElement(refs.reference.current) && contains(refs.reference.current, target)) {
if ((_refs$floating$curren = refs.floating.current) != null && _refs$floating$curren.contains(target) || isElement(refs.reference.current) && refs.reference.current.contains(target)) {
return;

@@ -934,5 +957,7 @@ }

function onBlur(event) {
var _refs$floating$curren3;
const target = event.relatedTarget;
if (target && !contains(refs.floating.current, target) && isElement(refs.reference.current) && !contains(refs.reference.current, target)) {
if (target && !((_refs$floating$curren3 = refs.floating.current) != null && _refs$floating$curren3.contains(target)) && isElement(refs.reference.current) && !refs.reference.current.contains(target)) {
onOpenChange == null ? void 0 : onOpenChange(false);

@@ -1301,2 +1326,2 @@ }

export { FloatingGroup, FloatingPortal, createPropGetters, createTree, safePolygon, useAria, useClick, useDismiss, useFloating, useFloatingId, useFocus, useFocusTrap, useGroup, useGroupContext, useHover, useListNavigation, useTypeahead };
export { FloatingGroup, FloatingPortal, createTree, safePolygon, useAria, useClick, useDismiss, useFloating, useFloatingId, useFocus, useFocusTrap, useGroup, useGroupContext, useHover, useInteractions, useListNavigation, useTypeahead };

@@ -1,1 +0,1 @@

import{useLayoutEffect as e,useEffect as r,useState as t,useRef as n,useContext as o,useCallback as c,createContext as u,useMemo as i}from"react";import{isElement as l,contains as a,getWindow as f,isHTMLElement as d,getOverflowAncestors as s,useFloating as g}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import{createPortal as p}from"react-dom";var v="undefined"!=typeof document?e:r;function h(e){return Object.entries(null!=e?e:{}).reduce(((e,r)=>{let[t,n]=r;return e[t]=[n],e}),{})}function m(e,r,t){const n={reference:"reference"===t?h(e):{},floating:"floating"===t?h(e):{}};return r.forEach((e=>{var r;const o=null!=(r=null==e?void 0:e[t])?r:{};Object.keys(o).forEach((e=>{var r;"function"==typeof o[e]&&(null==n[t][e]&&(n[t][e]=[]),null==(r=n[t][e])||r.push(o[e]))}))})),{..."floating"===t&&{tabIndex:-1},...e,...r.reduce(((e,r)=>(Object.assign(e,null==r?void 0:r[t]),e)),{}),...Object.entries(n[t]).reduce(((e,r)=>{let[t,n]=r;return 0===t.indexOf("on")&&(e[t]=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];n.forEach((e=>e(...r)))}),e}),{})}}function y(e){return{getReferenceProps:r=>m(r,e,"reference"),getFloatingProps:r=>m(r,e,"floating")}}function w(e){const r=new Map;return{nodes:e,emit(e,t){var n;null==(n=r.get(e))||n.forEach((e=>e(t)))},on(e,t){r.set(e,[...r.get(e)||[],t])},off(e,t){r.set(e,(r.get(e)||[]).filter((e=>e!==t)))}}}var b={exports:{}},E=function(e,r,t,n){var o=e[0],c=e[1],u=!1;void 0===t&&(t=0),void 0===n&&(n=r.length);for(var i=(n-t)/2,l=0,a=i-1;l<i;a=l++){var f=r[t+2*l+0],d=r[t+2*l+1],s=r[t+2*a+0],g=r[t+2*a+1];d>c!=g>c&&o<(s-f)*(c-d)/(g-d)+f&&(u=!u)}return u},k=function(e,r,t,n){var o=e[0],c=e[1],u=!1;void 0===t&&(t=0),void 0===n&&(n=r.length);for(var i=n-t,l=0,a=i-1;l<i;a=l++){var f=r[l+t][0],d=r[l+t][1],s=r[a+t][0],g=r[a+t][1];d>c!=g>c&&o<(s-f)*(c-d)/(g-d)+f&&(u=!u)}return u};b.exports=function(e,r,t,n){return r.length>0&&Array.isArray(r[0])?k(e,r,t,n):E(e,r,t,n)},b.exports.nested=k,b.exports.flat=E;var x=b.exports;function T(e){let r,{timeout:t=0,debug:n=null}=void 0===e?{}:e;return e=>{let{x:n,y:o,placement:c,refs:u,onClose:i,treeRef:f,nodeRef:d}=e;return function(e){var s;if("touch"===e.pointerType)return;const{target:g,clientX:p,clientY:v}=e,h=g;if("pointermove"===e.type&&l(u.reference.current)&&a(u.reference.current,h)||null!=(s=u.floating.current)&&s.contains(h))return;if(null!=f&&f.current.nodes.filter((e=>{let{current:r}=e;return r.parentId===(null==d?void 0:d.current.id)})).some((e=>{let{current:r}=e;return r.open})))return;if(!u.reference.current||!u.floating.current||null==c||null==n||null==o)return;const m=u.reference.current.getBoundingClientRect(),y=u.floating.current.getBoundingClientRect(),w=c.split("-")[0],b=n>y.right-y.width/2,E=o>y.bottom-y.height/2;switch(w){case"top":if(p>=y.left&&p<=y.right&&v>=y.bottom&&v<=m.top)return;break;case"bottom":if(p>=y.left&&p<=y.right&&v>=m.bottom&&v<=y.top)return;break;case"left":if(p>=y.right&&p<=m.left&&v>=y.left&&v<=y.right)return;break;case"right":if(p>=y.right&&p<=m.left&&v>=y.right&&v<=m.left)return}const k=function(e){let[r,t]=e;switch(w){case"top":{const e=[r-(b?-1:1),t+1],n=[r-(b?-1:1),t-1],o=[[y.left,b||y.width>m.width?y.bottom:y.top],[y.right,b?y.width>m.width?y.bottom:y.top:y.bottom]];return y.width<m.width?b?[e,...o,n]:[e,n,...o]:[e,...o]}case"bottom":{const e=[r-(b?-1:1),t-1],n=[r-(b?-1:1),t+1],o=[[y.left,b||y.width>m.width?y.top:y.bottom],[y.right,b?y.width>m.width?y.top:y.bottom:y.top]];return y.width<m.width?b?[e,...o,n]:[e,n,...o]:[e,...o]}case"left":{const e=[r+1,t-(E?-1:1)],n=[r-1,t-(E?-1:1)],o=[[E||y.height>m.height?y.right-1:y.left,y.top],[E?y.height>m.height?y.right-1:y.left:y.right-1,y.bottom]];return y.height<m.height?E?[e,...o,n]:[e,n,...o]:[e,...o]}case"right":{const e=[r-1,t-(E?-1:1)],n=[r+1,t-(E?-1:1)],o=[[E||y.height>m.height?y.left+1:y.right,y.top],[E?y.height>m.height?y.left+1:y.right:y.left+1,y.bottom]];return y.height<m.height?E?[e,...o,n]:[e,n,...o]:[e,...o]}}}([n,o]);x([p,v],k)?t&&(r=setTimeout(i,t)):(clearTimeout(r),i())}}}function A(e){let{children:r}=e;const[o,c]=t(!1),u=n(null);return v((()=>{const e=document.getElementById("floating-ui-root");e?u.current=e:(u.current=document.createElement("div"),u.current.id="floating-ui-root");const r=u.current;return document.body.contains(r)||document.body.appendChild(r),c(!0),()=>{document.body.contains(r)&&document.body.removeChild(r)}}),[]),o&&u.current?p(r,u.current):null}function R(e){return null!=e?f(e).document:document}function C(e,r){return"number"==typeof e?e:e[r]}const I=function(e,r){let{delay:t=0,handleLeave:o=null,mouseOnly:c=!1,pointerRestMs:u=0}=void 0===r?{}:r;const{onOpenChange:i=(()=>{}),open:l,dataRef:a,refs:f}=e,d=n(null),s=n(!1),g=n(),p=n();v((()=>{if(!o)return;if(!l)return void(s.current=!1);function e(){var e;"pointerover"===(null==(e=d.current)?void 0:e.type)&&i(!1)}const r=R(f.floating.current).documentElement;return r.addEventListener("pointerleave",e),()=>{r.removeEventListener("pointerleave",e)}}),[l,i,o]);const h=n();return{reference:{onPointerMove(){0===u||l||(clearTimeout(h.current),h.current=setTimeout((()=>{a.current.dismiss||i(!0)}),u))},onPointerEnter(e){c&&"mouse"!==e.pointerType||(d.current=e.nativeEvent,t?(clearTimeout(g.current),g.current=setTimeout((()=>{a.current.dismiss||i(!0)}),C(t,"open"))):i(!0))},onPointerLeave(r){var n;if(s.current||"click"===(null==(n=d.current)?void 0:n.type))return;const c=R(f.floating.current);if(o)return clearTimeout(g.current),p.current&&c.removeEventListener("pointermove",p.current),p.current=o({...e,x:r.clientX,y:r.clientY,onClose(){p.current&&c.removeEventListener("pointermove",p.current),i(!1)}}),void c.addEventListener("pointermove",p.current);a.current.dismiss=!1,t?(clearTimeout(h.current),clearTimeout(g.current),g.current=setTimeout((()=>i(!1)),C(t,"close"))):(s.current=!1,i(!1))}}}},D=u({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),L=()=>{const e=o(D);if(!e)throw new Error("useGroupContext() must be used within a <FloatingGroup />");return e},O=e=>{let{children:r,delay:n}=e;const[o,u]=t({delay:n,initialDelay:n,currentId:null}),i=c((e=>{u((r=>({...r,currentId:e})))}),[]);return React.createElement(D.Provider,{value:{...o,setState:u,setCurrentId:i}},r)},P=(e,t)=>{let{open:n,onOpenChange:o}=e,{id:c}=t;const{currentId:u,initialDelay:i,setState:l}=L();r((()=>{u&&o&&(l((e=>({...e,delay:{open:0,close:C(i,"close")}}))),u!==c&&o(!1))}),[c,o,l,u,i]),r((()=>{!n&&u===c&&o&&(o(!1),l((e=>({...e,delay:i,currentId:null}))))}),[n,l,u,c,o,i])};let S=0;function B(){return"floating-ui-"+S++}function K(){return i(B,[])}const M=function(e,r){let{open:t}=e,{role:n="dialog",titleId:o,descriptionId:c}=void 0===r?{}:r;const u=K(),i={id:u,role:n};return"tooltip"===n?{reference:{"aria-describedby":t?u:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":n,"aria-controls":t?u:void 0,..."listbox"===n&&{role:"combobox"}},floating:{...i,..."dialog"===n&&{"aria-labelledby":o,"aria-describedby":c}}}},U=e=>{let{open:r,onOpenChange:t=(()=>{}),dataRef:n}=e;return{reference:{onClick(e){var o;r?"click"===(null==(o=n.current.openEvent)?void 0:o.type)||n.current.hoveredThenClicked?(n.current.hoveredThenClicked=!1,t(!1)):n.current.hoveredThenClicked=!0:(n.current.openEvent=e.nativeEvent,t(!0))}}}},j=function(e,t){let{onOpenChange:n=(()=>{}),refs:o,open:u,treeRef:i,nodeRef:g,dataRef:p}=e,{escapeKey:v=!0,outsidePointerDown:h=!0,referencePointerDown:m=!1,ancestorScroll:y=!1}=void 0===t?{}:t;const w=c((()=>{d(o.reference.current)&&o.reference.current.focus()}),[o.reference.current]);return r((()=>{function e(){n(!1),w()}const r=null==i?void 0:i.current;return null==r||r.on("close",e),()=>{null==r||r.off("close",e)}}),[i,n,w]),r((()=>{if(!u)return;function e(){return null==i?void 0:i.current.nodes.filter((e=>{let{current:r}=e;return r.parentId===(null==g?void 0:g.current.id)})).some((e=>{let{current:r}=e;return r.open}))}function r(r){"Escape"!==r.key||e()||(p.current.dismiss=!0,i?i.current.emit("close"):(n(!1),w()))}function t(r){a(o.floating.current,r.target)||l(o.reference.current)&&a(o.reference.current,r.target)||e()||(i?i.current.emit("close"):(n(!1),w()))}function c(){n(!1)}const d=null!=o.floating.current?f(o.floating.current).document:document;v&&d.addEventListener("keydown",r),h&&d.addEventListener("pointerdown",t);const m=y?[...l(o.reference.current)?s(o.reference.current):[],...l(o.floating.current)?s(o.floating.current):[]]:[];return m.forEach((e=>e.addEventListener("scroll",c,{passive:!0}))),()=>{v&&d.removeEventListener("keydown",r),h&&d.removeEventListener("pointerdown",t),m.forEach((e=>e.removeEventListener("scroll",c)))}}),[v,h,i,g,u,n,p,w,y,o.floating,o.reference]),{reference:{onPointerDown(){m&&(p.current.dismiss=!0,n(!1))}}}},F=function(e,r){let{open:t,onOpenChange:o=(()=>{}),dataRef:c,refs:u}=e,{keyboardOnly:i=!0}=void 0===r?{}:r;const f=n();return v((()=>{t||(f.current=void 0)})),{reference:{onPointerDown(e){let{pointerType:r}=e;f.current=r},onFocus(e){var r,t;i&&f.current||"focus"===e.type&&"mousedown"===c.current.openEvent&&l(u.reference.current)&&null!=(r=u.reference.current)&&r.contains(null==(t=c.current.openEvent)?void 0:t.target)||c.current.dismiss||(c.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){const r=e.relatedTarget;a(u.floating.current,r)||l(u.reference.current)&&a(u.reference.current,r)||(c.current.dismiss=!1,c.current.hoveredThenClicked=!1,o(!1))}}}},N=function(e,t){let{open:o,refs:u,treeRef:i,nodeRef:f,onOpenChange:s}=e,{initialContentFocus:g=0,order:p=["content"],modal:h=!0,inert:m=!1,scrollLock:y="auto"}=void 0===t?{}:t;const w=n(0),b=c((()=>p.map((e=>{return d(u.reference.current)&&"reference"===e?u.reference.current:u.floating.current&&"floating"===e?u.floating.current:"content"===e?Array.from(null!=(r=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]"))?r:[]):null;var r,t})).filter(Boolean).flat()),[u.floating,u.reference,p]);function E(e){const r=e.relatedTarget;r&&!a(u.floating.current,r)&&l(u.reference.current)&&!a(u.reference.current,r)&&(null==s||s(!1))}return r((()=>{if(!m)if(o){const t=b();var e;if("number"==typeof g)null==(e=t[g])||e.focus({preventScroll:!0});else if(g.current){var r;null==(r=t.find((e=>e===g.current)))||r.focus({preventScroll:!0})}}else h&&d(u.reference.current)&&u.reference.current.focus()}),[b,o,m,h,g,u.reference]),r((()=>{if(!h)return;if(!o)return void(w.current=0);function e(e){if((null==i||!i.current.nodes.filter((e=>{let{current:r}=e;return r.parentId===(null==f?void 0:f.current.id)})).some((e=>{let{current:r}=e;return r.open})))&&"Tab"===e.key){var r;if(e.preventDefault(),e.stopPropagation(),m)return;const t=b();e.shiftKey?w.current=0===w.current?t.length-1:w.current-1:w.current=w.current===t.length-1?0:w.current+1,null==(r=t[w.current])||r.focus({preventScroll:!0})}}const r=R(u.floating.current);return r.addEventListener("keydown",e),()=>{r.removeEventListener("keydown",e)}}),[b,f,o,h,i,m,u.floating]),r((()=>{if(!o||!h)return;const e=R(u.floating.current).querySelectorAll("body > *:not(#floating-ui-root)");return e.forEach((e=>{e.setAttribute("aria-hidden","true")})),()=>{e.forEach((e=>{e.removeAttribute("aria-hidden")}))}}),[o,h,y,u.floating]),v((()=>{if(!o)return;const e=!0===y||"auto"===y&&h,r=R(u.floating.current);if(e){var t;const e=(null!=(t=r.defaultView)?t:window).innerWidth-r.documentElement.offsetWidth;r.documentElement.style.overflow="hidden",r.body.style.paddingRight=e+"px"}return()=>{e&&(r.documentElement.style.overflow="",r.body.style.paddingRight="")}}),[o,y]),h?{floating:{"aria-modal":"true"}}:{reference:{onBlur:E},floating:{onBlur:E}}};function q(e){e.preventDefault(),e.stopPropagation()}function G(e,r){let{startingIndex:t=-1,decrement:n=!1}=void 0===r?{}:r,o=t;do{var c,u;o+=n?-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 H=(e,r)=>{let{open:t,onOpenChange:o=(()=>{}),refs:u}=e,{listRef:i,activeIndex:l=null,selectedIndex:a=null,loop:f=!1,nested:s=!1,rtl:g=!1,preventScroll:p=!0,onNavigate:h=(()=>{})}=r;const m=n(!0),y=n(null!=a?a:0),w=n(""),b=c(((e,r)=>{var t;null==(t=e.current[r.current])||t.focus({preventScroll:p})}),[p]);return v((()=>{null!=a&&(y.current=a),t&&m.current&&(h(y.current),b(i,y))}),[t,a,i,h,b]),v((()=>{t&&null!=l&&(y.current=l,h(y.current),b(i,y))}),[t,l,i,h,b]),v((()=>{null==a&&(t&&("ArrowDown"===w.current||"ArrowUp"===w.current||m.current&&(" "===w.current||"Enter"===w.current))&&(y.current="ArrowUp"===w.current?G(i,{startingIndex:i.current.length,decrement:!0}):G(i),h(y.current),b(i,y)),w.current="")}),[t,i,a,h,b]),v((()=>{var e;t||null==a||(null==(e=u.reference.current)||e.focus({preventScroll:p}))}),[u.reference,p,a,t]),v((()=>{t||(m.current=!0)}),[t]),{reference:{onPointerDown(e){m.current=!e.pointerType},onKeyDown(e){w.current=e.key,u.reference.current instanceof Element&&"BUTTON"!==u.reference.current.tagName&&("Enter"!==e.key&&" "!==e.key||o(!0)),s?e.key===(g?"ArrowLeft":"ArrowRight")&&(y.current=G(i),q(e),o(!0),h(y.current),b(i,y)):"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(y.current=null==a?"ArrowDown"===e.key?G(i):G(i,{startingIndex:i.current.length,decrement:!0}):a,q(e),o(!0),h(y.current),b(i,y))}},floating:{onKeyDown(e){if(s&&e.key===(g?"ArrowRight":"ArrowLeft"))return q(e),o(!1),void(d(u.reference.current)&&u.reference.current.focus());const r=y.current,t=G(i),n=G(i,{decrement:!0,startingIndex:i.current.length});if("Home"===e.key&&(y.current=t,h(y.current),b(i,y)),"End"===e.key&&(y.current=n,h(y.current),b(i,y)),"ArrowDown"===e.key||"ArrowUp"===e.key){if(q(e),e.currentTarget.ownerDocument.activeElement===e.currentTarget&&null!=a)return y.current=a,h(y.current),void b(i,y);"ArrowDown"===e.key?y.current=f?r===n?t:G(i,{startingIndex:r}):Math.min(n,G(i,{startingIndex:r})):y.current=f?r===t?n:G(i,{startingIndex:r,decrement:!0}):Math.max(t,G(i,{startingIndex:r,decrement:!0})),h(y.current),b(i,y)}}}}},W=(e,r)=>{let{listRef:t,onMatch:o,debounceMs:c=500,ignoreKeys:u=[]}=r;const i=n(),l=n(""),a=n(null),f=n(null);function d(e){" "===e.key&&l.current.length>0&&(e.preventDefault(),e.stopPropagation());const r=t.current;if(null==r||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...u].includes(e.key))return;l.current+=e.key,clearTimeout(i.current),i.current=setTimeout((()=>{l.current="",a.current=f.current}),c);const n=a.current,d=[...r.slice((null!=n?n:-1)+1),...r.slice(0,null!=n?n:0)].find((e=>0===(null==e?void 0:e.toLowerCase().indexOf(l.current)))),s=d?r.indexOf(d):-1;-1!==s&&(o(s),f.current=s)}return{reference:{onKeyDown:d},floating:{onKeyDown:d}}};function X(e){let{open:r=!1,onOpenChange:t,placement:o,middleware:c,strategy:u,treeRef:l,nodeRef:a}=void 0===e?{}:e;v((()=>{a&&(a.current.open=r)}));const f=n({}),d=g({placement:o,middleware:c,strategy:u}),s=i((()=>({...d,treeRef:l,nodeRef:a,open:r,onOpenChange:t,dataRef:f})),[d,a,l,r,t]);return i((()=>({context:s,...d})),[d,s])}export{O as FloatingGroup,A as FloatingPortal,y as createPropGetters,w as createTree,T as safePolygon,M as useAria,U as useClick,j as useDismiss,X as useFloating,K as useFloatingId,F as useFocus,N as useFocusTrap,P as useGroup,L as useGroupContext,I as useHover,H as useListNavigation,W as useTypeahead};
import{useLayoutEffect as e,useEffect as r,useState as n,useRef as t,useContext as o,useCallback as c,createContext as u,useMemo as i}from"react";import{getOverflowAncestors as l,useFloating as a}from"@floating-ui/react-dom";export*from"@floating-ui/react-dom";import{createPortal as f}from"react-dom";var d="undefined"!=typeof document?e:r;function s(e){return Object.entries(null!=e?e:{}).reduce(((e,r)=>{let[n,t]=r;return e[n]=[t],e}),{})}function g(e,r,n){const t={reference:"reference"===n?s(e):{},floating:"floating"===n?s(e):{}};return r.forEach((e=>{var r;const o=null!=(r=null==e?void 0:e[n])?r:{};Object.keys(o).forEach((e=>{var r;"function"==typeof o[e]&&(null==t[n][e]&&(t[n][e]=[]),null==(r=t[n][e])||r.push(o[e]))}))})),{..."floating"===n&&{tabIndex:-1},...e,...r.reduce(((e,r)=>(Object.assign(e,null==r?void 0:r[n]),e)),{}),...Object.entries(t[n]).reduce(((e,r)=>{let[n,t]=r;return 0===n.indexOf("on")&&(e[n]=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];t.forEach((e=>e(...r)))}),e}),{})}}const v=function(e){return void 0===e&&(e=[]),{getReferenceProps:r=>g(r,e,"reference"),getFloatingProps:r=>g(r,e,"floating")}};function p(e){const r=new Map;return{nodes:e,emit(e,n){var t;null==(t=r.get(e))||t.forEach((e=>e(n)))},on(e,n){r.set(e,[...r.get(e)||[],n])},off(e,n){r.set(e,(r.get(e)||[]).filter((e=>e!==n)))}}}var h={exports:{}},m=function(e,r,n,t){var o=e[0],c=e[1],u=!1;void 0===n&&(n=0),void 0===t&&(t=r.length);for(var i=(t-n)/2,l=0,a=i-1;l<i;a=l++){var f=r[n+2*l+0],d=r[n+2*l+1],s=r[n+2*a+0],g=r[n+2*a+1];d>c!=g>c&&o<(s-f)*(c-d)/(g-d)+f&&(u=!u)}return u},y=function(e,r,n,t){var o=e[0],c=e[1],u=!1;void 0===n&&(n=0),void 0===t&&(t=r.length);for(var i=t-n,l=0,a=i-1;l<i;a=l++){var f=r[l+n][0],d=r[l+n][1],s=r[a+n][0],g=r[a+n][1];d>c!=g>c&&o<(s-f)*(c-d)/(g-d)+f&&(u=!u)}return u};h.exports=function(e,r,n,t){return r.length>0&&Array.isArray(r[0])?y(e,r,n,t):m(e,r,n,t)},h.exports.nested=y,h.exports.flat=m;var w=h.exports;function b(e){var r;return null!=(r=null==e?void 0:e.ownerDocument)?r:document}function E(e){var r;return null!=(r=b(e).defaultView)?r:window}function k(e){return!!e&&e instanceof E(e).Element}function x(e){return!!e&&e instanceof E(e).HTMLElement}function T(e){let r,{timeout:n=0,debug:t=null}=void 0===e?{}:e;return e=>{let{x:t,y:o,placement:c,refs:u,onClose:i,treeRef:l,nodeRef:a}=e;return function(e){var f;if("touch"===e.pointerType)return;const{target:d,clientX:s,clientY:g}=e,v=d;if("pointermove"===e.type&&k(u.reference.current)&&u.reference.current.contains(v)||null!=(f=u.floating.current)&&f.contains(v))return;if(null!=l&&l.current.nodes.filter((e=>{let{current:r}=e;return r.parentId===(null==a?void 0:a.current.id)})).some((e=>{let{current:r}=e;return r.open})))return;if(!u.reference.current||!u.floating.current||null==c||null==t||null==o)return;const p=u.reference.current.getBoundingClientRect(),h=u.floating.current.getBoundingClientRect(),m=c.split("-")[0],y=t>h.right-h.width/2,b=o>h.bottom-h.height/2;switch(m){case"top":if(s>=h.left&&s<=h.right&&g>=h.bottom&&g<=p.top)return;break;case"bottom":if(s>=h.left&&s<=h.right&&g>=p.bottom&&g<=h.top)return;break;case"left":if(s>=h.right&&s<=p.left&&g>=h.left&&g<=h.right)return;break;case"right":if(s>=h.right&&s<=p.left&&g>=h.right&&g<=p.left)return}const E=function(e){let[r,n]=e;switch(m){case"top":{const e=[r-(y?-1:1),n+1],t=[r-(y?-1:1),n-1],o=[[h.left,y||h.width>p.width?h.bottom:h.top],[h.right,y?h.width>p.width?h.bottom:h.top:h.bottom]];return h.width<p.width?y?[e,...o,t]:[e,t,...o]:[e,...o]}case"bottom":{const e=[r-(y?-1:1),n-1],t=[r-(y?-1:1),n+1],o=[[h.left,y||h.width>p.width?h.top:h.bottom],[h.right,y?h.width>p.width?h.top:h.bottom:h.top]];return h.width<p.width?y?[e,...o,t]:[e,t,...o]:[e,...o]}case"left":{const e=[r+1,n-(b?-1:1)],t=[r-1,n-(b?-1:1)],o=[[b||h.height>p.height?h.right-1:h.left,h.top],[b?h.height>p.height?h.right-1:h.left:h.right-1,h.bottom]];return h.height<p.height?b?[e,...o,t]:[e,t,...o]:[e,...o]}case"right":{const e=[r-1,n-(b?-1:1)],t=[r+1,n-(b?-1:1)],o=[[b||h.height>p.height?h.left+1:h.right,h.top],[b?h.height>p.height?h.left+1:h.right:h.left+1,h.bottom]];return h.height<p.height?b?[e,...o,t]:[e,t,...o]:[e,...o]}}}([t,o]);w([s,g],E)?n&&(r=setTimeout(i,n)):(clearTimeout(r),i())}}}function A(e){let{children:r}=e;const[o,c]=n(!1),u=t(null);return d((()=>{const e=document.getElementById("floating-ui-root");e?u.current=e:(u.current=document.createElement("div"),u.current.id="floating-ui-root");const r=u.current;return document.body.contains(r)||document.body.appendChild(r),c(!0),()=>{document.body.contains(r)&&document.body.removeChild(r)}}),[]),o&&u.current?f(r,u.current):null}function R(e,r){return"number"==typeof e?e:e[r]}const C=function(e,r){let{delay:n=0,handleLeave:o=null,mouseOnly:c=!1,pointerRestMs:u=0}=void 0===r?{}:r;const{onOpenChange:i=(()=>{}),open:l,dataRef:a,refs:f}=e,s=t(null),g=t(!1),v=t(),p=t();d((()=>{if(!o)return;if(!l)return void(g.current=!1);function e(){var e;"pointerover"===(null==(e=s.current)?void 0:e.type)&&i(!1)}const r=b(f.floating.current).documentElement;return r.addEventListener("pointerleave",e),()=>{r.removeEventListener("pointerleave",e)}}),[l,i,o]);const h=t();return{reference:{onPointerMove(){0===u||l||(clearTimeout(h.current),h.current=setTimeout((()=>{a.current.dismiss||i(!0)}),u))},onPointerEnter(e){c&&"mouse"!==e.pointerType||(s.current=e.nativeEvent,n?(clearTimeout(v.current),v.current=setTimeout((()=>{a.current.dismiss||i(!0)}),R(n,"open"))):i(!0))},onPointerLeave(r){var t;if(g.current||"click"===(null==(t=s.current)?void 0:t.type))return;const c=b(f.floating.current);if(o)return clearTimeout(v.current),p.current&&c.removeEventListener("pointermove",p.current),p.current=o({...e,x:r.clientX,y:r.clientY,onClose(){p.current&&c.removeEventListener("pointermove",p.current),i(!1)}}),void c.addEventListener("pointermove",p.current);a.current.dismiss=!1,n?(clearTimeout(h.current),clearTimeout(v.current),v.current=setTimeout((()=>i(!1)),R(n,"close"))):(g.current=!1,i(!1))}}}},I=u({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),D=()=>{const e=o(I);if(!e)throw new Error("useGroupContext() must be used within a <FloatingGroup />");return e},L=e=>{let{children:r,delay:t}=e;const[o,u]=n({delay:t,initialDelay:t,currentId:null}),i=c((e=>{u((r=>({...r,currentId:e})))}),[]);return React.createElement(I.Provider,{value:{...o,setState:u,setCurrentId:i}},r)},O=(e,n)=>{let{open:t,onOpenChange:o}=e,{id:c}=n;const{currentId:u,initialDelay:i,setState:l}=D();r((()=>{u&&o&&(l((e=>({...e,delay:{open:0,close:R(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])};let P=0;function S(){return"floating-ui-"+P++}function B(){return i(S,[])}const M=function(e,r){let{open:n}=e,{role:t="dialog",titleId:o,descriptionId:c}=void 0===r?{}:r;const u=B(),i={id:u,role:t};return"tooltip"===t?{reference:{"aria-describedby":n?u:void 0},floating:i}:{reference:{"aria-expanded":n?"true":"false","aria-haspopup":t,"aria-controls":n?u:void 0,..."listbox"===t&&{role:"combobox"}},floating:{...i,..."dialog"===t&&{"aria-labelledby":o,"aria-describedby":c}}}},K=e=>{let{open:r,onOpenChange:n=(()=>{}),dataRef:t}=e;return{reference:{onClick(e){var o;r?"click"===(null==(o=t.current.openEvent)?void 0:o.type)||t.current.hoveredThenClicked?(t.current.hoveredThenClicked=!1,n(!1)):t.current.hoveredThenClicked=!0:(t.current.openEvent=e.nativeEvent,n(!0))}}}},U=function(e,n){let{onOpenChange:t=(()=>{}),refs:o,open:u,treeRef:i,nodeRef:a,dataRef:f}=e,{escapeKey:d=!0,outsidePointerDown:s=!0,referencePointerDown:g=!1,ancestorScroll:v=!1}=void 0===n?{}:n;const p=c((()=>{x(o.reference.current)&&o.reference.current.focus()}),[o.reference.current]);return r((()=>{function e(){t(!1),p()}const r=null==i?void 0:i.current;return null==r||r.on("close",e),()=>{null==r||r.off("close",e)}}),[i,t,p]),r((()=>{if(!u)return;function e(){return null==i?void 0:i.current.nodes.filter((e=>{let{current:r}=e;return r.parentId===(null==a?void 0:a.current.id)})).some((e=>{let{current:r}=e;return r.open}))}function r(r){"Escape"!==r.key||e()||(f.current.dismiss=!0,i?i.current.emit("close"):(t(!1),p()))}function n(r){var n;null!=(n=o.floating.current)&&n.contains(r.target)||k(o.reference.current)&&o.reference.current.contains(r.target)||e()||(i?i.current.emit("close"):(t(!1),p()))}function c(){t(!1)}const g=b(o.floating.current);d&&g.addEventListener("keydown",r),s&&g.addEventListener("pointerdown",n);const h=v?[...k(o.reference.current)?l(o.reference.current):[],...k(o.floating.current)?l(o.floating.current):[]]:[];return h.forEach((e=>e.addEventListener("scroll",c,{passive:!0}))),()=>{d&&g.removeEventListener("keydown",r),s&&g.removeEventListener("pointerdown",n),h.forEach((e=>e.removeEventListener("scroll",c)))}}),[d,s,i,a,u,t,f,p,v,o.floating,o.reference]),{reference:{onPointerDown(){g&&(f.current.dismiss=!0,t(!1))}}}},j=function(e,r){let{open:n,onOpenChange:o=(()=>{}),dataRef:c,refs:u}=e,{keyboardOnly:i=!0}=void 0===r?{}:r;const l=t();return d((()=>{n||(l.current=void 0)})),{reference:{onPointerDown(e){let{pointerType:r}=e;l.current=r},onFocus(e){var r,n;i&&l.current||"focus"===e.type&&"mousedown"===c.current.openEvent&&k(u.reference.current)&&null!=(r=u.reference.current)&&r.contains(null==(n=c.current.openEvent)?void 0:n.target)||c.current.dismiss||(c.current.openEvent=e.nativeEvent,o(!0))},onBlur(e){var r;const n=e.relatedTarget;null!=(r=u.floating.current)&&r.contains(n)||k(u.reference.current)&&u.reference.current.contains(n)||(c.current.dismiss=!1,c.current.hoveredThenClicked=!1,o(!1))}}}},F=function(e,n){let{open:o,refs:u,treeRef:i,nodeRef:l,onOpenChange:a}=e,{initialContentFocus:f=0,order:s=["content"],modal:g=!0,inert:v=!1,scrollLock:p="auto"}=void 0===n?{}:n;const h=t(0),m=c((()=>s.map((e=>{return x(u.reference.current)&&"reference"===e?u.reference.current:u.floating.current&&"floating"===e?u.floating.current:"content"===e?Array.from(null!=(r=null==(n=u.floating.current)?void 0:n.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable]"))?r:[]):null;var r,n})).filter(Boolean).flat()),[u.floating,u.reference,s]);function y(e){var r;const n=e.relatedTarget;!n||null!=(r=u.floating.current)&&r.contains(n)||!k(u.reference.current)||u.reference.current.contains(n)||null==a||a(!1)}return r((()=>{if(!v)if(o){const n=m();var e;if("number"==typeof f)null==(e=n[f])||e.focus({preventScroll:!0});else if(f.current){var r;null==(r=n.find((e=>e===f.current)))||r.focus({preventScroll:!0})}}else g&&x(u.reference.current)&&u.reference.current.focus()}),[m,o,v,g,f,u.reference]),r((()=>{if(!g)return;if(!o)return void(h.current=0);function e(e){if((null==i||!i.current.nodes.filter((e=>{let{current:r}=e;return r.parentId===(null==l?void 0:l.current.id)})).some((e=>{let{current:r}=e;return r.open})))&&"Tab"===e.key){var r;if(e.preventDefault(),e.stopPropagation(),v)return;const n=m();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==(r=n[h.current])||r.focus({preventScroll:!0})}}const r=b(u.floating.current);return r.addEventListener("keydown",e),()=>{r.removeEventListener("keydown",e)}}),[m,l,o,g,i,v,u.floating]),r((()=>{if(!o||!g)return;const e=b(u.floating.current).querySelectorAll("body > *:not(#floating-ui-root)");return e.forEach((e=>{e.setAttribute("aria-hidden","true")})),()=>{e.forEach((e=>{e.removeAttribute("aria-hidden")}))}}),[o,g,p,u.floating]),d((()=>{if(!o)return;const e=!0===p||"auto"===p&&g,r=b(u.floating.current);if(e){var n;const e=(null!=(n=r.defaultView)?n:window).innerWidth-r.documentElement.offsetWidth;r.documentElement.style.overflow="hidden",r.body.style.paddingRight=e+"px"}return()=>{e&&(r.documentElement.style.overflow="",r.body.style.paddingRight="")}}),[o,p]),g?{floating:{"aria-modal":"true"}}:{reference:{onBlur:y},floating:{onBlur:y}}};function H(e){e.preventDefault(),e.stopPropagation()}function N(e,r){let{startingIndex:n=-1,decrement:t=!1}=void 0===r?{}:r,o=n;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 q=(e,r)=>{let{open:n,onOpenChange:o=(()=>{}),refs:u}=e,{listRef:i,activeIndex:l=null,selectedIndex:a=null,loop:f=!1,nested:s=!1,rtl:g=!1,preventScroll:v=!0,onNavigate:p=(()=>{})}=r;const h=t(!0),m=t(null!=a?a:0),y=t(""),w=c(((e,r)=>{var n;null==(n=e.current[r.current])||n.focus({preventScroll:v})}),[v]);return d((()=>{null!=a&&(m.current=a),n&&h.current&&(p(m.current),w(i,m))}),[n,a,i,p,w]),d((()=>{n&&null!=l&&(m.current=l,p(m.current),w(i,m))}),[n,l,i,p,w]),d((()=>{null==a&&(n&&("ArrowDown"===y.current||"ArrowUp"===y.current||h.current&&(" "===y.current||"Enter"===y.current))&&(m.current="ArrowUp"===y.current?N(i,{startingIndex:i.current.length,decrement:!0}):N(i),p(m.current),w(i,m)),y.current="")}),[n,i,a,p,w]),d((()=>{var e;n||null==a||(null==(e=u.reference.current)||e.focus({preventScroll:v}))}),[u.reference,v,a,n]),d((()=>{n||(h.current=!0)}),[n]),{reference:{onPointerDown(e){h.current=!e.pointerType},onKeyDown(e){y.current=e.key,u.reference.current instanceof Element&&"BUTTON"!==u.reference.current.tagName&&("Enter"!==e.key&&" "!==e.key||o(!0)),s?e.key===(g?"ArrowLeft":"ArrowRight")&&(m.current=N(i),H(e),o(!0),p(m.current),w(i,m)):"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(m.current=null==a?"ArrowDown"===e.key?N(i):N(i,{startingIndex:i.current.length,decrement:!0}):a,H(e),o(!0),p(m.current),w(i,m))}},floating:{onKeyDown(e){if(s&&e.key===(g?"ArrowRight":"ArrowLeft"))return H(e),o(!1),void(x(u.reference.current)&&u.reference.current.focus());const r=m.current,n=N(i),t=N(i,{decrement:!0,startingIndex:i.current.length});if("Home"===e.key&&(m.current=n,p(m.current),w(i,m)),"End"===e.key&&(m.current=t,p(m.current),w(i,m)),"ArrowDown"===e.key||"ArrowUp"===e.key){if(H(e),e.currentTarget.ownerDocument.activeElement===e.currentTarget&&null!=a)return m.current=a,p(m.current),void w(i,m);"ArrowDown"===e.key?m.current=f?r===t?n:N(i,{startingIndex:r}):Math.min(t,N(i,{startingIndex:r})):m.current=f?r===n?t:N(i,{startingIndex:r,decrement:!0}):Math.max(n,N(i,{startingIndex:r,decrement:!0})),p(m.current),w(i,m)}}}}},G=(e,r)=>{let{listRef:n,onMatch:o,debounceMs:c=500,ignoreKeys:u=[]}=r;const i=t(),l=t(""),a=t(null),f=t(null);function d(e){" "===e.key&&l.current.length>0&&(e.preventDefault(),e.stopPropagation());const r=n.current;if(null==r||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...u].includes(e.key))return;l.current+=e.key,clearTimeout(i.current),i.current=setTimeout((()=>{l.current="",a.current=f.current}),c);const t=a.current,d=[...r.slice((null!=t?t:-1)+1),...r.slice(0,null!=t?t:0)].find((e=>0===(null==e?void 0:e.toLowerCase().indexOf(l.current)))),s=d?r.indexOf(d):-1;-1!==s&&(o(s),f.current=s)}return{reference:{onKeyDown:d},floating:{onKeyDown:d}}};function V(e){let{open:r=!1,onOpenChange:n,placement:o,middleware:c,strategy:u,treeRef:l,nodeRef:f}=void 0===e?{}:e;d((()=>{f&&(f.current.open=r)}));const s=t({}),g=a({placement:o,middleware:c,strategy:u}),v=i((()=>({...g,treeRef:l,nodeRef:f,open:r,onOpenChange:n,dataRef:s})),[g,f,l,r,n]);return i((()=>({context:v,...g})),[g,v])}export{L as FloatingGroup,A as FloatingPortal,p as createTree,T as safePolygon,M as useAria,K as useClick,U as useDismiss,V as useFloating,B as useFloatingId,j as useFocus,F as useFocusTrap,O as useGroup,D as useGroupContext,C as useHover,v as useInteractions,q as useListNavigation,G as useTypeahead};

@@ -17,3 +17,3 @@ (function (global, factory) {

function getPreservedProps(userProps, propsArr, elementKey) {
function mergeProps(userProps, propsList, elementKey) {
const mergePropsMap = {

@@ -23,3 +23,3 @@ reference: elementKey === 'reference' ? reducePropsToArrayWithInitValue(userProps) : {},

};
propsArr.forEach(props => {
propsList.forEach(props => {
var _props$elementKey;

@@ -44,3 +44,3 @@

...userProps,
...propsArr.reduce((acc, props) => {
...propsList.reduce((acc, props) => {
Object.assign(acc, props == null ? void 0 : props[elementKey]);

@@ -67,8 +67,12 @@ return acc;

function createPropGetters(propsArr) {
const useInteractions = function (propsList) {
if (propsList === void 0) {
propsList = [];
}
return {
getReferenceProps: userProps => getPreservedProps(userProps, propsArr, 'reference'),
getFloatingProps: userProps => getPreservedProps(userProps, propsArr, 'floating')
getReferenceProps: userProps => mergeProps(userProps, propsList, 'reference'),
getFloatingProps: userProps => mergeProps(userProps, propsList, 'floating')
};
}
};

@@ -149,2 +153,21 @@ function createTree(nodes) {

function getDocument(floating) {
var _floating$ownerDocume;
return (_floating$ownerDocume = floating == null ? void 0 : floating.ownerDocument) != null ? _floating$ownerDocume : document;
}
function getWindow(value) {
var _getDocument$defaultV;
return (_getDocument$defaultV = getDocument(value).defaultView) != null ? _getDocument$defaultV : window;
}
function isElement(value) {
return value ? value instanceof getWindow(value).Element : false;
}
function isHTMLElement(value) {
return value ? value instanceof getWindow(value).HTMLElement : false;
}
function safePolygon(_temp) {

@@ -180,3 +203,3 @@ let {

if (event.type === 'pointermove' && reactDom.isElement(refs.reference.current) && reactDom.contains(refs.reference.current, targetNode) || (_refs$floating$curren = refs.floating.current) != null && _refs$floating$curren.contains(targetNode)) {
if (event.type === 'pointermove' && isElement(refs.reference.current) && refs.reference.current.contains(targetNode) || (_refs$floating$curren = refs.floating.current) != null && _refs$floating$curren.contains(targetNode)) {
return;

@@ -352,6 +375,2 @@ } // If any child has a menu open, abort

function getDocument(floating) {
return floating != null ? reactDom.getWindow(floating).document : document;
}
function getDelay(value, prop) {

@@ -658,3 +677,3 @@ if (typeof value === 'number') {

const focusReference = react.useCallback(() => {
if (reactDom.isHTMLElement(refs.reference.current)) {
if (isHTMLElement(refs.reference.current)) {
refs.reference.current.focus();

@@ -709,3 +728,5 @@ } // eslint-disable-next-line react-hooks/exhaustive-deps

function onPointerDown(event) {
if (reactDom.contains(refs.floating.current, event.target) || reactDom.isElement(refs.reference.current) && reactDom.contains(refs.reference.current, event.target) || isAnyChildNodeOpen()) {
var _refs$floating$curren;
if ((_refs$floating$curren = refs.floating.current) != null && _refs$floating$curren.contains(event.target) || isElement(refs.reference.current) && refs.reference.current.contains(event.target) || isAnyChildNodeOpen()) {
return;

@@ -726,6 +747,6 @@ }

const doc = refs.floating.current != null ? reactDom.getWindow(refs.floating.current).document : document;
const doc = getDocument(refs.floating.current);
escapeKey && doc.addEventListener('keydown', onKeyDown);
outsidePointerDown && doc.addEventListener('pointerdown', onPointerDown);
const ancestors = ancestorScroll ? [...(reactDom.isElement(refs.reference.current) ? reactDom.getOverflowAncestors(refs.reference.current) : []), ...(reactDom.isElement(refs.floating.current) ? reactDom.getOverflowAncestors(refs.floating.current) : [])] : [];
const ancestors = ancestorScroll ? [...(isElement(refs.reference.current) ? reactDom.getOverflowAncestors(refs.reference.current) : []), ...(isElement(refs.floating.current) ? reactDom.getOverflowAncestors(refs.floating.current) : [])] : [];
ancestors.forEach(ancestor => ancestor.addEventListener('scroll', onScroll, {

@@ -788,3 +809,3 @@ passive: true

if (event.type === 'focus' && dataRef.current.openEvent === 'mousedown' && reactDom.isElement(refs.reference.current) && (_refs$reference$curre = refs.reference.current) != null && _refs$reference$curre.contains((_dataRef$current$open = dataRef.current.openEvent) == null ? void 0 : _dataRef$current$open.target)) {
if (event.type === 'focus' && dataRef.current.openEvent === 'mousedown' && isElement(refs.reference.current) && (_refs$reference$curre = refs.reference.current) != null && _refs$reference$curre.contains((_dataRef$current$open = dataRef.current.openEvent) == null ? void 0 : _dataRef$current$open.target)) {
return;

@@ -800,2 +821,4 @@ }

onBlur(event) {
var _refs$floating$curren;
const target = event.relatedTarget; // When focusing the reference element (e.g. regular click), then

@@ -805,3 +828,3 @@ // clicking into the floating element, prevent it from hiding.

if (reactDom.contains(refs.floating.current, target) || reactDom.isElement(refs.reference.current) && reactDom.contains(refs.reference.current, target)) {
if ((_refs$floating$curren = refs.floating.current) != null && _refs$floating$curren.contains(target) || isElement(refs.reference.current) && refs.reference.current.contains(target)) {
return;

@@ -838,3 +861,3 @@ }

return order.map(type => {
if (reactDom.isHTMLElement(refs.reference.current) && type === 'reference') {
if (isHTMLElement(refs.reference.current) && type === 'reference') {
return refs.reference.current;

@@ -877,3 +900,3 @@ }

}
} else if (modal && reactDom.isHTMLElement(refs.reference.current)) {
} else if (modal && isHTMLElement(refs.reference.current)) {
refs.reference.current.focus();

@@ -939,5 +962,7 @@ }

function onBlur(event) {
var _refs$floating$curren3;
const target = event.relatedTarget;
if (target && !reactDom.contains(refs.floating.current, target) && reactDom.isElement(refs.reference.current) && !reactDom.contains(refs.reference.current, target)) {
if (target && !((_refs$floating$curren3 = refs.floating.current) != null && _refs$floating$curren3.contains(target)) && isElement(refs.reference.current) && !refs.reference.current.contains(target)) {
onOpenChange == null ? void 0 : onOpenChange(false);

@@ -1153,3 +1178,3 @@ }

if (reactDom.isHTMLElement(refs.reference.current)) {
if (isHTMLElement(refs.reference.current)) {
refs.reference.current.focus();

@@ -1309,3 +1334,2 @@ }

exports.FloatingPortal = FloatingPortal;
exports.createPropGetters = createPropGetters;
exports.createTree = createTree;

@@ -1323,2 +1347,3 @@ exports.safePolygon = safePolygon;

exports.useHover = useHover;
exports.useInteractions = useInteractions;
exports.useListNavigation = useListNavigation;

@@ -1325,0 +1350,0 @@ exports.useTypeahead = 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,r,n){"use strict";var o="undefined"!=typeof document?t.useLayoutEffect:t.useEffect;function u(e){return Object.entries(null!=e?e:{}).reduce(((e,t)=>{let[r,n]=t;return e[r]=[n],e}),{})}function c(e,t,r){const n={reference:"reference"===r?u(e):{},floating:"floating"===r?u(e):{}};return t.forEach((e=>{var t;const o=null!=(t=null==e?void 0:e[r])?t:{};Object.keys(o).forEach((e=>{var t;"function"==typeof o[e]&&(null==n[r][e]&&(n[r][e]=[]),null==(t=n[r][e])||t.push(o[e]))}))})),{..."floating"===r&&{tabIndex:-1},...e,...t.reduce(((e,t)=>(Object.assign(e,null==t?void 0:t[r]),e)),{}),...Object.entries(n[r]).reduce(((e,t)=>{let[r,n]=t;return 0===r.indexOf("on")&&(e[r]=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.forEach((e=>e(...t)))}),e}),{})}}var i={exports:{}},l=function(e,t,r,n){var o=e[0],u=e[1],c=!1;void 0===r&&(r=0),void 0===n&&(n=t.length);for(var i=(n-r)/2,l=0,a=i-1;l<i;a=l++){var s=t[r+2*l+0],f=t[r+2*l+1],d=t[r+2*a+0],g=t[r+2*a+1];f>u!=g>u&&o<(d-s)*(u-f)/(g-f)+s&&(c=!c)}return c},a=function(e,t,r,n){var o=e[0],u=e[1],c=!1;void 0===r&&(r=0),void 0===n&&(n=t.length);for(var i=n-r,l=0,a=i-1;l<i;a=l++){var s=t[l+r][0],f=t[l+r][1],d=t[a+r][0],g=t[a+r][1];f>u!=g>u&&o<(d-s)*(u-f)/(g-f)+s&&(c=!c)}return c};i.exports=function(e,t,r,n){return t.length>0&&Array.isArray(t[0])?a(e,t,r,n):l(e,t,r,n)},i.exports.nested=a,i.exports.flat=l;var s=i.exports;function f(e){return null!=e?r.getWindow(e).document:document}function d(e,t){return"number"==typeof e?e:e[t]}const g=t.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),p=()=>{const e=t.useContext(g);if(!e)throw new Error("useGroupContext() must be used within a <FloatingGroup />");return e};let v=0;function m(){return"floating-ui-"+v++}function h(){return t.useMemo(m,[])}function y(e){e.preventDefault(),e.stopPropagation()}function w(e,t){let{startingIndex:r=-1,decrement:n=!1}=void 0===t?{}:t,o=r;do{var u,c;o+=n?-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.FloatingGroup=e=>{let{children:r,delay:n}=e;const[o,u]=t.useState({delay:n,initialDelay:n,currentId:null}),c=t.useCallback((e=>{u((t=>({...t,currentId:e})))}),[]);return React.createElement(g.Provider,{value:{...o,setState:u,setCurrentId:c}},r)},e.FloatingPortal=function(e){let{children:r}=e;const[u,c]=t.useState(!1),i=t.useRef(null);return o((()=>{const e=document.getElementById("floating-ui-root");e?i.current=e:(i.current=document.createElement("div"),i.current.id="floating-ui-root");const t=i.current;return document.body.contains(t)||document.body.appendChild(t),c(!0),()=>{document.body.contains(t)&&document.body.removeChild(t)}}),[]),u&&i.current?n.createPortal(r,i.current):null},e.createPropGetters=function(e){return{getReferenceProps:t=>c(t,e,"reference"),getFloatingProps:t=>c(t,e,"floating")}},e.createTree=function(e){const t=new Map;return{nodes:e,emit(e,r){var n;null==(n=t.get(e))||n.forEach((e=>e(r)))},on(e,r){t.set(e,[...t.get(e)||[],r])},off(e,r){t.set(e,(t.get(e)||[]).filter((e=>e!==r)))}}},e.safePolygon=function(e){let t,{timeout:n=0,debug:o=null}=void 0===e?{}:e;return e=>{let{x:o,y:u,placement:c,refs:i,onClose:l,treeRef:a,nodeRef:f}=e;return function(e){var d;if("touch"===e.pointerType)return;const{target:g,clientX:p,clientY:v}=e,m=g;if("pointermove"===e.type&&r.isElement(i.reference.current)&&r.contains(i.reference.current,m)||null!=(d=i.floating.current)&&d.contains(m))return;if(null!=a&&a.current.nodes.filter((e=>{let{current:t}=e;return t.parentId===(null==f?void 0:f.current.id)})).some((e=>{let{current:t}=e;return t.open})))return;if(!i.reference.current||!i.floating.current||null==c||null==o||null==u)return;const h=i.reference.current.getBoundingClientRect(),y=i.floating.current.getBoundingClientRect(),w=c.split("-")[0],b=o>y.right-y.width/2,E=u>y.bottom-y.height/2;switch(w){case"top":if(p>=y.left&&p<=y.right&&v>=y.bottom&&v<=h.top)return;break;case"bottom":if(p>=y.left&&p<=y.right&&v>=h.bottom&&v<=y.top)return;break;case"left":if(p>=y.right&&p<=h.left&&v>=y.left&&v<=y.right)return;break;case"right":if(p>=y.right&&p<=h.left&&v>=y.right&&v<=h.left)return}const R=function(e){let[t,r]=e;switch(w){case"top":{const e=[t-(b?-1:1),r+1],n=[t-(b?-1:1),r-1],o=[[y.left,b||y.width>h.width?y.bottom:y.top],[y.right,b?y.width>h.width?y.bottom:y.top:y.bottom]];return y.width<h.width?b?[e,...o,n]:[e,n,...o]:[e,...o]}case"bottom":{const e=[t-(b?-1:1),r-1],n=[t-(b?-1:1),r+1],o=[[y.left,b||y.width>h.width?y.top:y.bottom],[y.right,b?y.width>h.width?y.top:y.bottom:y.top]];return y.width<h.width?b?[e,...o,n]:[e,n,...o]:[e,...o]}case"left":{const e=[t+1,r-(E?-1:1)],n=[t-1,r-(E?-1:1)],o=[[E||y.height>h.height?y.right-1:y.left,y.top],[E?y.height>h.height?y.right-1:y.left:y.right-1,y.bottom]];return y.height<h.height?E?[e,...o,n]:[e,n,...o]:[e,...o]}case"right":{const e=[t-1,r-(E?-1:1)],n=[t+1,r-(E?-1:1)],o=[[E||y.height>h.height?y.left+1:y.right,y.top],[E?y.height>h.height?y.left+1:y.right:y.left+1,y.bottom]];return y.height<h.height?E?[e,...o,n]:[e,n,...o]:[e,...o]}}}([o,u]);s([p,v],R)?n&&(t=setTimeout(l,n)):(clearTimeout(t),l())}}},e.useAria=function(e,t){let{open:r}=e,{role:n="dialog",titleId:o,descriptionId:u}=void 0===t?{}:t;const c=h(),i={id:c,role:n};return"tooltip"===n?{reference:{"aria-describedby":r?c:void 0},floating:i}:{reference:{"aria-expanded":r?"true":"false","aria-haspopup":n,"aria-controls":r?c:void 0,..."listbox"===n&&{role:"combobox"}},floating:{...i,..."dialog"===n&&{"aria-labelledby":o,"aria-describedby":u}}}},e.useClick=e=>{let{open:t,onOpenChange:r=(()=>{}),dataRef:n}=e;return{reference:{onClick(e){var o;t?"click"===(null==(o=n.current.openEvent)?void 0:o.type)||n.current.hoveredThenClicked?(n.current.hoveredThenClicked=!1,r(!1)):n.current.hoveredThenClicked=!0:(n.current.openEvent=e.nativeEvent,r(!0))}}}},e.useDismiss=function(e,n){let{onOpenChange:o=(()=>{}),refs:u,open:c,treeRef:i,nodeRef:l,dataRef:a}=e,{escapeKey:s=!0,outsidePointerDown:f=!0,referencePointerDown:d=!1,ancestorScroll:g=!1}=void 0===n?{}:n;const p=t.useCallback((()=>{r.isHTMLElement(u.reference.current)&&u.reference.current.focus()}),[u.reference.current]);return t.useEffect((()=>{function e(){o(!1),p()}const t=null==i?void 0:i.current;return null==t||t.on("close",e),()=>{null==t||t.off("close",e)}}),[i,o,p]),t.useEffect((()=>{if(!c)return;function e(){return null==i?void 0:i.current.nodes.filter((e=>{let{current:t}=e;return t.parentId===(null==l?void 0:l.current.id)})).some((e=>{let{current:t}=e;return t.open}))}function t(t){"Escape"!==t.key||e()||(a.current.dismiss=!0,i?i.current.emit("close"):(o(!1),p()))}function n(t){r.contains(u.floating.current,t.target)||r.isElement(u.reference.current)&&r.contains(u.reference.current,t.target)||e()||(i?i.current.emit("close"):(o(!1),p()))}function d(){o(!1)}const v=null!=u.floating.current?r.getWindow(u.floating.current).document:document;s&&v.addEventListener("keydown",t),f&&v.addEventListener("pointerdown",n);const m=g?[...r.isElement(u.reference.current)?r.getOverflowAncestors(u.reference.current):[],...r.isElement(u.floating.current)?r.getOverflowAncestors(u.floating.current):[]]:[];return m.forEach((e=>e.addEventListener("scroll",d,{passive:!0}))),()=>{s&&v.removeEventListener("keydown",t),f&&v.removeEventListener("pointerdown",n),m.forEach((e=>e.removeEventListener("scroll",d)))}}),[s,f,i,l,c,o,a,p,g,u.floating,u.reference]),{reference:{onPointerDown(){d&&(a.current.dismiss=!0,o(!1))}}}},e.useFloating=function(e){let{open:n=!1,onOpenChange:u,placement:c,middleware:i,strategy:l,treeRef:a,nodeRef:s}=void 0===e?{}:e;o((()=>{s&&(s.current.open=n)}));const f=t.useRef({}),d=r.useFloating({placement:c,middleware:i,strategy:l}),g=t.useMemo((()=>({...d,treeRef:a,nodeRef:s,open:n,onOpenChange:u,dataRef:f})),[d,s,a,n,u]);return t.useMemo((()=>({context:g,...d})),[d,g])},e.useFloatingId=h,e.useFocus=function(e,n){let{open:u,onOpenChange:c=(()=>{}),dataRef:i,refs:l}=e,{keyboardOnly:a=!0}=void 0===n?{}:n;const s=t.useRef();return o((()=>{u||(s.current=void 0)})),{reference:{onPointerDown(e){let{pointerType:t}=e;s.current=t},onFocus(e){var t,n;a&&s.current||"focus"===e.type&&"mousedown"===i.current.openEvent&&r.isElement(l.reference.current)&&null!=(t=l.reference.current)&&t.contains(null==(n=i.current.openEvent)?void 0:n.target)||i.current.dismiss||(i.current.openEvent=e.nativeEvent,c(!0))},onBlur(e){const t=e.relatedTarget;r.contains(l.floating.current,t)||r.isElement(l.reference.current)&&r.contains(l.reference.current,t)||(i.current.dismiss=!1,i.current.hoveredThenClicked=!1,c(!1))}}}},e.useFocusTrap=function(e,n){let{open:u,refs:c,treeRef:i,nodeRef:l,onOpenChange:a}=e,{initialContentFocus:s=0,order:d=["content"],modal:g=!0,inert:p=!1,scrollLock:v="auto"}=void 0===n?{}:n;const m=t.useRef(0),h=t.useCallback((()=>d.map((e=>{return r.isHTMLElement(c.reference.current)&&"reference"===e?c.reference.current:c.floating.current&&"floating"===e?c.floating.current:"content"===e?Array.from(null!=(t=null==(n=c.floating.current)?void 0:n.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,*[tabindex],*[contenteditable]"))?t:[]):null;var t,n})).filter(Boolean).flat()),[c.floating,c.reference,d]);function y(e){const t=e.relatedTarget;t&&!r.contains(c.floating.current,t)&&r.isElement(c.reference.current)&&!r.contains(c.reference.current,t)&&(null==a||a(!1))}return t.useEffect((()=>{if(!p)if(u){const r=h();var e;if("number"==typeof s)null==(e=r[s])||e.focus({preventScroll:!0});else if(s.current){var t;null==(t=r.find((e=>e===s.current)))||t.focus({preventScroll:!0})}}else g&&r.isHTMLElement(c.reference.current)&&c.reference.current.focus()}),[h,u,p,g,s,c.reference]),t.useEffect((()=>{if(!g)return;if(!u)return void(m.current=0);function e(e){if((null==i||!i.current.nodes.filter((e=>{let{current:t}=e;return t.parentId===(null==l?void 0:l.current.id)})).some((e=>{let{current:t}=e;return t.open})))&&"Tab"===e.key){var t;if(e.preventDefault(),e.stopPropagation(),p)return;const r=h();e.shiftKey?m.current=0===m.current?r.length-1:m.current-1:m.current=m.current===r.length-1?0:m.current+1,null==(t=r[m.current])||t.focus({preventScroll:!0})}}const t=f(c.floating.current);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}}),[h,l,u,g,i,p,c.floating]),t.useEffect((()=>{if(!u||!g)return;const e=f(c.floating.current).querySelectorAll("body > *:not(#floating-ui-root)");return e.forEach((e=>{e.setAttribute("aria-hidden","true")})),()=>{e.forEach((e=>{e.removeAttribute("aria-hidden")}))}}),[u,g,v,c.floating]),o((()=>{if(!u)return;const e=!0===v||"auto"===v&&g,t=f(c.floating.current);if(e){var r;const e=(null!=(r=t.defaultView)?r:window).innerWidth-t.documentElement.offsetWidth;t.documentElement.style.overflow="hidden",t.body.style.paddingRight=e+"px"}return()=>{e&&(t.documentElement.style.overflow="",t.body.style.paddingRight="")}}),[u,v]),g?{floating:{"aria-modal":"true"}}:{reference:{onBlur:y},floating:{onBlur:y}}},e.useGroup=(e,r)=>{let{open:n,onOpenChange:o}=e,{id:u}=r;const{currentId:c,initialDelay:i,setState:l}=p();t.useEffect((()=>{c&&o&&(l((e=>({...e,delay:{open:0,close:d(i,"close")}}))),c!==u&&o(!1))}),[u,o,l,c,i]),t.useEffect((()=>{!n&&c===u&&o&&(o(!1),l((e=>({...e,delay:i,currentId:null}))))}),[n,l,c,u,o,i])},e.useGroupContext=p,e.useHover=function(e,r){let{delay:n=0,handleLeave:u=null,mouseOnly:c=!1,pointerRestMs:i=0}=void 0===r?{}:r;const{onOpenChange:l=(()=>{}),open:a,dataRef:s,refs:g}=e,p=t.useRef(null),v=t.useRef(!1),m=t.useRef(),h=t.useRef();o((()=>{if(!u)return;if(!a)return void(v.current=!1);function e(){var e;"pointerover"===(null==(e=p.current)?void 0:e.type)&&l(!1)}const t=f(g.floating.current).documentElement;return t.addEventListener("pointerleave",e),()=>{t.removeEventListener("pointerleave",e)}}),[a,l,u]);const y=t.useRef();return{reference:{onPointerMove(){0===i||a||(clearTimeout(y.current),y.current=setTimeout((()=>{s.current.dismiss||l(!0)}),i))},onPointerEnter(e){c&&"mouse"!==e.pointerType||(p.current=e.nativeEvent,n?(clearTimeout(m.current),m.current=setTimeout((()=>{s.current.dismiss||l(!0)}),d(n,"open"))):l(!0))},onPointerLeave(t){var r;if(v.current||"click"===(null==(r=p.current)?void 0:r.type))return;const o=f(g.floating.current);if(u)return clearTimeout(m.current),h.current&&o.removeEventListener("pointermove",h.current),h.current=u({...e,x:t.clientX,y:t.clientY,onClose(){h.current&&o.removeEventListener("pointermove",h.current),l(!1)}}),void o.addEventListener("pointermove",h.current);s.current.dismiss=!1,n?(clearTimeout(y.current),clearTimeout(m.current),m.current=setTimeout((()=>l(!1)),d(n,"close"))):(v.current=!1,l(!1))}}}},e.useListNavigation=(e,n)=>{let{open:u,onOpenChange:c=(()=>{}),refs:i}=e,{listRef:l,activeIndex:a=null,selectedIndex:s=null,loop:f=!1,nested:d=!1,rtl:g=!1,preventScroll:p=!0,onNavigate:v=(()=>{})}=n;const m=t.useRef(!0),h=t.useRef(null!=s?s:0),b=t.useRef(""),E=t.useCallback(((e,t)=>{var r;null==(r=e.current[t.current])||r.focus({preventScroll:p})}),[p]);return o((()=>{null!=s&&(h.current=s),u&&m.current&&(v(h.current),E(l,h))}),[u,s,l,v,E]),o((()=>{u&&null!=a&&(h.current=a,v(h.current),E(l,h))}),[u,a,l,v,E]),o((()=>{null==s&&(u&&("ArrowDown"===b.current||"ArrowUp"===b.current||m.current&&(" "===b.current||"Enter"===b.current))&&(h.current="ArrowUp"===b.current?w(l,{startingIndex:l.current.length,decrement:!0}):w(l),v(h.current),E(l,h)),b.current="")}),[u,l,s,v,E]),o((()=>{var e;u||null==s||(null==(e=i.reference.current)||e.focus({preventScroll:p}))}),[i.reference,p,s,u]),o((()=>{u||(m.current=!0)}),[u]),{reference:{onPointerDown(e){m.current=!e.pointerType},onKeyDown(e){b.current=e.key,i.reference.current instanceof Element&&"BUTTON"!==i.reference.current.tagName&&("Enter"!==e.key&&" "!==e.key||c(!0)),d?e.key===(g?"ArrowLeft":"ArrowRight")&&(h.current=w(l),y(e),c(!0),v(h.current),E(l,h)):"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(h.current=null==s?"ArrowDown"===e.key?w(l):w(l,{startingIndex:l.current.length,decrement:!0}):s,y(e),c(!0),v(h.current),E(l,h))}},floating:{onKeyDown(e){if(d&&e.key===(g?"ArrowRight":"ArrowLeft"))return y(e),c(!1),void(r.isHTMLElement(i.reference.current)&&i.reference.current.focus());const t=h.current,n=w(l),o=w(l,{decrement:!0,startingIndex:l.current.length});if("Home"===e.key&&(h.current=n,v(h.current),E(l,h)),"End"===e.key&&(h.current=o,v(h.current),E(l,h)),"ArrowDown"===e.key||"ArrowUp"===e.key){if(y(e),e.currentTarget.ownerDocument.activeElement===e.currentTarget&&null!=s)return h.current=s,v(h.current),void E(l,h);"ArrowDown"===e.key?h.current=f?t===o?n:w(l,{startingIndex:t}):Math.min(o,w(l,{startingIndex:t})):h.current=f?t===n?o:w(l,{startingIndex:t,decrement:!0}):Math.max(n,w(l,{startingIndex:t,decrement:!0})),v(h.current),E(l,h)}}}}},e.useTypeahead=(e,r)=>{let{listRef:n,onMatch:o,debounceMs:u=500,ignoreKeys:c=[]}=r;const i=t.useRef(),l=t.useRef(""),a=t.useRef(null),s=t.useRef(null);function f(e){" "===e.key&&l.current.length>0&&(e.preventDefault(),e.stopPropagation());const t=n.current;if(null==t||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...c].includes(e.key))return;l.current+=e.key,clearTimeout(i.current),i.current=setTimeout((()=>{l.current="",a.current=s.current}),u);const r=a.current,f=[...t.slice((null!=r?r:-1)+1),...t.slice(0,null!=r?r:0)].find((e=>0===(null==e?void 0:e.toLowerCase().indexOf(l.current)))),d=f?t.indexOf(f):-1;-1!==d&&(o(d),s.current=d)}return{reference:{onKeyDown:f},floating:{onKeyDown:f}}},Object.keys(r).forEach((function(t){"default"===t||e.hasOwnProperty(t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(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"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.React,e.FloatingUIReactDOM,e.ReactDOM)}(this,(function(e,r,t,n){"use strict";var o="undefined"!=typeof document?r.useLayoutEffect:r.useEffect;function u(e){return Object.entries(null!=e?e:{}).reduce(((e,r)=>{let[t,n]=r;return e[t]=[n],e}),{})}function c(e,r,t){const n={reference:"reference"===t?u(e):{},floating:"floating"===t?u(e):{}};return r.forEach((e=>{var r;const o=null!=(r=null==e?void 0:e[t])?r:{};Object.keys(o).forEach((e=>{var r;"function"==typeof o[e]&&(null==n[t][e]&&(n[t][e]=[]),null==(r=n[t][e])||r.push(o[e]))}))})),{..."floating"===t&&{tabIndex:-1},...e,...r.reduce(((e,r)=>(Object.assign(e,null==r?void 0:r[t]),e)),{}),...Object.entries(n[t]).reduce(((e,r)=>{let[t,n]=r;return 0===t.indexOf("on")&&(e[t]=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];n.forEach((e=>e(...r)))}),e}),{})}}var i={exports:{}},l=function(e,r,t,n){var o=e[0],u=e[1],c=!1;void 0===t&&(t=0),void 0===n&&(n=r.length);for(var i=(n-t)/2,l=0,a=i-1;l<i;a=l++){var f=r[t+2*l+0],s=r[t+2*l+1],d=r[t+2*a+0],g=r[t+2*a+1];s>u!=g>u&&o<(d-f)*(u-s)/(g-s)+f&&(c=!c)}return c},a=function(e,r,t,n){var o=e[0],u=e[1],c=!1;void 0===t&&(t=0),void 0===n&&(n=r.length);for(var i=n-t,l=0,a=i-1;l<i;a=l++){var f=r[l+t][0],s=r[l+t][1],d=r[a+t][0],g=r[a+t][1];s>u!=g>u&&o<(d-f)*(u-s)/(g-s)+f&&(c=!c)}return c};i.exports=function(e,r,t,n){return r.length>0&&Array.isArray(r[0])?a(e,r,t,n):l(e,r,t,n)},i.exports.nested=a,i.exports.flat=l;var f=i.exports;function s(e){var r;return null!=(r=null==e?void 0:e.ownerDocument)?r:document}function d(e){var r;return null!=(r=s(e).defaultView)?r:window}function g(e){return!!e&&e instanceof d(e).Element}function p(e){return!!e&&e instanceof d(e).HTMLElement}function v(e,r){return"number"==typeof e?e:e[r]}const h=r.createContext({delay:1e3,initialDelay:1e3,currentId:null,setCurrentId:()=>{},setState:()=>{}}),m=()=>{const e=r.useContext(h);if(!e)throw new Error("useGroupContext() must be used within a <FloatingGroup />");return e};let y=0;function w(){return"floating-ui-"+y++}function b(){return r.useMemo(w,[])}function E(e){e.preventDefault(),e.stopPropagation()}function R(e,r){let{startingIndex:t=-1,decrement:n=!1}=void 0===r?{}:r,o=t;do{var u,c;o+=n?-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.FloatingGroup=e=>{let{children:t,delay:n}=e;const[o,u]=r.useState({delay:n,initialDelay:n,currentId:null}),c=r.useCallback((e=>{u((r=>({...r,currentId:e})))}),[]);return React.createElement(h.Provider,{value:{...o,setState:u,setCurrentId:c}},t)},e.FloatingPortal=function(e){let{children:t}=e;const[u,c]=r.useState(!1),i=r.useRef(null);return o((()=>{const e=document.getElementById("floating-ui-root");e?i.current=e:(i.current=document.createElement("div"),i.current.id="floating-ui-root");const r=i.current;return document.body.contains(r)||document.body.appendChild(r),c(!0),()=>{document.body.contains(r)&&document.body.removeChild(r)}}),[]),u&&i.current?n.createPortal(t,i.current):null},e.createTree=function(e){const r=new Map;return{nodes:e,emit(e,t){var n;null==(n=r.get(e))||n.forEach((e=>e(t)))},on(e,t){r.set(e,[...r.get(e)||[],t])},off(e,t){r.set(e,(r.get(e)||[]).filter((e=>e!==t)))}}},e.safePolygon=function(e){let r,{timeout:t=0,debug:n=null}=void 0===e?{}:e;return e=>{let{x:n,y:o,placement:u,refs:c,onClose:i,treeRef:l,nodeRef:a}=e;return function(e){var s;if("touch"===e.pointerType)return;const{target:d,clientX:p,clientY:v}=e,h=d;if("pointermove"===e.type&&g(c.reference.current)&&c.reference.current.contains(h)||null!=(s=c.floating.current)&&s.contains(h))return;if(null!=l&&l.current.nodes.filter((e=>{let{current:r}=e;return r.parentId===(null==a?void 0:a.current.id)})).some((e=>{let{current:r}=e;return r.open})))return;if(!c.reference.current||!c.floating.current||null==u||null==n||null==o)return;const m=c.reference.current.getBoundingClientRect(),y=c.floating.current.getBoundingClientRect(),w=u.split("-")[0],b=n>y.right-y.width/2,E=o>y.bottom-y.height/2;switch(w){case"top":if(p>=y.left&&p<=y.right&&v>=y.bottom&&v<=m.top)return;break;case"bottom":if(p>=y.left&&p<=y.right&&v>=m.bottom&&v<=y.top)return;break;case"left":if(p>=y.right&&p<=m.left&&v>=y.left&&v<=y.right)return;break;case"right":if(p>=y.right&&p<=m.left&&v>=y.right&&v<=m.left)return}const R=function(e){let[r,t]=e;switch(w){case"top":{const e=[r-(b?-1:1),t+1],n=[r-(b?-1:1),t-1],o=[[y.left,b||y.width>m.width?y.bottom:y.top],[y.right,b?y.width>m.width?y.bottom:y.top:y.bottom]];return y.width<m.width?b?[e,...o,n]:[e,n,...o]:[e,...o]}case"bottom":{const e=[r-(b?-1:1),t-1],n=[r-(b?-1:1),t+1],o=[[y.left,b||y.width>m.width?y.top:y.bottom],[y.right,b?y.width>m.width?y.top:y.bottom:y.top]];return y.width<m.width?b?[e,...o,n]:[e,n,...o]:[e,...o]}case"left":{const e=[r+1,t-(E?-1:1)],n=[r-1,t-(E?-1:1)],o=[[E||y.height>m.height?y.right-1:y.left,y.top],[E?y.height>m.height?y.right-1:y.left:y.right-1,y.bottom]];return y.height<m.height?E?[e,...o,n]:[e,n,...o]:[e,...o]}case"right":{const e=[r-1,t-(E?-1:1)],n=[r+1,t-(E?-1:1)],o=[[E||y.height>m.height?y.left+1:y.right,y.top],[E?y.height>m.height?y.left+1:y.right:y.left+1,y.bottom]];return y.height<m.height?E?[e,...o,n]:[e,n,...o]:[e,...o]}}}([n,o]);f([p,v],R)?t&&(r=setTimeout(i,t)):(clearTimeout(r),i())}}},e.useAria=function(e,r){let{open:t}=e,{role:n="dialog",titleId:o,descriptionId:u}=void 0===r?{}:r;const c=b(),i={id:c,role:n};return"tooltip"===n?{reference:{"aria-describedby":t?c:void 0},floating:i}:{reference:{"aria-expanded":t?"true":"false","aria-haspopup":n,"aria-controls":t?c:void 0,..."listbox"===n&&{role:"combobox"}},floating:{...i,..."dialog"===n&&{"aria-labelledby":o,"aria-describedby":u}}}},e.useClick=e=>{let{open:r,onOpenChange:t=(()=>{}),dataRef:n}=e;return{reference:{onClick(e){var o;r?"click"===(null==(o=n.current.openEvent)?void 0:o.type)||n.current.hoveredThenClicked?(n.current.hoveredThenClicked=!1,t(!1)):n.current.hoveredThenClicked=!0:(n.current.openEvent=e.nativeEvent,t(!0))}}}},e.useDismiss=function(e,n){let{onOpenChange:o=(()=>{}),refs:u,open:c,treeRef:i,nodeRef:l,dataRef:a}=e,{escapeKey:f=!0,outsidePointerDown:d=!0,referencePointerDown:v=!1,ancestorScroll:h=!1}=void 0===n?{}:n;const m=r.useCallback((()=>{p(u.reference.current)&&u.reference.current.focus()}),[u.reference.current]);return r.useEffect((()=>{function e(){o(!1),m()}const r=null==i?void 0:i.current;return null==r||r.on("close",e),()=>{null==r||r.off("close",e)}}),[i,o,m]),r.useEffect((()=>{if(!c)return;function e(){return null==i?void 0:i.current.nodes.filter((e=>{let{current:r}=e;return r.parentId===(null==l?void 0:l.current.id)})).some((e=>{let{current:r}=e;return r.open}))}function r(r){"Escape"!==r.key||e()||(a.current.dismiss=!0,i?i.current.emit("close"):(o(!1),m()))}function n(r){var t;null!=(t=u.floating.current)&&t.contains(r.target)||g(u.reference.current)&&u.reference.current.contains(r.target)||e()||(i?i.current.emit("close"):(o(!1),m()))}function p(){o(!1)}const v=s(u.floating.current);f&&v.addEventListener("keydown",r),d&&v.addEventListener("pointerdown",n);const y=h?[...g(u.reference.current)?t.getOverflowAncestors(u.reference.current):[],...g(u.floating.current)?t.getOverflowAncestors(u.floating.current):[]]:[];return y.forEach((e=>e.addEventListener("scroll",p,{passive:!0}))),()=>{f&&v.removeEventListener("keydown",r),d&&v.removeEventListener("pointerdown",n),y.forEach((e=>e.removeEventListener("scroll",p)))}}),[f,d,i,l,c,o,a,m,h,u.floating,u.reference]),{reference:{onPointerDown(){v&&(a.current.dismiss=!0,o(!1))}}}},e.useFloating=function(e){let{open:n=!1,onOpenChange:u,placement:c,middleware:i,strategy:l,treeRef:a,nodeRef:f}=void 0===e?{}:e;o((()=>{f&&(f.current.open=n)}));const s=r.useRef({}),d=t.useFloating({placement:c,middleware:i,strategy:l}),g=r.useMemo((()=>({...d,treeRef:a,nodeRef:f,open:n,onOpenChange:u,dataRef:s})),[d,f,a,n,u]);return r.useMemo((()=>({context:g,...d})),[d,g])},e.useFloatingId=b,e.useFocus=function(e,t){let{open:n,onOpenChange:u=(()=>{}),dataRef:c,refs:i}=e,{keyboardOnly:l=!0}=void 0===t?{}:t;const a=r.useRef();return o((()=>{n||(a.current=void 0)})),{reference:{onPointerDown(e){let{pointerType:r}=e;a.current=r},onFocus(e){var r,t;l&&a.current||"focus"===e.type&&"mousedown"===c.current.openEvent&&g(i.reference.current)&&null!=(r=i.reference.current)&&r.contains(null==(t=c.current.openEvent)?void 0:t.target)||c.current.dismiss||(c.current.openEvent=e.nativeEvent,u(!0))},onBlur(e){var r;const t=e.relatedTarget;null!=(r=i.floating.current)&&r.contains(t)||g(i.reference.current)&&i.reference.current.contains(t)||(c.current.dismiss=!1,c.current.hoveredThenClicked=!1,u(!1))}}}},e.useFocusTrap=function(e,t){let{open:n,refs:u,treeRef:c,nodeRef:i,onOpenChange:l}=e,{initialContentFocus:a=0,order:f=["content"],modal:d=!0,inert:v=!1,scrollLock:h="auto"}=void 0===t?{}:t;const m=r.useRef(0),y=r.useCallback((()=>f.map((e=>{return p(u.reference.current)&&"reference"===e?u.reference.current:u.floating.current&&"floating"===e?u.floating.current:"content"===e?Array.from(null!=(r=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]"))?r:[]):null;var r,t})).filter(Boolean).flat()),[u.floating,u.reference,f]);function w(e){var r;const t=e.relatedTarget;!t||null!=(r=u.floating.current)&&r.contains(t)||!g(u.reference.current)||u.reference.current.contains(t)||null==l||l(!1)}return r.useEffect((()=>{if(!v)if(n){const t=y();var e;if("number"==typeof a)null==(e=t[a])||e.focus({preventScroll:!0});else if(a.current){var r;null==(r=t.find((e=>e===a.current)))||r.focus({preventScroll:!0})}}else d&&p(u.reference.current)&&u.reference.current.focus()}),[y,n,v,d,a,u.reference]),r.useEffect((()=>{if(!d)return;if(!n)return void(m.current=0);function e(e){if((null==c||!c.current.nodes.filter((e=>{let{current:r}=e;return r.parentId===(null==i?void 0:i.current.id)})).some((e=>{let{current:r}=e;return r.open})))&&"Tab"===e.key){var r;if(e.preventDefault(),e.stopPropagation(),v)return;const t=y();e.shiftKey?m.current=0===m.current?t.length-1:m.current-1:m.current=m.current===t.length-1?0:m.current+1,null==(r=t[m.current])||r.focus({preventScroll:!0})}}const r=s(u.floating.current);return r.addEventListener("keydown",e),()=>{r.removeEventListener("keydown",e)}}),[y,i,n,d,c,v,u.floating]),r.useEffect((()=>{if(!n||!d)return;const e=s(u.floating.current).querySelectorAll("body > *:not(#floating-ui-root)");return e.forEach((e=>{e.setAttribute("aria-hidden","true")})),()=>{e.forEach((e=>{e.removeAttribute("aria-hidden")}))}}),[n,d,h,u.floating]),o((()=>{if(!n)return;const e=!0===h||"auto"===h&&d,r=s(u.floating.current);if(e){var t;const e=(null!=(t=r.defaultView)?t:window).innerWidth-r.documentElement.offsetWidth;r.documentElement.style.overflow="hidden",r.body.style.paddingRight=e+"px"}return()=>{e&&(r.documentElement.style.overflow="",r.body.style.paddingRight="")}}),[n,h]),d?{floating:{"aria-modal":"true"}}:{reference:{onBlur:w},floating:{onBlur:w}}},e.useGroup=(e,t)=>{let{open:n,onOpenChange:o}=e,{id:u}=t;const{currentId:c,initialDelay:i,setState:l}=m();r.useEffect((()=>{c&&o&&(l((e=>({...e,delay:{open:0,close:v(i,"close")}}))),c!==u&&o(!1))}),[u,o,l,c,i]),r.useEffect((()=>{!n&&c===u&&o&&(o(!1),l((e=>({...e,delay:i,currentId:null}))))}),[n,l,c,u,o,i])},e.useGroupContext=m,e.useHover=function(e,t){let{delay:n=0,handleLeave:u=null,mouseOnly:c=!1,pointerRestMs:i=0}=void 0===t?{}:t;const{onOpenChange:l=(()=>{}),open:a,dataRef:f,refs:d}=e,g=r.useRef(null),p=r.useRef(!1),h=r.useRef(),m=r.useRef();o((()=>{if(!u)return;if(!a)return void(p.current=!1);function e(){var e;"pointerover"===(null==(e=g.current)?void 0:e.type)&&l(!1)}const r=s(d.floating.current).documentElement;return r.addEventListener("pointerleave",e),()=>{r.removeEventListener("pointerleave",e)}}),[a,l,u]);const y=r.useRef();return{reference:{onPointerMove(){0===i||a||(clearTimeout(y.current),y.current=setTimeout((()=>{f.current.dismiss||l(!0)}),i))},onPointerEnter(e){c&&"mouse"!==e.pointerType||(g.current=e.nativeEvent,n?(clearTimeout(h.current),h.current=setTimeout((()=>{f.current.dismiss||l(!0)}),v(n,"open"))):l(!0))},onPointerLeave(r){var t;if(p.current||"click"===(null==(t=g.current)?void 0:t.type))return;const o=s(d.floating.current);if(u)return clearTimeout(h.current),m.current&&o.removeEventListener("pointermove",m.current),m.current=u({...e,x:r.clientX,y:r.clientY,onClose(){m.current&&o.removeEventListener("pointermove",m.current),l(!1)}}),void o.addEventListener("pointermove",m.current);f.current.dismiss=!1,n?(clearTimeout(y.current),clearTimeout(h.current),h.current=setTimeout((()=>l(!1)),v(n,"close"))):(p.current=!1,l(!1))}}}},e.useInteractions=function(e){return void 0===e&&(e=[]),{getReferenceProps:r=>c(r,e,"reference"),getFloatingProps:r=>c(r,e,"floating")}},e.useListNavigation=(e,t)=>{let{open:n,onOpenChange:u=(()=>{}),refs:c}=e,{listRef:i,activeIndex:l=null,selectedIndex:a=null,loop:f=!1,nested:s=!1,rtl:d=!1,preventScroll:g=!0,onNavigate:v=(()=>{})}=t;const h=r.useRef(!0),m=r.useRef(null!=a?a:0),y=r.useRef(""),w=r.useCallback(((e,r)=>{var t;null==(t=e.current[r.current])||t.focus({preventScroll:g})}),[g]);return o((()=>{null!=a&&(m.current=a),n&&h.current&&(v(m.current),w(i,m))}),[n,a,i,v,w]),o((()=>{n&&null!=l&&(m.current=l,v(m.current),w(i,m))}),[n,l,i,v,w]),o((()=>{null==a&&(n&&("ArrowDown"===y.current||"ArrowUp"===y.current||h.current&&(" "===y.current||"Enter"===y.current))&&(m.current="ArrowUp"===y.current?R(i,{startingIndex:i.current.length,decrement:!0}):R(i),v(m.current),w(i,m)),y.current="")}),[n,i,a,v,w]),o((()=>{var e;n||null==a||(null==(e=c.reference.current)||e.focus({preventScroll:g}))}),[c.reference,g,a,n]),o((()=>{n||(h.current=!0)}),[n]),{reference:{onPointerDown(e){h.current=!e.pointerType},onKeyDown(e){y.current=e.key,c.reference.current instanceof Element&&"BUTTON"!==c.reference.current.tagName&&("Enter"!==e.key&&" "!==e.key||u(!0)),s?e.key===(d?"ArrowLeft":"ArrowRight")&&(m.current=R(i),E(e),u(!0),v(m.current),w(i,m)):"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(m.current=null==a?"ArrowDown"===e.key?R(i):R(i,{startingIndex:i.current.length,decrement:!0}):a,E(e),u(!0),v(m.current),w(i,m))}},floating:{onKeyDown(e){if(s&&e.key===(d?"ArrowRight":"ArrowLeft"))return E(e),u(!1),void(p(c.reference.current)&&c.reference.current.focus());const r=m.current,t=R(i),n=R(i,{decrement:!0,startingIndex:i.current.length});if("Home"===e.key&&(m.current=t,v(m.current),w(i,m)),"End"===e.key&&(m.current=n,v(m.current),w(i,m)),"ArrowDown"===e.key||"ArrowUp"===e.key){if(E(e),e.currentTarget.ownerDocument.activeElement===e.currentTarget&&null!=a)return m.current=a,v(m.current),void w(i,m);"ArrowDown"===e.key?m.current=f?r===n?t:R(i,{startingIndex:r}):Math.min(n,R(i,{startingIndex:r})):m.current=f?r===t?n:R(i,{startingIndex:r,decrement:!0}):Math.max(t,R(i,{startingIndex:r,decrement:!0})),v(m.current),w(i,m)}}}}},e.useTypeahead=(e,t)=>{let{listRef:n,onMatch:o,debounceMs:u=500,ignoreKeys:c=[]}=t;const i=r.useRef(),l=r.useRef(""),a=r.useRef(null),f=r.useRef(null);function s(e){" "===e.key&&l.current.length>0&&(e.preventDefault(),e.stopPropagation());const r=n.current;if(null==r||["Home","End","Escape","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight",...c].includes(e.key))return;l.current+=e.key,clearTimeout(i.current),i.current=setTimeout((()=>{l.current="",a.current=f.current}),u);const t=a.current,s=[...r.slice((null!=t?t:-1)+1),...r.slice(0,null!=t?t:0)].find((e=>0===(null==e?void 0:e.toLowerCase().indexOf(l.current)))),d=s?r.indexOf(s):-1;-1!==d&&(o(d),f.current=d)}return{reference:{onKeyDown:s},floating:{onKeyDown:s}}},Object.keys(t).forEach((function(r){"default"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@floating-ui/react-dom-interactions",
"version": "0.0.0",
"version": "0.0.1",
"@rollingversions": {

@@ -5,0 +5,0 @@ "baseVersion": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc