10 lines
57 KiB
JavaScript
10 lines
57 KiB
JavaScript
|
import{_extends,_objectWithoutPropertiesLoose,lightenColor,newStyled,require_react,require_react_dom,scope}from"./chunk-B3YDJJJH.js";import{__commonJS2 as __commonJS,__toESM,__toESM2,require_memoizerific}from"./chunk-ZR5JZWHI.js";var React3=__toESM(require_react(),1),import_react=__toESM(require_react(),1),ReactDOM=__toESM(require_react_dom(),1),import_react_dom=__toESM(require_react_dom(),1);var import_memoizerific=__toESM(require_memoizerific(),1),require_react_fast_compare=__commonJS({"../../node_modules/react-fast-compare/index.js"(exports,module){var hasElementType=typeof Element<"u",hasMap=typeof Map=="function",hasSet=typeof Set=="function",hasArrayBuffer=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function equal(a,b){if(a===b)return!0;if(a&&b&&typeof a=="object"&&typeof b=="object"){if(a.constructor!==b.constructor)return!1;var length,i,keys;if(Array.isArray(a)){if(length=a.length,length!=b.length)return!1;for(i=length;i--!==0;)if(!equal(a[i],b[i]))return!1;return!0}var it;if(hasMap&&a instanceof Map&&b instanceof Map){if(a.size!==b.size)return!1;for(it=a.entries();!(i=it.next()).done;)if(!b.has(i.value[0]))return!1;for(it=a.entries();!(i=it.next()).done;)if(!equal(i.value[1],b.get(i.value[0])))return!1;return!0}if(hasSet&&a instanceof Set&&b instanceof Set){if(a.size!==b.size)return!1;for(it=a.entries();!(i=it.next()).done;)if(!b.has(i.value[0]))return!1;return!0}if(hasArrayBuffer&&ArrayBuffer.isView(a)&&ArrayBuffer.isView(b)){if(length=a.length,length!=b.length)return!1;for(i=length;i--!==0;)if(a[i]!==b[i])return!1;return!0}if(a.constructor===RegExp)return a.source===b.source&&a.flags===b.flags;if(a.valueOf!==Object.prototype.valueOf&&typeof a.valueOf=="function"&&typeof b.valueOf=="function")return a.valueOf()===b.valueOf();if(a.toString!==Object.prototype.toString&&typeof a.toString=="function"&&typeof b.toString=="function")return a.toString()===b.toString();if(keys=Object.keys(a),length=keys.length,length!==Object.keys(b).length)return!1;for(i=length;i--!==0;)if(!Object.prototype.hasOwnProperty.call(b,keys[i]))return!1;if(hasElementType&&a instanceof Element)return!1;for(i=length;i--!==0;)if(!((keys[i]==="_owner"||keys[i]==="__v"||keys[i]==="__o")&&a.$$typeof)&&!equal(a[keys[i]],b[keys[i]]))return!1;return!0}return a!==a&&b!==b}module.exports=function(a,b){try{return equal(a,b)}catch(error){if((error.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw error}}}}),fromEntries=function(entries){return entries.reduce(function(acc,_ref){var key=_ref[0],value=_ref[1];return acc[key]=value,acc},{})},useIsomorphicLayoutEffect=typeof window<"u"&&window.document&&window.document.createElement?React3.useLayoutEffect:React3.useEffect,top="top",bottom="bottom",right="right",left="left",auto="auto",basePlacements=[top,bottom,right,left],start="start",end="end",clippingParents="clippingParents",viewport="viewport",popper="popper",reference="reference",variationPlacements=basePlacements.reduce(function(acc,placement){return acc.concat([placement+"-"+start,placement+"-"+end])},[]),placements=[].concat(basePlacements,[auto]).reduce(function(acc,placement){return acc.concat([placement,placement+"-"+start,placement+"-"+end])},[]),beforeRead="beforeRead",read="read",afterRead="afterRead",beforeMain="beforeMain",main="main",afterMain="afterMain",beforeWrite="beforeWrite",write="write",afterWrite="afterWrite",modifierPhases=[beforeRead,read,afterRead,beforeMain,main,afterMain,beforeWrite,write,afterWrite];function getNodeName(element){return element?(element.nodeName||"").toLowerCase():null}function getWindow(node){if(node==null)return window;if(node.toString()!=="[object Window]"){var ownerDocument=node.ownerDocument;return ownerDocument&&ownerDocument.defaultView||window}return node}function isElement(node){var OwnElement=getWindow(node).Element;return node instanceof OwnElement||node instanceof Element}function isHTMLElement(node){var OwnElement=getWindow(node).HTMLElement;return node instanceof OwnElement||node instanceof HTMLElement}function isShadow
|
||
|
drop-shadow(0px 5px 5px rgba(0,0,0,0.05))
|
||
|
drop-shadow(0 1px 3px rgba(0,0,0,0.1))
|
||
|
`,borderRadius:theme.appBorderRadius,fontSize:theme.typography.size.s1}:{}),Tooltip=import_react.default.forwardRef(({placement="top",hasChrome=!0,children,arrowProps={},tooltipRef,color,withArrows,...props},ref)=>import_react.default.createElement(Wrapper,{"data-testid":"tooltip",hasChrome,ref,...props,color},hasChrome&&withArrows&&import_react.default.createElement(Arrow,{placement,...arrowProps,color}),children));Tooltip.displayName="Tooltip";var{document:document2}=scope,TargetContainer=newStyled.div`
|
||
|
display: inline-block;
|
||
|
cursor: ${props=>props.trigger==="hover"||props.trigger.includes("hover")?"default":"pointer"};
|
||
|
`,TargetSvgContainer=newStyled.g`
|
||
|
cursor: ${props=>props.trigger==="hover"||props.trigger.includes("hover")?"default":"pointer"};
|
||
|
`,WithTooltipPure=({svg=!1,trigger="click",closeOnOutsideClick=!1,placement="top",modifiers=[{name:"preventOverflow",options:{padding:8}},{name:"offset",options:{offset:[8,8]}},{name:"arrow",options:{padding:8}}],hasChrome=!0,defaultVisible=!1,withArrows,offset:offset2,tooltip,children,closeOnTriggerHidden,mutationObserverOptions,delayHide,visible,interactive,delayShow,strategy,followCursor,onVisibleChange,...props})=>{let Container=svg?TargetSvgContainer:TargetContainer,{getArrowProps,getTooltipProps,setTooltipRef,setTriggerRef,visible:isVisible,state}=usePopperTooltip({trigger,placement,defaultVisible,delayHide,interactive,closeOnOutsideClick,closeOnTriggerHidden,onVisibleChange,delayShow,followCursor,mutationObserverOptions,visible,offset:offset2},{modifiers,strategy}),tooltipComponent=import_react.default.createElement(Tooltip,{placement:state?.placement,ref:setTooltipRef,hasChrome,arrowProps:getArrowProps(),withArrows,...getTooltipProps()},typeof tooltip=="function"?tooltip({onHide:()=>onVisibleChange(!1)}):tooltip);return import_react.default.createElement(import_react.default.Fragment,null,import_react.default.createElement(Container,{trigger,ref:setTriggerRef,...props},children),isVisible&&import_react_dom.default.createPortal(tooltipComponent,document2.body))},WithToolTipState=({startOpen=!1,onVisibleChange:onChange,...rest})=>{let[tooltipShown,setTooltipShown]=(0,import_react.useState)(startOpen),onVisibilityChange=(0,import_react.useCallback)(visibility=>{onChange&&onChange(visibility)===!1||setTooltipShown(visibility)},[onChange]);return(0,import_react.useEffect)(()=>{let hide2=()=>onVisibilityChange(!1);document2.addEventListener("keydown",hide2,!1);let iframes=Array.from(document2.getElementsByTagName("iframe")),unbinders=[];return iframes.forEach(iframe=>{let bind=()=>{try{iframe.contentWindow.document&&(iframe.contentWindow.document.addEventListener("click",hide2),unbinders.push(()=>{try{iframe.contentWindow.document.removeEventListener("click",hide2)}catch{}}))}catch{}};bind(),iframe.addEventListener("load",bind),unbinders.push(()=>{iframe.removeEventListener("load",bind)})}),()=>{document2.removeEventListener("keydown",hide2),unbinders.forEach(unbind=>{unbind()})}}),import_react.default.createElement(WithTooltipPure,{...rest,visible:tooltipShown,onVisibleChange:onVisibilityChange})};export{WithTooltipPure,WithToolTipState};
|