Socket
Socket
Sign inDemoInstall

react-laag

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-laag - npm Package Compare versions

Comparing version 1.7.0 to 1.7.1

6

dist/index.es.js

@@ -1153,3 +1153,3 @@ import React__default, { useState, useRef, useEffect, useCallback, createElement, Fragment, useMemo, useLayoutEffect } from 'react';

}, []);
return [setRef, state];
return [setRef, state, lastElement];
}

@@ -1249,3 +1249,3 @@

scrollParents
}] = useElementState(container, fixed, environment);
}, normalTriggerRef] = useElementState(container, fixed, environment);
const {

@@ -1365,3 +1365,3 @@ styles,

useOnScroll(scrollParents, handlePositioning, environment, isOpen);
const outsideClickRefs = useRef(new Set([layerRef, triggerRef])); // handle clicks that are not originated from the trigger / layer
const outsideClickRefs = useRef(new Set([layerRef, normalTriggerRef])); // handle clicks that are not originated from the trigger / layer
// element

@@ -1368,0 +1368,0 @@

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

import React__default,{useState,useRef,useEffect,useCallback,createElement,Fragment,useMemo,useLayoutEffect}from"react";import{createPortal}from"react-dom";function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function useEvent(e,t,r,n,o){return void 0===n&&(n=!0),void 0===o&&(o=!1),useEffect(()=>{if(!n||!e)return;const i=r,s=Array.isArray(e)?e:[e],l=Array.isArray(t)?t:[t];return s.forEach(e=>{l.forEach(t=>{e.addEventListener(t,i,o)})}),()=>{s.forEach(e=>{l.forEach(t=>{e.removeEventListener(t,i,o)})})}},[r,e,n,t,o])}const OutsideClickContext=React__default.createContext({});function isChildOf(e,t){if(e===t)return!0;if(e.children&&e.children.length>0)for(let r=0;r<e.children.length;r++){const n=e.children[r];if(n&&isChildOf(n,t))return!0}return!1}function OutsideClickGroupProvider(e){let{refs:t,children:r}=e;return"function"==typeof React__default.useContext(OutsideClickContext)?r:React__default.createElement(OutsideClickContext.Provider,{value:React__default.useCallback(e=>{t.current.add(e)},[])},r)}function useRegisterGroup(e){const t=React__default.useContext(OutsideClickContext);React__default.useEffect(()=>{const[r]=e.current.values();"function"==typeof t&&r&&t(r)},[t,e])}function useOutsideClick(e,t){const[r]=React__default.useState(["click"]);useRegisterGroup(e),useEvent("undefined"!=typeof document?document:null,r,React__default.useCallback(r=>{for(const t of e.current)if(t.current&&isChildOf(t.current,r.target))return;t()},[t]),!0,!0)}function useOnScroll(e,t,r,n){void 0===n&&(n=!0),useEvent(useMemo(()=>void 0!==r?[r,...e]:[],[e]),"scroll",t,n)}function useOnWindowResize(e,t,r){void 0===r&&(r=!0),useEvent(void 0!==t?t:null,"resize",e,r)}const useIsomorphicLayoutEffect="undefined"!=typeof window?useLayoutEffect:useEffect;function useTrackElementResize(e,t,r,n,o,i){const s=useRef(o);s.current=o;const l=e||(void 0===i?class{}:i.ResizeObserver);if(!l)throw new Error("This browser does not support `ResizeObserver` out of the box. Please provide a polyfill as a prop.");const c=useRef(new l(()=>{t.current&&s.current()}));return useIsomorphicLayoutEffect(()=>{n?r&&c.current.observe(r):(r&&c.current.unobserve(r),t.current&&c.current.unobserve(t.current))},[n,r]),useEffect(()=>()=>{c.current.disconnect()},[]),c.current}const EMPTY_STYLE={};function isSet(e){return void 0!==e&&null!==e}function areStylesTheSame(e,t){const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o=0;o<Math.max(r.length,n.length);o++){const i=r[o]||n[o];if(e[i]!==t[i])return!1}return!0}function shouldUpdateStyles(e,t){return!areStylesTheSame(e.layer,t.layer)||!areStylesTheSame(e.arrow,t.arrow)}function getWindowClientRect(e){return{top:0,left:0,right:e?e.innerWidth:0,bottom:e?e.innerHeight:0,height:e?e.innerHeight:0,width:e?e.innerWidth:0}}const convertFloat=e=>parseFloat(e.replace("px",""));function getContentBox(e,t){if(!t)return{width:0,height:0};const{width:r,height:n,boxSizing:o,borderLeft:i,borderRight:s,borderTop:l,borderBottom:c,paddingLeft:a,paddingRight:u,paddingTop:f,paddingBottom:g}=t.getComputedStyle(e);return{width:"border-box"===o?convertFloat(r):[r,i,s,a,u].reduce((e,t)=>e+(t?convertFloat(t):0),0),height:"border-box"===o?convertFloat(n):[n,l,c,f,g].reduce((e,t)=>e+(t?convertFloat(t):0),0)}}function clientRectToObject(e){return{top:e.top,left:e.left,right:e.right,bottom:e.bottom,width:e.width,height:e.height}}function getElementFromAnchorNode(e){let t=e;for(;!t.getBoundingClientRect;){if(!t.parentElement)return null;t=t.parentElement}return t}function minMax(e,t){let{min:r,max:n}=t;return e<r?r:e>n?n:e}function useStyleState(e){const[t]=useState({layer:EMPTY_STYLE,arrow:EMPTY_STYLE,layerSide:e.split("_")[0].toLowerCase()}),[r,n]=useState(t),o=useRef(r);return{styles:r,lastStyles:o,setStyles:n,resetLastStyles:()=>{o.current=t}}}const Anchor={BOTTOM_LEFT:"BOTTOM_LEFT",BOTTOM_RIGHT:"BOTTOM_RIGHT",BOTTOM_CENTER:"BOTTOM_CENTER",TOP_LEFT:"TOP_LEFT",TOP_CENTER:"TOP_CENTER",TOP_RIGHT:"TOP_RIGHT",LEFT_BOTTOM:"LEFT_BOTTOM",LEFT_CENTER:"LEFT_CENTER",LEFT_TOP:"LEFT_TOP",RIGHT_BOTTOM:"RIGHT_BOTTOM",RIGHT_CENTER:"RIGHT_CENTER",RIGHT_TOP:"RIGHT_TOP"},POSSIBLE_ANCHORS=Object.keys(Anchor);function getPrimaryDirection(e){return e.startsWith("TOP_")||e.startsWith("BOTTOM_")?"Y":"X"}function primaryIsY(e){return"TOP"===e||"BOTTOM"===e}function getPrimaryByIndex(e,t,r,n){const o=primaryIsY(t);return e<3?t:e<6?o?r:n:e<9?o?["LEFT","RIGHT"].filter(e=>e!==r)[0]:["TOP","BOTTOM"].filter(e=>e!==n)[0]:o?["TOP","BOTTOM"].filter(e=>e!==t)[0]:["LEFT","RIGHT"].filter(e=>e!==t)[0]}function getSecondaryByIndex(e,t,r,n){const o=primaryIsY(t),i=n.trigger.height>n.layer.height,s=n.trigger.width>n.layer.width;switch(e){case 9:case 0:return r;case 1:case 10:return"CENTER"===r?o?"RIGHT":"BOTTOM":"CENTER";case 4:case 7:return"CENTER";case 2:case 11:return o?["LEFT","RIGHT"].filter(e=>e!==r)[0]:["TOP","BOTTOM"].filter(e=>e!==r)[0];case 3:case 6:return o?"BOTTOM"===t?i?"BOTTOM":"TOP":i?"TOP":"BOTTOM":"LEFT"===t?s?"LEFT":"RIGHT":s?"RIGHT":"LEFT";case 5:case 8:return o?"BOTTOM"===t?i?"TOP":"BOTTOM":i?"BOTTOM":"TOP":"LEFT"===t?s?"RIGHT":"LEFT":s?"LEFT":"RIGHT"}return"LEFT"}function getSecondaryAnchorOptionsByPrimary(e,t){return t.filter(t=>t.startsWith(e))}function splitAnchor(e){const[t,r]=e.split("_");return{primary:t,secondary:r}}function getLayerSideByAnchor(e){return"CENTER"===e?"center":splitAnchor(e).primary.toLowerCase()}function getAnchorPriority(e,t,r,n,o){const{primary:i,secondary:s}="CENTER"!==e?splitAnchor(e):{primary:n,secondary:"CENTER"};let l=POSSIBLE_ANCHORS.map((e,t)=>getPrimaryByIndex(t,i,r,n)+"_"+getSecondaryByIndex(t,i,s,o)).filter(e=>t.indexOf(e)>-1);return-1===l.indexOf(e)&&(l=[e,...l]),l}function getPrimaryStyle(e,t,r,n){const o="TOP"===e||"BOTTOM"===e?"top":"left",i="TOP"===e||"BOTTOM"===e?"height":"width";return"TOP"===e||"LEFT"===e?{[o]:t.trigger[o]-t.layer[i]-(t.relativeParent[o]-r[o])-n}:{[o]:t.trigger[o]+t.trigger[i]-(t.relativeParent[o]-r[o])+n}}function getCenter(e,t,r,n,o){return minMax(e.trigger[n]-e.relativeParent[n]+t[n]+e.trigger[o]/2-e.layer[o]/2-r,getLimits(e,t)[n])}function getLimits(e,t){const r=e.trigger.top-e.relativeParent.top+t.top,n=e.trigger.left-e.relativeParent.left+t.left;return{top:{min:r-(e.layer.height-e.arrow.height),max:r+(e.trigger.height-e.arrow.height)},left:{min:n-(e.layer.width-e.arrow.width),max:n+(e.trigger.width-e.arrow.width)}}}function getSecondaryStyle(e,t,r,n,o){if("CENTER"===e){const e="X"===o?"top":"left";return{[e]:getCenter(t,r,n,e,"X"===o?"height":"width")}}const i="TOP"===e||"BOTTOM"===e?"top":"left",s="TOP"===e||"BOTTOM"===e?"height":"width";return"TOP"===e||"LEFT"===e?{[i]:minMax(t.trigger[i]-t.relativeParent[i]+r[i]+n,getLimits(t,r)[i])}:{[i]:minMax(t.trigger[i]+t.trigger[s]-t.layer[s]-(t.relativeParent[i]-r[i])-n,getLimits(t,r)[i])}}function getAbsolutePositions(e){let{anchor:t,rects:r,triggerOffset:n,offsetSecondary:o,scrollLeft:i,scrollTop:s}=e;const l={left:i,top:s};if("CENTER"===t)return{top:getCenter(r,l,0,"top","height"),left:getCenter(r,l,0,"left","width")};const{primary:c,secondary:a}=splitAnchor(t),u=getPrimaryDirection(t);return _extends({},getPrimaryStyle(c,r,l,n),{},getSecondaryStyle(a,r,l,o,u))}function fixLayerDimensions(e,t,r){const n="function"==typeof r?r(getLayerSideByAnchor(t)):r;return _extends({},clientRectToObject(e),{},n)}const propMap={TOP:{side1:"bottom",side2:"top",size:"height",factor:-1},BOTTOM:{side1:"top",side2:"bottom",size:"height",factor:1},LEFT:{side1:"right",side2:"left",size:"width",factor:-1},RIGHT:{side1:"left",side2:"right",size:"width",factor:1}};function getPrimaryRect(e,t,r,n){const{side1:o,side2:i,size:s,factor:l}=propMap[e],c=t[i]+n*l;return{[o]:c,[i]:c+r[s]*l}}function getCenter$1(e,t,r,n,o){const i=e[n]+e[o]/2-t[o]/2-r;return{[n]:i,["left"===n?"right":"bottom"]:i+t[o]}}function getSecondaryRect(e,t,r,n,o){if("CENTER"===e){return getCenter$1(t,r,n,"X"===o?"top":"left","X"===o?"height":"width")}const{side1:i,side2:s,size:l,factor:c}=propMap[e],a=t[s]-n*c;return{[s]:a,[i]:a-r[l]*c}}function getLayerRectByAnchor(e){let t,r,{trigger:n,layer:o,anchor:i,triggerOffset:s,scrollOffset:l=0,offsetSecondary:c=0,layerDimensions:a}=e;const u=a?fixLayerDimensions(o,i,a):o;if("CENTER"===i)t=getCenter$1(n,u,0,"top","height"),r=getCenter$1(n,u,0,"left","width");else{const{primary:e,secondary:o}=splitAnchor(i),l=getPrimaryDirection(i);t=getPrimaryRect(e,n,u,s),r=getSecondaryRect(o,n,u,c,l)}const f=_extends({},u,{},t,{},r);return f.top=f.top-l,f.right=f.right+l,f.left=f.left-l,f.bottom=f.bottom+l,f}const ALL_OFFSET_SIDES=["bottom","top","left","right"];function getLayerOffsetsToParent(e,t){return{top:e.top-t.top,bottom:t.bottom-e.bottom,left:e.left-t.left,right:t.right-e.right}}function getLayerOffsetsToParents(e,t){return t.map(t=>getLayerOffsetsToParent(e,t))}function isLayerCompletelyInvisible(e,t){return t.some(t=>e.bottom<=t.top||e.right<=t.left||e.top>=t.bottom||e.left>=t.right)}function doesEntireLayerFitWithinScrollParents(e,t){return getLayerOffsetsToParents(e,t).every(e=>ALL_OFFSET_SIDES.every(t=>e[t]>=0))}function reduceOffsets(e){const t=e.reduce((e,t)=>(ALL_OFFSET_SIDES.forEach(r=>{e[r]=[...e[r],t[r]]}),e),{top:[],bottom:[],left:[],right:[]});return ALL_OFFSET_SIDES.reduce((e,r)=>(e[r]=t[r].sort((e,t)=>e-t)[0],e),{})}function getNegativeOffsetSides(e){const t=reduceOffsets(e);return ALL_OFFSET_SIDES.filter(e=>t[e]<0)}function getVisibleLayerSurface(e,t){const r=getLayerOffsetsToParent(e,t),{width:n,height:o}=ALL_OFFSET_SIDES.filter(e=>r[e]<0).reduce((e,t)=>{const n="top"===t||"bottom"===t?"height":"width";return _extends({},e,{[n]:e[n]+r[t]})},e),i=n*o;return n<0&&o<0?-i:i}function getVisibleLayerSurfaceWithinScrollParent(e,t){return t.map(t=>getVisibleLayerSurface(e,t)).sort((e,t)=>e-t)[0]}function doesAnchorFitWithinScrollParents(e,t,r,n,o){return doesEntireLayerFitWithinScrollParents(getLayerRectByAnchor({anchor:e,trigger:t.trigger,layer:t.layer,triggerOffset:r,scrollOffset:n,layerDimensions:o}),t.scrollParents)}function getLayerOffsetsToScrollParentsByAnchor(e,t,r,n){return getLayerOffsetsToParents(getLayerRectByAnchor({anchor:e,trigger:t.trigger,layer:t.layer,triggerOffset:r,scrollOffset:n,layerDimensions:null}),t.scrollParents)}function triggerIsBiggerThanLayer(e,t,r){return("top"===e||"bottom"===e)&&r.width>t.width||("left"===e||"right"===e)&&r.height>t.height}function getOffsetSurface(e,t,r,n){const o=getPrimaryDirection(e);return(t["X"===o?"width":"height"]-r-2*n)*(t["X"===o?"height":"width"]-r-2*n)}function findAnchorByLayerSurface(e,t,r,n,o){return t.map(t=>{const i=getLayerRectByAnchor({anchor:t,layer:e.layer,trigger:e.trigger,scrollOffset:n,triggerOffset:r,layerDimensions:o});return{anchor:t,square:getVisibleLayerSurfaceWithinScrollParent(i,e.scrollParents)-getOffsetSurface(t,i,r,n)}}).sort((e,t)=>t.square-e.square)[0].anchor}function findBestSuitableAnchor(e,t,r,n,o){const i=t.find(t=>doesAnchorFitWithinScrollParents(t,e,r,n,o));return i||findAnchorByLayerSurface(e,t,r,n,o)}function getSecondaryOffsetSide(e,t,r,n,o){const i=getPrimaryDirection(e);return getNegativeOffsetSides(getLayerOffsetsToScrollParentsByAnchor(t,r,n,o)).find(e=>"X"===i?"top"===e||"bottom"===e:"left"===e||"right"===e)}function findSecondaryOffset(e,t,r,n,o){const{primary:i}=splitAnchor(e),s=getSecondaryAnchorOptionsByPrimary(i,t),l=0===s.indexOf(e),c=doesAnchorFitWithinScrollParents(e,r,n,o,null);if(l&&c)return 0;const a=getSecondaryOffsetSide(e,s.find(e=>!doesAnchorFitWithinScrollParents(e,r,n,o,null)),r,n,o);if(!a)return 0;let u=-reduceOffsets(getLayerOffsetsToScrollParentsByAnchor(e,r,n,o))[a];const f=triggerIsBiggerThanLayer(getLayerSideByAnchor(e),r.layer,r.trigger),g=e.includes("_CENTER"),d=e.includes("_LEFT"),h=e.includes("_TOP");return f&&(d&&"right"===a||"left"===a||h&&"bottom"===a||"top"===a)?u=-u:f||!g||"top"!==a&&"left"!==a||(u=-u),u}function getOffsets(e,t,r){const n=e.left+e.width/2-t.left-r.width/2,o=e.right-e.width/2-t.right+r.width/2,i=e.top+e.height/2-t.top-r.height/2,s=e.bottom-e.height/2-t.bottom+r.height/2;return{left:n<0?-n:0,right:o>0?-o:0,top:i<0?-i:0,bottom:s>0?-s:0}}function getArrowStyle(e,t,r,n){const o=triggerIsBiggerThanLayer(r,e,t),i={left:{min:n.width/2,max:e.width-n.width/2},top:{min:n.height/2,max:e.height-n.height/2}},s=getOffsets(e,t,n);return"bottom"===r?{bottom:"100%",top:null,left:minMax(o?e.width/2+(s.left+s.right):t.left+t.width/2-e.left,i.left),right:null}:"right"===r?{right:"100%",left:null,top:minMax(o?e.height/2+(s.top+s.bottom):t.top+t.height/2-e.top,i.top),bottom:null}:"top"===r?{top:"100%",bottom:null,left:minMax(o?e.width/2+(s.left+s.right):t.left+t.width/2-e.left,i.left),right:null}:{left:"100%",right:null,top:minMax(o?e.height/2+(s.top+s.bottom):t.top+t.height/2-e.top,i.top),bottom:null}}function getAbsoluteStyle(e){let{rects:t,scrollTop:r,scrollLeft:n,triggerOffset:o,scrollOffset:i,possibleAnchors:s,preferedAnchor:l,preferedX:c,preferedY:a,autoAdjust:u,snapToAnchor:f,layerDimensions:g}=e;const d=getAnchorPriority(l,s,c,a,t),h=u?findBestSuitableAnchor(t,d,o,i,g):l,p=u&&!f&&"CENTER"!==h?findSecondaryOffset(h,d,t,o,i):0,y=getAbsolutePositions({anchor:h,rects:t,triggerOffset:o,offsetSecondary:p,scrollLeft:n,scrollTop:r}),m=getLayerRectByAnchor({anchor:h,trigger:t.trigger,layer:t.layer,triggerOffset:o,offsetSecondary:p,layerDimensions:g});return g&&(y.width=m.width,y.height=m.height),{layerStyle:y,layerRect:m,anchor:h}}function compensateScrollbars(e,t,r){const n=e.width-t,o=e.height-r;return{left:e.left,top:e.top,width:e.width-n,right:e.right-n,height:e.height-o,bottom:e.bottom-o}}function getArrowRect(e,t){const r=e.querySelector("[data-arrow]");if(!r)return{top:0,bottom:0,left:0,right:0,width:0,height:0};const n=r.getBoundingClientRect();return _extends({},clientRectToObject(n),{width:n.width+2*t,height:n.height+2*t})}const defaultPlacement={autoAdjust:!1,snapToAnchor:!1,anchor:"TOP_CENTER",layerDimensions:null,possibleAnchors:POSSIBLE_ANCHORS,preferX:"RIGHT",preferY:"BOTTOM",scrollOffset:10,triggerOffset:0,arrowOffset:0};function getPositioning(e){let{triggerRect:t,layerElement:r,relativeParentElement:n,scrollParents:o,placement:i={},environment:s,fixed:l}=e;if(0===t.height)return;if(!r)return;const c=l?[getWindowClientRect(s)]:[...o.map(e=>compensateScrollbars(e.getBoundingClientRect(),e.clientWidth,e.clientHeight)),getWindowClientRect(s)],a={autoAdjust:i.autoAdjust||defaultPlacement.autoAdjust,snapToAnchor:i.snapToAnchor||defaultPlacement.snapToAnchor,triggerOffset:isSet(i.triggerOffset)?i.triggerOffset:defaultPlacement.triggerOffset,scrollOffset:isSet(i.scrollOffset)?i.scrollOffset:defaultPlacement.scrollOffset,possibleAnchors:i.possibleAnchors||defaultPlacement.possibleAnchors,preferedAnchor:i.anchor||defaultPlacement.anchor,preferedX:i.preferX||defaultPlacement.preferX,preferedY:i.preferY||defaultPlacement.preferY,scrollLeft:n===document.body?0:n.scrollLeft,scrollTop:n===document.body?0:n.scrollTop,relativeParentElement:n,layerDimensions:i.layerDimensions||defaultPlacement.layerDimensions},u=r.getBoundingClientRect(),f={layer:_extends({top:u.top,left:u.left,right:u.right,bottom:u.bottom},getContentBox(r,s)),relativeParent:n.getBoundingClientRect(),scrollParents:c,trigger:t,arrow:getArrowRect(r,i.arrowOffset||defaultPlacement.arrowOffset)},{layerRect:g,layerStyle:d,anchor:h}=getAbsoluteStyle(_extends({rects:f},a));l&&(d.top=g.top,d.left=g.left);const p=getLayerSideByAnchor(h);return{styles:{layer:d,arrow:"CENTER"===h?EMPTY_STYLE:getArrowStyle(g,t,p,f.arrow),layerSide:p},layerRect:g}}function useElementRef(e,t){const[r,n]=useState(e||null),o=useRef(null);return[useCallback(e=>{e&&e!==o.current&&(o.current=e,n(t?t(e):e))},[]),r]}function findScrollContainers(e,t){const r=[];if(!e||!t)return r;if(e===document.body)return r;const{overflow:n,overflowX:o,overflowY:i}=t.getComputedStyle(e);return[n,o,i].some(e=>"auto"===e||"scroll"===e)&&r.push(e),[...r,...findScrollContainers(e.parentElement,t)]}function useElementState(e,t,r){return useElementRef({triggerElement:null,relativeParentElement:null,scrollParents:[]},useCallback(n=>{const o=findScrollContainers(n,r),i=o[0]||document.body;if(i===document.body)document.body.style.position="relative";else if("development"===process.env.NODE_ENV&&r){const n="function"==typeof e?e():e,o=r.getComputedStyle(i).position;"relative"!==o&&"absolute"!==o&&"fixed"!==o&&!t&&!n&&console.error("react-laag: Set the 'position' style of the nearest scroll-container to 'relative', 'absolute' or 'fixed', or set the 'fixed' prop to true. This is needed in order to position the layers properly. Currently the scroll-container is positioned: \""+o+'". Visit https://react-laag.com/docs/#position-relative for more info.',i)}return{triggerElement:n,relativeParentElement:i,scrollParents:o}},[]))}function useIsOpen(e,t){const r=useRef(t),n=!r.current&&(isSet(t)?t:e),o=useState(!1)[1];return useEffect(()=>{r.current&&(r.current=!1,o(!0))},[]),n}function ToggleLayer(e){let{children:t,renderLayer:r,placement:n={},onStyle:o,isOpen:i,closeOnOutsideClick:s,onOutsideClick:l,onDisappear:c,closeOnDisappear:a,fixed:u,container:f,environment:g=("undefined"!=typeof window?window:void 0)}=e,d=_objectWithoutPropertiesLoose(e,["children","renderLayer","placement","onStyle","isOpen","closeOnOutsideClick","onOutsideClick","onDisappear","closeOnDisappear","fixed","container","environment"]);const[h,{relativeParentElement:p,triggerElement:y,scrollParents:m}]=useElementState(f,u,g),{styles:T,setStyles:O,lastStyles:S,resetLastStyles:E}=useStyleState(n.anchor||defaultPlacement.anchor),w=useRef(null),[P,L]=useState(!1),R=useIsOpen(P,i),b=useCallback(()=>{if(!y)throw new Error("Could not find a valid reference of the trigger element. See https://www.react-laag.com/docs/togglelayer/#children for more info.");const e=y.getBoundingClientRect(),t=getPositioning({triggerRect:e,layerElement:w.current,placement:n,relativeParentElement:p,scrollParents:m,fixed:u,environment:g});if(!t)return;const{layerRect:r,styles:s}=t;shouldUpdateStyles(S.current,s)&&(isSet(o)?(S.current=s,o(s.layer,s.arrow,s.layerSide)):O(s));const l=isSet(c),f=a&&!isSet(i);if(l||f){const t=[...m.map(e=>e.getBoundingClientRect()),getWindowClientRect(g)],n=!doesEntireLayerFitWithinScrollParents(u?e:r,t),o=isLayerCompletelyInvisible(u?e:r,t);l?(n||o)&&c(o?"full":"partial"):("partial"===a&&n&&L(!1),"full"===a&&o&&L(!1))}},[p,R,y,m,u,n]),C=useTrackElementResize(d.ResizeObserver,w,y,R,b,g);useIsomorphicLayoutEffect(()=>{const e=!isSet(o);T!==S.current&&e?S.current=T:R?b():E()}),useOnWindowResize(b,g,R),useOnScroll(m,b,g,R);const v=useRef(new Set([w,h]));useOutsideClick(v,useCallback(()=>{R&&(l&&l(),s&&!isSet(i)&&L(!1))},[R,L,i]));const _="function"==typeof f?f():f;return createElement(Fragment,null,t({isOpen:R,close:()=>{if(isSet(i))throw new Error("You cannot call `close()` while using the `isOpen` prop");L(!1)},open:()=>{if(isSet(i))throw new Error("You cannot call `open()` while using the `isOpen` prop");L(!0)},toggle:()=>{if(isSet(i))throw new Error("You cannot call `toggle()` while using the `isOpen` prop");L(!P)},triggerRef:h,layerSide:R?T.layerSide:null}),p&&createElement(OutsideClickGroupProvider,{refs:v},createPortal(r({layerProps:{ref:e=>{e&&C.observe(e),w.current=e},style:_extends({},isSet(o)?EMPTY_STYLE:T.layer,{position:u?"fixed":"absolute",willChange:"top, bottom, left, right, width, height"})},arrowStyle:_extends({},isSet(o)?EMPTY_STYLE:T.arrow,{position:"absolute",willChange:"top, bottom, left, right"}),isOpen:R,layerSide:T.layerSide,triggerRect:y?y.getBoundingClientRect():null,close:()=>{if(isSet(i))throw new Error("You cannot call `close()` while using the `isOpen` prop");L(!1)}}),_||p)))}function getWidthBasedOnAngle(e,t){return Math.tan(e*(Math.PI/180))*t}function getViewBox(e,t,r,n){switch(r){case"bottom":return"0 "+-n+" "+t+" "+e;case"top":return"0 0 "+t+" "+(e+n);case"right":return-n+" 0 "+e+" "+t;case"left":return"0 0 "+(e+n)+" "+t}return""}function getTrianglePath(e){let{sizeA:t,sizeB:r,layerSide:n,roundness:o,angle:i}=e;const s=o/10*t*2,l="bottom"===n?"0 "+t:"top"===n?"0 0":"right"===n?t+" "+r:"0 "+r,c=("bottom"===n||"top"===n?"H":"V")+" "+("bottom"===n||"top"===n?r:0),a=r/2,u=r/2+getWidthBasedOnAngle(i,t/8),f=t/8,g="bottom"===n?"C "+u+" "+f+" "+(a+s)+" 0 "+a+" 0":"top"===n?"C "+u+" "+(t-f)+" "+(a+s)+" "+t+" "+a+" "+t:"right"===n?"C "+f+" "+(r-u)+" 0 "+(a-s)+" 0 "+a:"C "+(t-f)+" "+(r-u)+" "+t+" "+(a-s)+" "+t+" "+a,d=r/2-getWidthBasedOnAngle(i,t/8),h=t/8;return"M "+l+" "+c+" "+g+" "+("bottom"===n?"C "+(a-s)+" 0 "+d+" "+h+" "+l:"top"===n?"C "+(a-s)+" "+t+" "+d+" "+(t-h)+" "+l:"right"===n?"C 0 "+(a+s)+" "+h+" "+(r-d)+" "+l:"C"+t+" "+(a+s)+" "+(t-h)+" "+(r-d)+" "+l)}function getBorderMaskPath(e){let{sizeA:t,sizeB:r,borderWidth:n,layerSide:o,angle:i}=e;const s=getWidthBasedOnAngle(i,n);return"bottom"===o||"top"===o?"M "+n+" "+("bottom"===o?t:0)+" H "+(r-n)+" L "+(r-n-s)+" "+("bottom"===o?t-n:n)+" H "+(s+n)+" Z":"M "+("right"===o?t:0)+" "+n+" V "+(r-n)+" L "+("right"===o?t-n:n)+" "+(r-n-s)+" V "+(s+n)+" Z"}function Arrow(e){let{size:t=8,angle:r=45,borderWidth:n=0,borderColor:o="black",roundness:i=0,backgroundColor:s="white",layerSide:l="top",style:c={}}=e;if("center"===l)return null;const a=t,u=2*getWidthBasedOnAngle(r,t);return createElement("svg",{style:_extends({},c,{transform:"translate"+("left"===l||"right"===l?"Y":"X")+"(-50%)"}),"data-arrow":"true",width:"left"===l||"right"===l?a:u,viewBox:getViewBox(a,u,l,n)},createElement("path",{fill:s,strokeWidth:n,stroke:o,d:getTrianglePath({angle:r,layerSide:l,roundness:i,sizeA:a,sizeB:u})}),createElement("path",{fill:s,d:getBorderMaskPath({sizeA:a,sizeB:u,angle:r,borderWidth:n,layerSide:l})}))}function useToggleLayer(e,t){let r=void 0===t?{}:t,{onStyle:n,closeOnOutsideClick:o,closeOnDisappear:i,fixed:s,container:l,placement:c={},environment:a=("undefined"!=typeof window?window:void 0)}=r,u=_objectWithoutPropertiesLoose(r,["onStyle","closeOnOutsideClick","closeOnDisappear","fixed","container","placement","environment"]);const[f,{relativeParentElement:g,triggerElement:d,scrollParents:h}]=useElementState(l,s,a),{styles:p,setStyles:y,lastStyles:m,resetLastStyles:T}=useStyleState(c.anchor||defaultPlacement.anchor),O=useRef(null),S=useRef(null);function E(){return"function"==typeof S.current?S.current():S.current}const[w,P]=useState(!1);function L(){S.current=null,P(!1)}const R=useCallback(()=>{const e=E();if(!e)return;const t=getPositioning({triggerRect:e,layerElement:O.current,placement:c,relativeParentElement:g,scrollParents:h,fixed:s,environment:a});if(!t)return;const{layerRect:r,styles:o}=t;if(shouldUpdateStyles(m.current,o)&&(isSet(n)?(m.current=o,n(o.layer,o.arrow,o.layerSide)):y(o)),i){const t=[...h.map(e=>e.getBoundingClientRect()),getWindowClientRect(a)],n=!doesEntireLayerFitWithinScrollParents(s?e:r,t),o=isLayerCompletelyInvisible(s?e:r,t);"partial"===i&&n&&L(),"full"===i&&o&&L()}},[g,w,d,h,s,c]),b=useTrackElementResize(u.ResizeObserver,O,d,w,R,a);useIsomorphicLayoutEffect(()=>{const e=!isSet(n);p!==m.current&&e?m.current=p:w?R():T()}),useOnWindowResize(R,a,w),useOnScroll(h,R,a,w);const C=useRef(new Set([O]));useOutsideClick(C,useCallback(()=>{w&&o&&L()},[w,P,o]));const v="function"==typeof l?l():l;function _(e){let{clientRect:t,target:r}=e;S.current=t,w&&r===d?R():(f(r),P(!0))}const B={isOpen:w,close:L,open:_,openFromContextMenuEvent:e=>{e.preventDefault();const t=e.target;_({clientRect:{top:e.clientY,left:e.clientX,bottom:e.clientY+1,right:e.clientX+1,width:1,height:1},target:t})},openFromMouseEvent:e=>{const t=e.currentTarget;if(!t||!t.getBoundingClientRect)return;_({clientRect:()=>t.getBoundingClientRect(),target:t})},openFromRef:e=>{e.current?_({target:e.current,clientRect:e.current.getBoundingClientRect()}):console.error("Error inside useTooltip(): Expected a valid ref to a trigger element, but got "+typeof e.current)},openFromSelection:e=>{if(!e.anchorNode||e.isCollapsed)return;const t=getElementFromAnchorNode(e.anchorNode);if(!t)return;const r=e.getRangeAt(0);_({clientRect:()=>r.getBoundingClientRect(),target:t})},layerSide:w?p.layerSide:null},A=g&&createPortal(e({layerProps:{ref:e=>{e&&b.observe(e),O.current=e},style:_extends({},isSet(n)?EMPTY_STYLE:p.layer,{position:s?"fixed":"absolute",willChange:"top, bottom, left, right, width, height"})},arrowStyle:_extends({},isSet(n)?EMPTY_STYLE:p.arrow,{position:"absolute",willChange:"top, bottom, left, right"}),isOpen:w,layerSide:p.layerSide,triggerRect:E(),close:()=>{L()}}),v||g);return[createElement(OutsideClickGroupProvider,{refs:C},A),B]}function useHover(e){const{delayEnter:t=0,delayLeave:r=0,hideOnScroll:n=!0,onShow:o,onHide:i}=e||{},[s,l]=useState(!1),c=useRef(null),a=useRef(null),u=useRef(!1);function f(e){if(e)return o&&o(),void l(!0);i&&i(),l(!1)}useEffect(()=>{const e=c.current;function t(){c.current&&(clearTimeout(c.current),c.current=null)}function r(){s&&n&&(t(),f(!1))}function o(){s&&(t(),f(!1))}return window.addEventListener("scroll",r,!0),window.addEventListener("touchend",o,!0),()=>{window.removeEventListener("scroll",r,!0),window.removeEventListener("touchend",o,!0),e&&clearTimeout(e)}},[s,n]);const g={onMouseEnter:function(){"leaving"===a.current&&c.current&&(clearTimeout(c.current),c.current=null,a.current=null),s||(a.current="entering",c.current=setTimeout(()=>{f(!0),c.current=null,a.current=null},t))},onMouseLeave:function(){"entering"===a.current&&c.current&&(clearTimeout(c.current),c.current=null),s&&(a.current="leaving",c.current=setTimeout(()=>{f(!1),c.current=null},r))},onTouchStart:()=>{u.current=!1},onTouchMove:()=>{u.current=!0},onTouchEnd:()=>{u.current||s||f(!0),u.current=!1}};return o?g:[s,g]}function useBreakpoint(e){const[t,r]=useState("undefined"!=typeof window&&window.matchMedia("(max-width: "+e+"px)").matches);return useEffect(()=>{const t=window.matchMedia("(max-width: "+e+"px)");function n(e){r(e.matches)}return t.addListener(n),()=>{t.removeListener(n)}},[e]),t}function Transition(e){let{isOpen:t,children:r}=e;const[n,o]=useState({isOpenInternal:t,isLeaving:!1}),i=useRef(!1);return useEffect(()=>{t?o({isOpenInternal:!0,isLeaving:!1}):i.current&&o({isOpenInternal:!1,isLeaving:!0})},[t,o]),useEffect(()=>{i.current=!0},[]),t||n.isOpenInternal||n.isLeaving?r(n.isOpenInternal,()=>{n.isOpenInternal||o(e=>_extends({},e,{isLeaving:!1}))},n.isLeaving):null}function useTooltip(e,t){let r=void 0===t?{}:t,{delayEnter:n,delayLeave:o,hideOnScroll:i}=r,s=_objectWithoutPropertiesLoose(r,["delayEnter","delayLeave","hideOnScroll"]);const l=useRef(),[c,{openFromRef:a,close:u}]=useToggleLayer(e,s),f=useHover({delayEnter:n,delayLeave:o,hideOnScroll:i,onShow:()=>a(l),onHide:u});return[c,_extends({ref:l},f)]}export{ToggleLayer,Arrow,useToggleLayer,Anchor as anchor,useHover,useBreakpoint,Transition,useTooltip};
import React__default,{useState,useRef,useEffect,useCallback,createElement,Fragment,useMemo,useLayoutEffect}from"react";import{createPortal}from"react-dom";function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function useEvent(e,t,r,n,o){return void 0===n&&(n=!0),void 0===o&&(o=!1),useEffect(()=>{if(!n||!e)return;const i=r,s=Array.isArray(e)?e:[e],l=Array.isArray(t)?t:[t];return s.forEach(e=>{l.forEach(t=>{e.addEventListener(t,i,o)})}),()=>{s.forEach(e=>{l.forEach(t=>{e.removeEventListener(t,i,o)})})}},[r,e,n,t,o])}const OutsideClickContext=React__default.createContext({});function isChildOf(e,t){if(e===t)return!0;if(e.children&&e.children.length>0)for(let r=0;r<e.children.length;r++){const n=e.children[r];if(n&&isChildOf(n,t))return!0}return!1}function OutsideClickGroupProvider(e){let{refs:t,children:r}=e;return"function"==typeof React__default.useContext(OutsideClickContext)?r:React__default.createElement(OutsideClickContext.Provider,{value:React__default.useCallback(e=>{t.current.add(e)},[])},r)}function useRegisterGroup(e){const t=React__default.useContext(OutsideClickContext);React__default.useEffect(()=>{const[r]=e.current.values();"function"==typeof t&&r&&t(r)},[t,e])}function useOutsideClick(e,t){const[r]=React__default.useState(["click"]);useRegisterGroup(e),useEvent("undefined"!=typeof document?document:null,r,React__default.useCallback(r=>{for(const t of e.current)if(t.current&&isChildOf(t.current,r.target))return;t()},[t]),!0,!0)}function useOnScroll(e,t,r,n){void 0===n&&(n=!0),useEvent(useMemo(()=>void 0!==r?[r,...e]:[],[e]),"scroll",t,n)}function useOnWindowResize(e,t,r){void 0===r&&(r=!0),useEvent(void 0!==t?t:null,"resize",e,r)}const useIsomorphicLayoutEffect="undefined"!=typeof window?useLayoutEffect:useEffect;function useTrackElementResize(e,t,r,n,o,i){const s=useRef(o);s.current=o;const l=e||(void 0===i?class{}:i.ResizeObserver);if(!l)throw new Error("This browser does not support `ResizeObserver` out of the box. Please provide a polyfill as a prop.");const c=useRef(new l(()=>{t.current&&s.current()}));return useIsomorphicLayoutEffect(()=>{n?r&&c.current.observe(r):(r&&c.current.unobserve(r),t.current&&c.current.unobserve(t.current))},[n,r]),useEffect(()=>()=>{c.current.disconnect()},[]),c.current}const EMPTY_STYLE={};function isSet(e){return void 0!==e&&null!==e}function areStylesTheSame(e,t){const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o=0;o<Math.max(r.length,n.length);o++){const i=r[o]||n[o];if(e[i]!==t[i])return!1}return!0}function shouldUpdateStyles(e,t){return!areStylesTheSame(e.layer,t.layer)||!areStylesTheSame(e.arrow,t.arrow)}function getWindowClientRect(e){return{top:0,left:0,right:e?e.innerWidth:0,bottom:e?e.innerHeight:0,height:e?e.innerHeight:0,width:e?e.innerWidth:0}}const convertFloat=e=>parseFloat(e.replace("px",""));function getContentBox(e,t){if(!t)return{width:0,height:0};const{width:r,height:n,boxSizing:o,borderLeft:i,borderRight:s,borderTop:l,borderBottom:c,paddingLeft:a,paddingRight:u,paddingTop:f,paddingBottom:g}=t.getComputedStyle(e);return{width:"border-box"===o?convertFloat(r):[r,i,s,a,u].reduce((e,t)=>e+(t?convertFloat(t):0),0),height:"border-box"===o?convertFloat(n):[n,l,c,f,g].reduce((e,t)=>e+(t?convertFloat(t):0),0)}}function clientRectToObject(e){return{top:e.top,left:e.left,right:e.right,bottom:e.bottom,width:e.width,height:e.height}}function getElementFromAnchorNode(e){let t=e;for(;!t.getBoundingClientRect;){if(!t.parentElement)return null;t=t.parentElement}return t}function minMax(e,t){let{min:r,max:n}=t;return e<r?r:e>n?n:e}function useStyleState(e){const[t]=useState({layer:EMPTY_STYLE,arrow:EMPTY_STYLE,layerSide:e.split("_")[0].toLowerCase()}),[r,n]=useState(t),o=useRef(r);return{styles:r,lastStyles:o,setStyles:n,resetLastStyles:()=>{o.current=t}}}const Anchor={BOTTOM_LEFT:"BOTTOM_LEFT",BOTTOM_RIGHT:"BOTTOM_RIGHT",BOTTOM_CENTER:"BOTTOM_CENTER",TOP_LEFT:"TOP_LEFT",TOP_CENTER:"TOP_CENTER",TOP_RIGHT:"TOP_RIGHT",LEFT_BOTTOM:"LEFT_BOTTOM",LEFT_CENTER:"LEFT_CENTER",LEFT_TOP:"LEFT_TOP",RIGHT_BOTTOM:"RIGHT_BOTTOM",RIGHT_CENTER:"RIGHT_CENTER",RIGHT_TOP:"RIGHT_TOP"},POSSIBLE_ANCHORS=Object.keys(Anchor);function getPrimaryDirection(e){return e.startsWith("TOP_")||e.startsWith("BOTTOM_")?"Y":"X"}function primaryIsY(e){return"TOP"===e||"BOTTOM"===e}function getPrimaryByIndex(e,t,r,n){const o=primaryIsY(t);return e<3?t:e<6?o?r:n:e<9?o?["LEFT","RIGHT"].filter(e=>e!==r)[0]:["TOP","BOTTOM"].filter(e=>e!==n)[0]:o?["TOP","BOTTOM"].filter(e=>e!==t)[0]:["LEFT","RIGHT"].filter(e=>e!==t)[0]}function getSecondaryByIndex(e,t,r,n){const o=primaryIsY(t),i=n.trigger.height>n.layer.height,s=n.trigger.width>n.layer.width;switch(e){case 9:case 0:return r;case 1:case 10:return"CENTER"===r?o?"RIGHT":"BOTTOM":"CENTER";case 4:case 7:return"CENTER";case 2:case 11:return o?["LEFT","RIGHT"].filter(e=>e!==r)[0]:["TOP","BOTTOM"].filter(e=>e!==r)[0];case 3:case 6:return o?"BOTTOM"===t?i?"BOTTOM":"TOP":i?"TOP":"BOTTOM":"LEFT"===t?s?"LEFT":"RIGHT":s?"RIGHT":"LEFT";case 5:case 8:return o?"BOTTOM"===t?i?"TOP":"BOTTOM":i?"BOTTOM":"TOP":"LEFT"===t?s?"RIGHT":"LEFT":s?"LEFT":"RIGHT"}return"LEFT"}function getSecondaryAnchorOptionsByPrimary(e,t){return t.filter(t=>t.startsWith(e))}function splitAnchor(e){const[t,r]=e.split("_");return{primary:t,secondary:r}}function getLayerSideByAnchor(e){return"CENTER"===e?"center":splitAnchor(e).primary.toLowerCase()}function getAnchorPriority(e,t,r,n,o){const{primary:i,secondary:s}="CENTER"!==e?splitAnchor(e):{primary:n,secondary:"CENTER"};let l=POSSIBLE_ANCHORS.map((e,t)=>getPrimaryByIndex(t,i,r,n)+"_"+getSecondaryByIndex(t,i,s,o)).filter(e=>t.indexOf(e)>-1);return-1===l.indexOf(e)&&(l=[e,...l]),l}function getPrimaryStyle(e,t,r,n){const o="TOP"===e||"BOTTOM"===e?"top":"left",i="TOP"===e||"BOTTOM"===e?"height":"width";return"TOP"===e||"LEFT"===e?{[o]:t.trigger[o]-t.layer[i]-(t.relativeParent[o]-r[o])-n}:{[o]:t.trigger[o]+t.trigger[i]-(t.relativeParent[o]-r[o])+n}}function getCenter(e,t,r,n,o){return minMax(e.trigger[n]-e.relativeParent[n]+t[n]+e.trigger[o]/2-e.layer[o]/2-r,getLimits(e,t)[n])}function getLimits(e,t){const r=e.trigger.top-e.relativeParent.top+t.top,n=e.trigger.left-e.relativeParent.left+t.left;return{top:{min:r-(e.layer.height-e.arrow.height),max:r+(e.trigger.height-e.arrow.height)},left:{min:n-(e.layer.width-e.arrow.width),max:n+(e.trigger.width-e.arrow.width)}}}function getSecondaryStyle(e,t,r,n,o){if("CENTER"===e){const e="X"===o?"top":"left";return{[e]:getCenter(t,r,n,e,"X"===o?"height":"width")}}const i="TOP"===e||"BOTTOM"===e?"top":"left",s="TOP"===e||"BOTTOM"===e?"height":"width";return"TOP"===e||"LEFT"===e?{[i]:minMax(t.trigger[i]-t.relativeParent[i]+r[i]+n,getLimits(t,r)[i])}:{[i]:minMax(t.trigger[i]+t.trigger[s]-t.layer[s]-(t.relativeParent[i]-r[i])-n,getLimits(t,r)[i])}}function getAbsolutePositions(e){let{anchor:t,rects:r,triggerOffset:n,offsetSecondary:o,scrollLeft:i,scrollTop:s}=e;const l={left:i,top:s};if("CENTER"===t)return{top:getCenter(r,l,0,"top","height"),left:getCenter(r,l,0,"left","width")};const{primary:c,secondary:a}=splitAnchor(t),u=getPrimaryDirection(t);return _extends({},getPrimaryStyle(c,r,l,n),{},getSecondaryStyle(a,r,l,o,u))}function fixLayerDimensions(e,t,r){const n="function"==typeof r?r(getLayerSideByAnchor(t)):r;return _extends({},clientRectToObject(e),{},n)}const propMap={TOP:{side1:"bottom",side2:"top",size:"height",factor:-1},BOTTOM:{side1:"top",side2:"bottom",size:"height",factor:1},LEFT:{side1:"right",side2:"left",size:"width",factor:-1},RIGHT:{side1:"left",side2:"right",size:"width",factor:1}};function getPrimaryRect(e,t,r,n){const{side1:o,side2:i,size:s,factor:l}=propMap[e],c=t[i]+n*l;return{[o]:c,[i]:c+r[s]*l}}function getCenter$1(e,t,r,n,o){const i=e[n]+e[o]/2-t[o]/2-r;return{[n]:i,["left"===n?"right":"bottom"]:i+t[o]}}function getSecondaryRect(e,t,r,n,o){if("CENTER"===e){return getCenter$1(t,r,n,"X"===o?"top":"left","X"===o?"height":"width")}const{side1:i,side2:s,size:l,factor:c}=propMap[e],a=t[s]-n*c;return{[s]:a,[i]:a-r[l]*c}}function getLayerRectByAnchor(e){let t,r,{trigger:n,layer:o,anchor:i,triggerOffset:s,scrollOffset:l=0,offsetSecondary:c=0,layerDimensions:a}=e;const u=a?fixLayerDimensions(o,i,a):o;if("CENTER"===i)t=getCenter$1(n,u,0,"top","height"),r=getCenter$1(n,u,0,"left","width");else{const{primary:e,secondary:o}=splitAnchor(i),l=getPrimaryDirection(i);t=getPrimaryRect(e,n,u,s),r=getSecondaryRect(o,n,u,c,l)}const f=_extends({},u,{},t,{},r);return f.top=f.top-l,f.right=f.right+l,f.left=f.left-l,f.bottom=f.bottom+l,f}const ALL_OFFSET_SIDES=["bottom","top","left","right"];function getLayerOffsetsToParent(e,t){return{top:e.top-t.top,bottom:t.bottom-e.bottom,left:e.left-t.left,right:t.right-e.right}}function getLayerOffsetsToParents(e,t){return t.map(t=>getLayerOffsetsToParent(e,t))}function isLayerCompletelyInvisible(e,t){return t.some(t=>e.bottom<=t.top||e.right<=t.left||e.top>=t.bottom||e.left>=t.right)}function doesEntireLayerFitWithinScrollParents(e,t){return getLayerOffsetsToParents(e,t).every(e=>ALL_OFFSET_SIDES.every(t=>e[t]>=0))}function reduceOffsets(e){const t=e.reduce((e,t)=>(ALL_OFFSET_SIDES.forEach(r=>{e[r]=[...e[r],t[r]]}),e),{top:[],bottom:[],left:[],right:[]});return ALL_OFFSET_SIDES.reduce((e,r)=>(e[r]=t[r].sort((e,t)=>e-t)[0],e),{})}function getNegativeOffsetSides(e){const t=reduceOffsets(e);return ALL_OFFSET_SIDES.filter(e=>t[e]<0)}function getVisibleLayerSurface(e,t){const r=getLayerOffsetsToParent(e,t),{width:n,height:o}=ALL_OFFSET_SIDES.filter(e=>r[e]<0).reduce((e,t)=>{const n="top"===t||"bottom"===t?"height":"width";return _extends({},e,{[n]:e[n]+r[t]})},e),i=n*o;return n<0&&o<0?-i:i}function getVisibleLayerSurfaceWithinScrollParent(e,t){return t.map(t=>getVisibleLayerSurface(e,t)).sort((e,t)=>e-t)[0]}function doesAnchorFitWithinScrollParents(e,t,r,n,o){return doesEntireLayerFitWithinScrollParents(getLayerRectByAnchor({anchor:e,trigger:t.trigger,layer:t.layer,triggerOffset:r,scrollOffset:n,layerDimensions:o}),t.scrollParents)}function getLayerOffsetsToScrollParentsByAnchor(e,t,r,n){return getLayerOffsetsToParents(getLayerRectByAnchor({anchor:e,trigger:t.trigger,layer:t.layer,triggerOffset:r,scrollOffset:n,layerDimensions:null}),t.scrollParents)}function triggerIsBiggerThanLayer(e,t,r){return("top"===e||"bottom"===e)&&r.width>t.width||("left"===e||"right"===e)&&r.height>t.height}function getOffsetSurface(e,t,r,n){const o=getPrimaryDirection(e);return(t["X"===o?"width":"height"]-r-2*n)*(t["X"===o?"height":"width"]-r-2*n)}function findAnchorByLayerSurface(e,t,r,n,o){return t.map(t=>{const i=getLayerRectByAnchor({anchor:t,layer:e.layer,trigger:e.trigger,scrollOffset:n,triggerOffset:r,layerDimensions:o});return{anchor:t,square:getVisibleLayerSurfaceWithinScrollParent(i,e.scrollParents)-getOffsetSurface(t,i,r,n)}}).sort((e,t)=>t.square-e.square)[0].anchor}function findBestSuitableAnchor(e,t,r,n,o){const i=t.find(t=>doesAnchorFitWithinScrollParents(t,e,r,n,o));return i||findAnchorByLayerSurface(e,t,r,n,o)}function getSecondaryOffsetSide(e,t,r,n,o){const i=getPrimaryDirection(e);return getNegativeOffsetSides(getLayerOffsetsToScrollParentsByAnchor(t,r,n,o)).find(e=>"X"===i?"top"===e||"bottom"===e:"left"===e||"right"===e)}function findSecondaryOffset(e,t,r,n,o){const{primary:i}=splitAnchor(e),s=getSecondaryAnchorOptionsByPrimary(i,t),l=0===s.indexOf(e),c=doesAnchorFitWithinScrollParents(e,r,n,o,null);if(l&&c)return 0;const a=getSecondaryOffsetSide(e,s.find(e=>!doesAnchorFitWithinScrollParents(e,r,n,o,null)),r,n,o);if(!a)return 0;let u=-reduceOffsets(getLayerOffsetsToScrollParentsByAnchor(e,r,n,o))[a];const f=triggerIsBiggerThanLayer(getLayerSideByAnchor(e),r.layer,r.trigger),g=e.includes("_CENTER"),d=e.includes("_LEFT"),h=e.includes("_TOP");return f&&(d&&"right"===a||"left"===a||h&&"bottom"===a||"top"===a)?u=-u:f||!g||"top"!==a&&"left"!==a||(u=-u),u}function getOffsets(e,t,r){const n=e.left+e.width/2-t.left-r.width/2,o=e.right-e.width/2-t.right+r.width/2,i=e.top+e.height/2-t.top-r.height/2,s=e.bottom-e.height/2-t.bottom+r.height/2;return{left:n<0?-n:0,right:o>0?-o:0,top:i<0?-i:0,bottom:s>0?-s:0}}function getArrowStyle(e,t,r,n){const o=triggerIsBiggerThanLayer(r,e,t),i={left:{min:n.width/2,max:e.width-n.width/2},top:{min:n.height/2,max:e.height-n.height/2}},s=getOffsets(e,t,n);return"bottom"===r?{bottom:"100%",top:null,left:minMax(o?e.width/2+(s.left+s.right):t.left+t.width/2-e.left,i.left),right:null}:"right"===r?{right:"100%",left:null,top:minMax(o?e.height/2+(s.top+s.bottom):t.top+t.height/2-e.top,i.top),bottom:null}:"top"===r?{top:"100%",bottom:null,left:minMax(o?e.width/2+(s.left+s.right):t.left+t.width/2-e.left,i.left),right:null}:{left:"100%",right:null,top:minMax(o?e.height/2+(s.top+s.bottom):t.top+t.height/2-e.top,i.top),bottom:null}}function getAbsoluteStyle(e){let{rects:t,scrollTop:r,scrollLeft:n,triggerOffset:o,scrollOffset:i,possibleAnchors:s,preferedAnchor:l,preferedX:c,preferedY:a,autoAdjust:u,snapToAnchor:f,layerDimensions:g}=e;const d=getAnchorPriority(l,s,c,a,t),h=u?findBestSuitableAnchor(t,d,o,i,g):l,p=u&&!f&&"CENTER"!==h?findSecondaryOffset(h,d,t,o,i):0,y=getAbsolutePositions({anchor:h,rects:t,triggerOffset:o,offsetSecondary:p,scrollLeft:n,scrollTop:r}),m=getLayerRectByAnchor({anchor:h,trigger:t.trigger,layer:t.layer,triggerOffset:o,offsetSecondary:p,layerDimensions:g});return g&&(y.width=m.width,y.height=m.height),{layerStyle:y,layerRect:m,anchor:h}}function compensateScrollbars(e,t,r){const n=e.width-t,o=e.height-r;return{left:e.left,top:e.top,width:e.width-n,right:e.right-n,height:e.height-o,bottom:e.bottom-o}}function getArrowRect(e,t){const r=e.querySelector("[data-arrow]");if(!r)return{top:0,bottom:0,left:0,right:0,width:0,height:0};const n=r.getBoundingClientRect();return _extends({},clientRectToObject(n),{width:n.width+2*t,height:n.height+2*t})}const defaultPlacement={autoAdjust:!1,snapToAnchor:!1,anchor:"TOP_CENTER",layerDimensions:null,possibleAnchors:POSSIBLE_ANCHORS,preferX:"RIGHT",preferY:"BOTTOM",scrollOffset:10,triggerOffset:0,arrowOffset:0};function getPositioning(e){let{triggerRect:t,layerElement:r,relativeParentElement:n,scrollParents:o,placement:i={},environment:s,fixed:l}=e;if(0===t.height)return;if(!r)return;const c=l?[getWindowClientRect(s)]:[...o.map(e=>compensateScrollbars(e.getBoundingClientRect(),e.clientWidth,e.clientHeight)),getWindowClientRect(s)],a={autoAdjust:i.autoAdjust||defaultPlacement.autoAdjust,snapToAnchor:i.snapToAnchor||defaultPlacement.snapToAnchor,triggerOffset:isSet(i.triggerOffset)?i.triggerOffset:defaultPlacement.triggerOffset,scrollOffset:isSet(i.scrollOffset)?i.scrollOffset:defaultPlacement.scrollOffset,possibleAnchors:i.possibleAnchors||defaultPlacement.possibleAnchors,preferedAnchor:i.anchor||defaultPlacement.anchor,preferedX:i.preferX||defaultPlacement.preferX,preferedY:i.preferY||defaultPlacement.preferY,scrollLeft:n===document.body?0:n.scrollLeft,scrollTop:n===document.body?0:n.scrollTop,relativeParentElement:n,layerDimensions:i.layerDimensions||defaultPlacement.layerDimensions},u=r.getBoundingClientRect(),f={layer:_extends({top:u.top,left:u.left,right:u.right,bottom:u.bottom},getContentBox(r,s)),relativeParent:n.getBoundingClientRect(),scrollParents:c,trigger:t,arrow:getArrowRect(r,i.arrowOffset||defaultPlacement.arrowOffset)},{layerRect:g,layerStyle:d,anchor:h}=getAbsoluteStyle(_extends({rects:f},a));l&&(d.top=g.top,d.left=g.left);const p=getLayerSideByAnchor(h);return{styles:{layer:d,arrow:"CENTER"===h?EMPTY_STYLE:getArrowStyle(g,t,p,f.arrow),layerSide:p},layerRect:g}}function useElementRef(e,t){const[r,n]=useState(e||null),o=useRef(null);return[useCallback(e=>{e&&e!==o.current&&(o.current=e,n(t?t(e):e))},[]),r,o]}function findScrollContainers(e,t){const r=[];if(!e||!t)return r;if(e===document.body)return r;const{overflow:n,overflowX:o,overflowY:i}=t.getComputedStyle(e);return[n,o,i].some(e=>"auto"===e||"scroll"===e)&&r.push(e),[...r,...findScrollContainers(e.parentElement,t)]}function useElementState(e,t,r){return useElementRef({triggerElement:null,relativeParentElement:null,scrollParents:[]},useCallback(n=>{const o=findScrollContainers(n,r),i=o[0]||document.body;if(i===document.body)document.body.style.position="relative";else if("development"===process.env.NODE_ENV&&r){const n="function"==typeof e?e():e,o=r.getComputedStyle(i).position;"relative"!==o&&"absolute"!==o&&"fixed"!==o&&!t&&!n&&console.error("react-laag: Set the 'position' style of the nearest scroll-container to 'relative', 'absolute' or 'fixed', or set the 'fixed' prop to true. This is needed in order to position the layers properly. Currently the scroll-container is positioned: \""+o+'". Visit https://react-laag.com/docs/#position-relative for more info.',i)}return{triggerElement:n,relativeParentElement:i,scrollParents:o}},[]))}function useIsOpen(e,t){const r=useRef(t),n=!r.current&&(isSet(t)?t:e),o=useState(!1)[1];return useEffect(()=>{r.current&&(r.current=!1,o(!0))},[]),n}function ToggleLayer(e){let{children:t,renderLayer:r,placement:n={},onStyle:o,isOpen:i,closeOnOutsideClick:s,onOutsideClick:l,onDisappear:c,closeOnDisappear:a,fixed:u,container:f,environment:g=("undefined"!=typeof window?window:void 0)}=e,d=_objectWithoutPropertiesLoose(e,["children","renderLayer","placement","onStyle","isOpen","closeOnOutsideClick","onOutsideClick","onDisappear","closeOnDisappear","fixed","container","environment"]);const[h,{relativeParentElement:p,triggerElement:y,scrollParents:m},T]=useElementState(f,u,g),{styles:O,setStyles:S,lastStyles:E,resetLastStyles:w}=useStyleState(n.anchor||defaultPlacement.anchor),P=useRef(null),[L,R]=useState(!1),b=useIsOpen(L,i),C=useCallback(()=>{if(!y)throw new Error("Could not find a valid reference of the trigger element. See https://www.react-laag.com/docs/togglelayer/#children for more info.");const e=y.getBoundingClientRect(),t=getPositioning({triggerRect:e,layerElement:P.current,placement:n,relativeParentElement:p,scrollParents:m,fixed:u,environment:g});if(!t)return;const{layerRect:r,styles:s}=t;shouldUpdateStyles(E.current,s)&&(isSet(o)?(E.current=s,o(s.layer,s.arrow,s.layerSide)):S(s));const l=isSet(c),f=a&&!isSet(i);if(l||f){const t=[...m.map(e=>e.getBoundingClientRect()),getWindowClientRect(g)],n=!doesEntireLayerFitWithinScrollParents(u?e:r,t),o=isLayerCompletelyInvisible(u?e:r,t);l?(n||o)&&c(o?"full":"partial"):("partial"===a&&n&&R(!1),"full"===a&&o&&R(!1))}},[p,b,y,m,u,n]),v=useTrackElementResize(d.ResizeObserver,P,y,b,C,g);useIsomorphicLayoutEffect(()=>{const e=!isSet(o);O!==E.current&&e?E.current=O:b?C():w()}),useOnWindowResize(C,g,b),useOnScroll(m,C,g,b);const _=useRef(new Set([P,T]));useOutsideClick(_,useCallback(()=>{b&&(l&&l(),s&&!isSet(i)&&R(!1))},[b,R,i]));const B="function"==typeof f?f():f;return createElement(Fragment,null,t({isOpen:b,close:()=>{if(isSet(i))throw new Error("You cannot call `close()` while using the `isOpen` prop");R(!1)},open:()=>{if(isSet(i))throw new Error("You cannot call `open()` while using the `isOpen` prop");R(!0)},toggle:()=>{if(isSet(i))throw new Error("You cannot call `toggle()` while using the `isOpen` prop");R(!L)},triggerRef:h,layerSide:b?O.layerSide:null}),p&&createElement(OutsideClickGroupProvider,{refs:_},createPortal(r({layerProps:{ref:e=>{e&&v.observe(e),P.current=e},style:_extends({},isSet(o)?EMPTY_STYLE:O.layer,{position:u?"fixed":"absolute",willChange:"top, bottom, left, right, width, height"})},arrowStyle:_extends({},isSet(o)?EMPTY_STYLE:O.arrow,{position:"absolute",willChange:"top, bottom, left, right"}),isOpen:b,layerSide:O.layerSide,triggerRect:y?y.getBoundingClientRect():null,close:()=>{if(isSet(i))throw new Error("You cannot call `close()` while using the `isOpen` prop");R(!1)}}),B||p)))}function getWidthBasedOnAngle(e,t){return Math.tan(e*(Math.PI/180))*t}function getViewBox(e,t,r,n){switch(r){case"bottom":return"0 "+-n+" "+t+" "+e;case"top":return"0 0 "+t+" "+(e+n);case"right":return-n+" 0 "+e+" "+t;case"left":return"0 0 "+(e+n)+" "+t}return""}function getTrianglePath(e){let{sizeA:t,sizeB:r,layerSide:n,roundness:o,angle:i}=e;const s=o/10*t*2,l="bottom"===n?"0 "+t:"top"===n?"0 0":"right"===n?t+" "+r:"0 "+r,c=("bottom"===n||"top"===n?"H":"V")+" "+("bottom"===n||"top"===n?r:0),a=r/2,u=r/2+getWidthBasedOnAngle(i,t/8),f=t/8,g="bottom"===n?"C "+u+" "+f+" "+(a+s)+" 0 "+a+" 0":"top"===n?"C "+u+" "+(t-f)+" "+(a+s)+" "+t+" "+a+" "+t:"right"===n?"C "+f+" "+(r-u)+" 0 "+(a-s)+" 0 "+a:"C "+(t-f)+" "+(r-u)+" "+t+" "+(a-s)+" "+t+" "+a,d=r/2-getWidthBasedOnAngle(i,t/8),h=t/8;return"M "+l+" "+c+" "+g+" "+("bottom"===n?"C "+(a-s)+" 0 "+d+" "+h+" "+l:"top"===n?"C "+(a-s)+" "+t+" "+d+" "+(t-h)+" "+l:"right"===n?"C 0 "+(a+s)+" "+h+" "+(r-d)+" "+l:"C"+t+" "+(a+s)+" "+(t-h)+" "+(r-d)+" "+l)}function getBorderMaskPath(e){let{sizeA:t,sizeB:r,borderWidth:n,layerSide:o,angle:i}=e;const s=getWidthBasedOnAngle(i,n);return"bottom"===o||"top"===o?"M "+n+" "+("bottom"===o?t:0)+" H "+(r-n)+" L "+(r-n-s)+" "+("bottom"===o?t-n:n)+" H "+(s+n)+" Z":"M "+("right"===o?t:0)+" "+n+" V "+(r-n)+" L "+("right"===o?t-n:n)+" "+(r-n-s)+" V "+(s+n)+" Z"}function Arrow(e){let{size:t=8,angle:r=45,borderWidth:n=0,borderColor:o="black",roundness:i=0,backgroundColor:s="white",layerSide:l="top",style:c={}}=e;if("center"===l)return null;const a=t,u=2*getWidthBasedOnAngle(r,t);return createElement("svg",{style:_extends({},c,{transform:"translate"+("left"===l||"right"===l?"Y":"X")+"(-50%)"}),"data-arrow":"true",width:"left"===l||"right"===l?a:u,viewBox:getViewBox(a,u,l,n)},createElement("path",{fill:s,strokeWidth:n,stroke:o,d:getTrianglePath({angle:r,layerSide:l,roundness:i,sizeA:a,sizeB:u})}),createElement("path",{fill:s,d:getBorderMaskPath({sizeA:a,sizeB:u,angle:r,borderWidth:n,layerSide:l})}))}function useToggleLayer(e,t){let r=void 0===t?{}:t,{onStyle:n,closeOnOutsideClick:o,closeOnDisappear:i,fixed:s,container:l,placement:c={},environment:a=("undefined"!=typeof window?window:void 0)}=r,u=_objectWithoutPropertiesLoose(r,["onStyle","closeOnOutsideClick","closeOnDisappear","fixed","container","placement","environment"]);const[f,{relativeParentElement:g,triggerElement:d,scrollParents:h}]=useElementState(l,s,a),{styles:p,setStyles:y,lastStyles:m,resetLastStyles:T}=useStyleState(c.anchor||defaultPlacement.anchor),O=useRef(null),S=useRef(null);function E(){return"function"==typeof S.current?S.current():S.current}const[w,P]=useState(!1);function L(){S.current=null,P(!1)}const R=useCallback(()=>{const e=E();if(!e)return;const t=getPositioning({triggerRect:e,layerElement:O.current,placement:c,relativeParentElement:g,scrollParents:h,fixed:s,environment:a});if(!t)return;const{layerRect:r,styles:o}=t;if(shouldUpdateStyles(m.current,o)&&(isSet(n)?(m.current=o,n(o.layer,o.arrow,o.layerSide)):y(o)),i){const t=[...h.map(e=>e.getBoundingClientRect()),getWindowClientRect(a)],n=!doesEntireLayerFitWithinScrollParents(s?e:r,t),o=isLayerCompletelyInvisible(s?e:r,t);"partial"===i&&n&&L(),"full"===i&&o&&L()}},[g,w,d,h,s,c]),b=useTrackElementResize(u.ResizeObserver,O,d,w,R,a);useIsomorphicLayoutEffect(()=>{const e=!isSet(n);p!==m.current&&e?m.current=p:w?R():T()}),useOnWindowResize(R,a,w),useOnScroll(h,R,a,w);const C=useRef(new Set([O]));useOutsideClick(C,useCallback(()=>{w&&o&&L()},[w,P,o]));const v="function"==typeof l?l():l;function _(e){let{clientRect:t,target:r}=e;S.current=t,w&&r===d?R():(f(r),P(!0))}const B={isOpen:w,close:L,open:_,openFromContextMenuEvent:e=>{e.preventDefault();const t=e.target;_({clientRect:{top:e.clientY,left:e.clientX,bottom:e.clientY+1,right:e.clientX+1,width:1,height:1},target:t})},openFromMouseEvent:e=>{const t=e.currentTarget;if(!t||!t.getBoundingClientRect)return;_({clientRect:()=>t.getBoundingClientRect(),target:t})},openFromRef:e=>{e.current?_({target:e.current,clientRect:e.current.getBoundingClientRect()}):console.error("Error inside useTooltip(): Expected a valid ref to a trigger element, but got "+typeof e.current)},openFromSelection:e=>{if(!e.anchorNode||e.isCollapsed)return;const t=getElementFromAnchorNode(e.anchorNode);if(!t)return;const r=e.getRangeAt(0);_({clientRect:()=>r.getBoundingClientRect(),target:t})},layerSide:w?p.layerSide:null},A=g&&createPortal(e({layerProps:{ref:e=>{e&&b.observe(e),O.current=e},style:_extends({},isSet(n)?EMPTY_STYLE:p.layer,{position:s?"fixed":"absolute",willChange:"top, bottom, left, right, width, height"})},arrowStyle:_extends({},isSet(n)?EMPTY_STYLE:p.arrow,{position:"absolute",willChange:"top, bottom, left, right"}),isOpen:w,layerSide:p.layerSide,triggerRect:E(),close:()=>{L()}}),v||g);return[createElement(OutsideClickGroupProvider,{refs:C},A),B]}function useHover(e){const{delayEnter:t=0,delayLeave:r=0,hideOnScroll:n=!0,onShow:o,onHide:i}=e||{},[s,l]=useState(!1),c=useRef(null),a=useRef(null),u=useRef(!1);function f(e){if(e)return o&&o(),void l(!0);i&&i(),l(!1)}useEffect(()=>{const e=c.current;function t(){c.current&&(clearTimeout(c.current),c.current=null)}function r(){s&&n&&(t(),f(!1))}function o(){s&&(t(),f(!1))}return window.addEventListener("scroll",r,!0),window.addEventListener("touchend",o,!0),()=>{window.removeEventListener("scroll",r,!0),window.removeEventListener("touchend",o,!0),e&&clearTimeout(e)}},[s,n]);const g={onMouseEnter:function(){"leaving"===a.current&&c.current&&(clearTimeout(c.current),c.current=null,a.current=null),s||(a.current="entering",c.current=setTimeout(()=>{f(!0),c.current=null,a.current=null},t))},onMouseLeave:function(){"entering"===a.current&&c.current&&(clearTimeout(c.current),c.current=null),s&&(a.current="leaving",c.current=setTimeout(()=>{f(!1),c.current=null},r))},onTouchStart:()=>{u.current=!1},onTouchMove:()=>{u.current=!0},onTouchEnd:()=>{u.current||s||f(!0),u.current=!1}};return o?g:[s,g]}function useBreakpoint(e){const[t,r]=useState("undefined"!=typeof window&&window.matchMedia("(max-width: "+e+"px)").matches);return useEffect(()=>{const t=window.matchMedia("(max-width: "+e+"px)");function n(e){r(e.matches)}return t.addListener(n),()=>{t.removeListener(n)}},[e]),t}function Transition(e){let{isOpen:t,children:r}=e;const[n,o]=useState({isOpenInternal:t,isLeaving:!1}),i=useRef(!1);return useEffect(()=>{t?o({isOpenInternal:!0,isLeaving:!1}):i.current&&o({isOpenInternal:!1,isLeaving:!0})},[t,o]),useEffect(()=>{i.current=!0},[]),t||n.isOpenInternal||n.isLeaving?r(n.isOpenInternal,()=>{n.isOpenInternal||o(e=>_extends({},e,{isLeaving:!1}))},n.isLeaving):null}function useTooltip(e,t){let r=void 0===t?{}:t,{delayEnter:n,delayLeave:o,hideOnScroll:i}=r,s=_objectWithoutPropertiesLoose(r,["delayEnter","delayLeave","hideOnScroll"]);const l=useRef(),[c,{openFromRef:a,close:u}]=useToggleLayer(e,s),f=useHover({delayEnter:n,delayLeave:o,hideOnScroll:i,onShow:()=>a(l),onHide:u});return[c,_extends({ref:l},f)]}export{ToggleLayer,Arrow,useToggleLayer,Anchor as anchor,useHover,useBreakpoint,Transition,useTooltip};

@@ -1170,3 +1170,3 @@ 'use strict';

}, []);
return [setRef, state];
return [setRef, state, lastElement];
}

@@ -1266,3 +1266,3 @@

scrollParents
}] = useElementState(container, fixed, environment);
}, normalTriggerRef] = useElementState(container, fixed, environment);
const {

@@ -1382,3 +1382,3 @@ styles,

useOnScroll(scrollParents, handlePositioning, environment, isOpen);
const outsideClickRefs = React.useRef(new Set([layerRef, triggerRef])); // handle clicks that are not originated from the trigger / layer
const outsideClickRefs = React.useRef(new Set([layerRef, normalTriggerRef])); // handle clicks that are not originated from the trigger / layer
// element

@@ -1385,0 +1385,0 @@

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

import * as React from "react";
/**

@@ -5,3 +6,3 @@ * Tracks an element and keeps it in state

*/
declare function useElementRef<T = HTMLElement | null>(initialState?: T, elementToState?: (element: HTMLElement) => T): [any, T];
declare function useElementRef<T = HTMLElement | null>(initialState?: T, elementToState?: (element: HTMLElement) => T): [any, T, React.MutableRefObject<HTMLElement | null>];
export default useElementRef;
import { Container } from "./types";
import * as React from "react";
declare type UseElementState = {

@@ -7,3 +8,3 @@ triggerElement: HTMLElement | null;

};
export default function useElementState(container: Container | undefined, fixed: boolean | undefined, environment?: Window): [any, UseElementState];
export default function useElementState(container: Container | undefined, fixed: boolean | undefined, environment?: Window): [any, UseElementState, React.MutableRefObject<HTMLElement | null>];
export {};
{
"name": "react-laag",
"version": "1.7.0",
"version": "1.7.1",
"description": "",

@@ -5,0 +5,0 @@ "author": "Erik Verweij",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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