Socket
Socket
Sign inDemoInstall

@radix-ui/react-presence

Package Overview
Dependencies
Maintainers
5
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-presence - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

2

dist/index.js

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

var e=require("@radix-ui/react-compose-refs").useComposedRefs,n=require("react"),t=n.Children,r=n.cloneElement,u=n.useState,o=n.useRef,i=n.useEffect,s=n.useCallback,c=n.useReducer;const a=n=>{const{present:a,children:m}=n,l=function(e){const[n,t]=u(),r=o({}),a=o(e),m=o(),l=e?"mounted":"unmounted",[f,N]=function(e,n){return c(((e,t)=>{const r=n[e][t];return null!=r?r:e}),e)}(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i((()=>{const n=r.current,t=a.current;if(t!==e){const r=m.current,u=d(n);if(e)N("MOUNT");else if("none"===u||"none"===(null==n?void 0:n.display))N("UNMOUNT");else{const e=r!==u;N(t&&e?"ANIMATION_OUT":"UNMOUNT")}a.current=e}}),[e,N]),i((()=>{if(n){const e=e=>{const t=d(r.current).includes(e.animationName);e.target===n&&t&&N("ANIMATION_END")},t=e=>{e.target===n&&(m.current=d(r.current))};return n.addEventListener("animationstart",t),n.addEventListener("animationcancel",e),n.addEventListener("animationend",e),()=>{n.removeEventListener("animationstart",t),n.removeEventListener("animationcancel",e),n.removeEventListener("animationend",e)}}}),[n,N]),{isPresent:["mounted","unmountSuspended"].includes(f),ref:s((e=>{e&&(r.current=getComputedStyle(e),t(e))}),[])}}(a),f="function"==typeof m?m({present:l.isPresent}):t.only(m),N=e(l.ref,f.ref);return"function"==typeof m||l.isPresent?r(f,{ref:N}):null};function d(e){return(null==e?void 0:e.animationName)||"none"}var m,l,f;exports.Presence=a,a.displayName="Presence",m={},l="Presence",f=function(){return a},Object.defineProperty(m,l,{get:f,enumerable:!0});
var e,n,t=require("@radix-ui/react-compose-refs").useComposedRefs,r=(e={},n=require("react"),Object.keys(n).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),e);const u=e=>{const{present:n,children:u}=e,s=function(e){const[n,t]=r.useState(),u=r.useRef({}),s=r.useRef(e),i=r.useRef(),c=e?"mounted":"unmounted",[a,d]=function(e,n){return r.useReducer(((e,t)=>{const r=n[e][t];return null!=r?r:e}),e)}(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const n=u.current,t=s.current;if(t!==e){const r=i.current,u=o(n);if(e)d("MOUNT");else if("none"===u||"none"===(null==n?void 0:n.display))d("UNMOUNT");else{const e=r!==u;d(t&&e?"ANIMATION_OUT":"UNMOUNT")}s.current=e}}),[e,d]),r.useEffect((()=>{if(n){const e=e=>{const t=o(u.current).includes(e.animationName);e.target===n&&t&&d("ANIMATION_END")},t=e=>{e.target===n&&(i.current=o(u.current))};return n.addEventListener("animationstart",t),n.addEventListener("animationcancel",e),n.addEventListener("animationend",e),()=>{n.removeEventListener("animationstart",t),n.removeEventListener("animationcancel",e),n.removeEventListener("animationend",e)}}}),[n,d]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:r.useCallback((e=>{e&&(u.current=getComputedStyle(e),t(e))}),[])}}(n),i="function"==typeof u?u({present:s.isPresent}):r.Children.only(u),c=t(s.ref,i.ref);return"function"==typeof u||s.isPresent?r.cloneElement(i,{ref:c}):null};function o(e){return(null==e?void 0:e.animationName)||"none"}exports.Presence=u,u.displayName="Presence";
//# sourceMappingURL=index.js.map

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

import{useComposedRefs as e}from"@radix-ui/react-compose-refs";import{Children as n,cloneElement as t,useState as r,useRef as o,useEffect as u,useCallback as i,useReducer as s}from"react";var c,a,d;export const Presence=c=>{const{present:a,children:d}=c,N=function(e){const[n,t]=r(),c=o({}),a=o(e),d=o(),N=e?"mounted":"unmounted",[f,l]=function(e,n){return s(((e,t)=>{const r=n[e][t];return null!=r?r:e}),e)}(N,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u((()=>{const n=c.current,t=a.current;if(t!==e){const r=d.current,o=m(n);if(e)l("MOUNT");else if("none"===o||"none"===(null==n?void 0:n.display))l("UNMOUNT");else{const e=r!==o;l(t&&e?"ANIMATION_OUT":"UNMOUNT")}a.current=e}}),[e,l]),u((()=>{if(n){const e=e=>{const t=m(c.current).includes(e.animationName);e.target===n&&t&&l("ANIMATION_END")},t=e=>{e.target===n&&(d.current=m(c.current))};return n.addEventListener("animationstart",t),n.addEventListener("animationcancel",e),n.addEventListener("animationend",e),()=>{n.removeEventListener("animationstart",t),n.removeEventListener("animationcancel",e),n.removeEventListener("animationend",e)}}}),[n,l]),{isPresent:["mounted","unmountSuspended"].includes(f),ref:i((e=>{e&&(c.current=getComputedStyle(e),t(e))}),[])}}(a),f="function"==typeof d?d({present:N.isPresent}):n.only(d),l=e(N.ref,f.ref);return"function"==typeof d||N.isPresent?t(f,{ref:l}):null};function m(e){return(null==e?void 0:e.animationName)||"none"}Presence.displayName="Presence",c={},a="Presence",d=function(){return Presence},Object.defineProperty(c,a,{get:d,enumerable:!0});
import{useComposedRefs as e}from"@radix-ui/react-compose-refs";import*as n from"react";export const Presence=r=>{const{present:u,children:o}=r,s=function(e){const[r,u]=n.useState(),o=n.useRef({}),s=n.useRef(e),i=n.useRef(),c=e?"mounted":"unmounted",[a,d]=function(e,t){return n.useReducer(((e,n)=>{const r=t[e][n];return null!=r?r:e}),e)}(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return n.useEffect((()=>{const n=o.current,r=s.current;if(r!==e){const u=i.current,o=t(n);if(e)d("MOUNT");else if("none"===o||"none"===(null==n?void 0:n.display))d("UNMOUNT");else{const e=u!==o;d(r&&e?"ANIMATION_OUT":"UNMOUNT")}s.current=e}}),[e,d]),n.useEffect((()=>{if(r){const e=e=>{const n=t(o.current).includes(e.animationName);e.target===r&&n&&d("ANIMATION_END")},n=e=>{e.target===r&&(i.current=t(o.current))};return r.addEventListener("animationstart",n),r.addEventListener("animationcancel",e),r.addEventListener("animationend",e),()=>{r.removeEventListener("animationstart",n),r.removeEventListener("animationcancel",e),r.removeEventListener("animationend",e)}}}),[r,d]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:n.useCallback((e=>{e&&(o.current=getComputedStyle(e),u(e))}),[])}}(u),i="function"==typeof o?o({present:s.isPresent}):n.Children.only(o),c=e(s.ref,i.ref);return"function"==typeof o||s.isPresent?n.cloneElement(i,{ref:c}):null};function t(e){return(null==e?void 0:e.animationName)||"none"}Presence.displayName="Presence";
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-presence",
"version": "0.0.11",
"version": "0.0.12",
"license": "MIT",

@@ -21,3 +21,3 @@ "source": "src/index.ts",

"@babel/runtime": "^7.13.10",
"@radix-ui/react-compose-refs": "0.0.3"
"@radix-ui/react-compose-refs": "0.0.4"
},

@@ -24,0 +24,0 @@ "peerDependencies": {

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