UNPKG

amotify

Version:

UI Component for React,NextJS,esbuild

2 lines (1 loc) 1.71 kB
import{b as p,d as y}from"../chunk-C5N2D3ZX.js";import{jsx as s,jsxs as S}from"react/jsx-runtime";import{useState as h,useEffect as f}from"react";import a,{useStore as w,UUID as d}from"jmini";import{Box as g,FAI as D}from"../atoms";import{Row as A}from"../mols";import{Button as I}from"./Button";import u from"./Sheet";const r={__memoryID:d(),open:o=>{let n=o,{tipsID:e=d(),tipsGroups:t=[]}=n,i=y(n,["tipsID","tipsGroups"]);u.open("custom",p({sheetID:e,props:{tipsID:e},sheetGroups:["tooltips",...t],closeAtAroundClick:!0,closeAtParentBlur:!0,closeAtEscapeKeyDown:!0,closeAtPageTransit:!0},i))},close:o=>{o&&u.close(o)},closeALL:()=>{u.closeGroup("tooltips")},notice:(o,e)=>{let t=(e==null?void 0:e.tipsID)||d();r.open({tipsID:t,parent:document.body,gravityPoint:18,hold_state:!1,closeAtAroundClick:!1,closeAtParentBlur:!1,paddingBottom:"1/2",content:()=>{f(()=>{let m="resize_event-"+t;return a(window).onEvent("resize",()=>{a.interval.once(()=>{var l,v;(v=(l=w.get("customSheet-"+t))==null?void 0:l.reposition)==null||v.call(l)},50)},{eventID:m}),()=>{a(window).removeEvent(m)}},[]);let i=(e==null?void 0:e.closeToSeconds)||5,[n,c]=h(i);return f(()=>{a.interval.once(()=>{n>0&&c(n-1),n==0&&r.close(t)},1e3,"notice_countDown-"+t)},[n]),s(r.Body,{borderRadius:"2.tone.secondary",padding:"1/2",onMouseOver:()=>{c(-1)},onMouseLeave:()=>{c(i)},children:S(A.Separate,{children:[s(g,{padding:[0,"1/2"],xcss:{minWidth:"20vw",maxWidth:"60vw"},children:o}),s(I.Clear,{color:"white",ssSphere:2.5,onClick:()=>{r.close(t)},children:s(D.X,{})})]})})}})},Body:o=>s(g,p({padding:"1/2",backgroundColor:"dark",borderRadius:"2.tone.secondary",fontColor:"white",boxShadow:"1.remark"},o))};export{r as Tooltips,r as default};