Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-presence

Package Overview
Dependencies
Maintainers
5
Versions
133
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.7 to 0.0.8

2

dist/index.js

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

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);function u(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,u=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(r=(i=a.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){u=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(u)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return o(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var i=function(e){var n=e.present,o=e.children,i=function(e){var n=u(r.useState(),2),t=n[0],o=n[1],i=u(r.useState(),2),f=i[0],c=i[1],s=r.useRef(e),l=r.useRef(),d=u(function(e,n){return r.useReducer((function(e,t){var r=n[e][t];return null!=r?r:e}),e)}(e?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}}),2),m=d[0],v=d[1];return r.useEffect((function(){if(t){var e=getComputedStyle(t);l.current=a(e),c(e)}}),[t]),r.useEffect((function(){var n=s.current;if(n!==e){var t=l.current,r=a(f);if(l.current=r,e)v("MOUNT");else if("none"===(null==f?void 0:f.display))v("UNMOUNT");else{v(n&&t!==r?"ANIMATION_OUT":"UNMOUNT")}s.current=e}}),[e,f,v]),r.useEffect((function(){if(t){var e=function(e){var n=a(f),r=e.animationName===n;e.target===t&&r&&v("ANIMATION_END")};return t.addEventListener("animationcancel",e),t.addEventListener("animationend",e),function(){t.removeEventListener("animationcancel",e),t.removeEventListener("animationend",e)}}}),[t,e,f,v]),{ref:function(e){return o(e)},isPresent:["mounted","unmountSuspended"].includes(m)}}(n),f="function"==typeof o?o({present:i.isPresent}):r.Children.only(o),c=t(i.ref,f.ref);return"function"==typeof o||i.isPresent?r.cloneElement(f,{ref:c}):null};function a(e){return(null==e?void 0:e.animationName)||"none"}exports.Presence=i,i.displayName="Presence";
var e=require("@radix-ui/react-compose-refs").useComposedRefs,n=require("react"),t=n.Children,r=n.cloneElement,u=n.useState,o=n.useRef,s=n.useEffect,c=n.useCallback,i=n.useReducer;const a=n=>{const{present:a,children:m}=n,f=function(e){const[n,t]=u(),r=o({}),a=o(e),m=o(),f=e?"mounted":"unmounted",[N,l]=function(e,n){return i(((e,t)=>n[e][t]??e),e)}(f,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s((()=>{const n=r.current,t=a.current;if(t!==e){const r=m.current,u=d(n);if(e)l("MOUNT");else if("none"===u||"none"===n?.display)l("UNMOUNT");else{const e=r!==u;l(t&&e?"ANIMATION_OUT":"UNMOUNT")}a.current=e}}),[e,l]),s((()=>{if(n){const e=e=>{const t=d(r.current),u=e.animationName===t;e.target===n&&u&&(m.current=d(r.current),l("ANIMATION_END"))};return n.addEventListener("animationcancel",e),n.addEventListener("animationend",e),()=>{n.removeEventListener("animationcancel",e),n.removeEventListener("animationend",e)}}}),[n,l]),{isPresent:["mounted","unmountSuspended"].includes(N),ref:c((e=>{e&&(r.current=getComputedStyle(e),t(e))}),[])}}(a),N="function"==typeof m?m({present:f.isPresent}):t.only(m),l=e(f.ref,N.ref);return"function"==typeof m||f.isPresent?r(N,{ref:l}):null};function d(e){return e?.animationName||"none"}var m,f,N;exports.Presence=a,a.displayName="Presence",m={},f="Presence",N=function(){return a},Object.defineProperty(m,f,{get:N,enumerable:!0});
//# sourceMappingURL=index.js.map

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

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

@@ -5,0 +5,0 @@ "source": "src/index.ts",

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