@bothub-chat/ui
Version:
Bothub UI Components
2 lines (1 loc) • 895 B
JavaScript
import{__rest as r}from"tslib";import{jsx as e}from"react/jsx-runtime";import{useRef as o,useCallback as t,useEffect as l}from"react";import{useTransition as n}from"@react-spring/web";import{BackdropStyled as c}from"./styled.js";const i=i=>{var{open:b,onClick:a,children:d}=i,s=r(i,["open","onClick","children"]);const m=o(null),p=t((r=>{r.target===m.current&&(null==a||a(r))}),[a,m]);l((()=>(b?document.body.style.overflow="hidden":document.body.style.removeProperty("overflow"),()=>{document.body.style.removeProperty("overflow")})),[b]);return n(b,{from:{background:"rgba(0, 0, 0, 0)",backdropFilter:"blur(0px)"},enter:{background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(5px)"},leave:{background:"rgba(0, 0, 0, 0)",backdropFilter:"blur(0px)"}})(((r,o)=>o&&e(c,Object.assign({},s,{ref:m,onClick:p,style:Object.assign(Object.assign({},r),s.style||{}),children:d}))))};export{i as Backdrop};