@radix-ui/react-presence
Advanced tools
Comparing version 0.1.1 to 0.1.2-rc.1
@@ -1,2 +0,2 @@ | ||
var e,n,t=require("@radix-ui/react-use-layout-effect").useLayoutEffect,r=require("@radix-ui/react-compose-refs").useComposedRefs,u=(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 o=e=>{const{present:n,children:o}=e,i=function(e){const[n,r]=u.useState(),o=u.useRef({}),i=u.useRef(e),c=u.useRef("none"),a=e?"mounted":"unmounted",[d,m]=function(e,n){return u.useReducer(((e,t)=>{const r=n[e][t];return null!=r?r:e}),e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect((()=>{const e=s(o.current);c.current="mounted"===d?e:"none"}),[d]),t((()=>{const n=o.current,t=i.current;if(t!==e){const r=c.current,u=s(n);if(e)m("MOUNT");else if("none"===u||"none"===(null==n?void 0:n.display))m("UNMOUNT");else{const e=r!==u;m(t&&e?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,m]),t((()=>{if(n){const e=e=>{const t=s(o.current).includes(e.animationName);e.target===n&&t&&m("ANIMATION_END")},t=e=>{e.target===n&&(c.current=s(o.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,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:u.useCallback((e=>{e&&(o.current=getComputedStyle(e)),r(e)}),[])}}(n),c="function"==typeof o?o({present:i.isPresent}):u.Children.only(o),a=r(i.ref,c.ref);return"function"==typeof o||i.isPresent?/*#__PURE__*/u.cloneElement(c,{ref:a}):null};function s(e){return(null==e?void 0:e.animationName)||"none"}exports.Presence=o,o.displayName="Presence"; | ||
var e,n,t=require("@radix-ui/react-use-layout-effect").useLayoutEffect,r=require("@radix-ui/react-compose-refs").useComposedRefs,u=(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 o=e=>{const{present:n,children:o}=e,i=function(e){const[n,r]=u.useState(),o=u.useRef({}),i=u.useRef(e),c=u.useRef("none"),a=e?"mounted":"unmounted",[d,m]=function(e,n){return u.useReducer(((e,t)=>{const r=n[e][t];return null!=r?r:e}),e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect((()=>{const e=s(o.current);c.current="mounted"===d?e:"none"}),[d]),t((()=>{const n=o.current,t=i.current;if(t!==e){const r=c.current,u=s(n);if(e)m("MOUNT");else if("none"===u||"none"===(null==n?void 0:n.display))m("UNMOUNT");else{const e=r!==u;m(t&&e?"ANIMATION_OUT":"UNMOUNT")}i.current=e}}),[e,m]),t((()=>{if(n){const e=e=>{const t=s(o.current).includes(e.animationName);e.target===n&&t&&m("ANIMATION_END")},t=e=>{e.target===n&&(c.current=s(o.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)}}m("ANIMATION_END")}),[n,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:u.useCallback((e=>{e&&(o.current=getComputedStyle(e)),r(e)}),[])}}(n),c="function"==typeof o?o({present:i.isPresent}):u.Children.only(o),a=r(i.ref,c.ref);return"function"==typeof o||i.isPresent?/*#__PURE__*/u.cloneElement(c,{ref:a}):null};function s(e){return(null==e?void 0:e.animationName)||"none"}exports.Presence=o,o.displayName="Presence"; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{useLayoutEffect as e}from"@radix-ui/react-use-layout-effect";import{useComposedRefs as n}from"@radix-ui/react-compose-refs";import*as t from"react";export const Presence=u=>{const{present:o,children:i}=u,s=function(n){const[u,o]=t.useState(),i=t.useRef({}),s=t.useRef(n),c=t.useRef("none"),a=n?"mounted":"unmounted",[d,m]=function(e,n){return t.useReducer(((e,t)=>{const r=n[e][t];return null!=r?r:e}),e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return t.useEffect((()=>{const e=r(i.current);c.current="mounted"===d?e:"none"}),[d]),e((()=>{const e=i.current,t=s.current;if(t!==n){const u=c.current,o=r(e);if(n)m("MOUNT");else if("none"===o||"none"===(null==e?void 0:e.display))m("UNMOUNT");else{const e=u!==o;m(t&&e?"ANIMATION_OUT":"UNMOUNT")}s.current=n}}),[n,m]),e((()=>{if(u){const e=e=>{const n=r(i.current).includes(e.animationName);e.target===u&&n&&m("ANIMATION_END")},n=e=>{e.target===u&&(c.current=r(i.current))};return u.addEventListener("animationstart",n),u.addEventListener("animationcancel",e),u.addEventListener("animationend",e),()=>{u.removeEventListener("animationstart",n),u.removeEventListener("animationcancel",e),u.removeEventListener("animationend",e)}}}),[u,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:t.useCallback((e=>{e&&(i.current=getComputedStyle(e)),o(e)}),[])}}(o),c="function"==typeof i?i({present:s.isPresent}):t.Children.only(i),a=n(s.ref,c.ref);return"function"==typeof i||s.isPresent?/*#__PURE__*/t.cloneElement(c,{ref:a}):null};function r(e){return(null==e?void 0:e.animationName)||"none"}Presence.displayName="Presence"; | ||
import{useLayoutEffect as e}from"@radix-ui/react-use-layout-effect";import{useComposedRefs as n}from"@radix-ui/react-compose-refs";import*as t from"react";export const Presence=u=>{const{present:o,children:i}=u,s=function(n){const[u,o]=t.useState(),i=t.useRef({}),s=t.useRef(n),c=t.useRef("none"),a=n?"mounted":"unmounted",[d,m]=function(e,n){return t.useReducer(((e,t)=>{const r=n[e][t];return null!=r?r:e}),e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return t.useEffect((()=>{const e=r(i.current);c.current="mounted"===d?e:"none"}),[d]),e((()=>{const e=i.current,t=s.current;if(t!==n){const u=c.current,o=r(e);if(n)m("MOUNT");else if("none"===o||"none"===(null==e?void 0:e.display))m("UNMOUNT");else{const e=u!==o;m(t&&e?"ANIMATION_OUT":"UNMOUNT")}s.current=n}}),[n,m]),e((()=>{if(u){const e=e=>{const n=r(i.current).includes(e.animationName);e.target===u&&n&&m("ANIMATION_END")},n=e=>{e.target===u&&(c.current=r(i.current))};return u.addEventListener("animationstart",n),u.addEventListener("animationcancel",e),u.addEventListener("animationend",e),()=>{u.removeEventListener("animationstart",n),u.removeEventListener("animationcancel",e),u.removeEventListener("animationend",e)}}m("ANIMATION_END")}),[u,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:t.useCallback((e=>{e&&(i.current=getComputedStyle(e)),o(e)}),[])}}(o),c="function"==typeof i?i({present:s.isPresent}):t.Children.only(i),a=n(s.ref,c.ref);return"function"==typeof i||s.isPresent?/*#__PURE__*/t.cloneElement(c,{ref:a}):null};function r(e){return(null==e?void 0:e.animationName)||"none"}Presence.displayName="Presence"; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@radix-ui/react-presence", | ||
"version": "0.1.1", | ||
"version": "0.1.2-rc.1", | ||
"license": "MIT", | ||
@@ -33,3 +33,4 @@ "source": "src/index.ts", | ||
"url": "https://github.com/radix-ui/primitives/issues" | ||
} | ||
}, | ||
"stableVersion": "0.1.1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24576