@radix-ui/react-presence
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -1,2 +0,2 @@ | ||
var n,e,t=require("@radix-ui/react-compose-refs").useComposedRefs,r=(n={},e=require("react"),Object.keys(e).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(n,t,{enumerable:!0,get:function(){return e[t]}})})),n);function i(n,e){return function(n){if(Array.isArray(n))return n}(n)||function(n,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(n)))return;var t=[],r=!0,i=!1,u=void 0;try{for(var o,a=n[Symbol.iterator]();!(r=(o=a.next()).done)&&(t.push(o.value),!e||t.length!==e);r=!0);}catch(n){i=!0,u=n}finally{try{r||null==a.return||a.return()}finally{if(i)throw u}}return t}(n,e)||function(n,e){if(!n)return;if("string"==typeof n)return u(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);"Object"===t&&n.constructor&&(t=n.constructor.name);if("Map"===t||"Set"===t)return Array.from(n);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(n,e)}(n,e)||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 u(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}var o=function(n){var e=n.present,u=n.children,o=function(n){var e=i(r.useState(),2),t=e[0],u=e[1],o=i(r.useState(),2),c=o[0],f=o[1],s=r.useRef(n),d=r.useRef(),m=i(function(n,e){return r.useReducer((function(n,t){var r=e[n][t];return null!=r?r:n}),n)}(n?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended",TRANSITION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted",TRANSITION_END:"unmounted"},unmounted:{MOUNT:"mounted"}}),2),l=m[0],v=m[1];return r.useEffect((function(){if(t){var n=getComputedStyle(t);d.current=a(n),f(n)}}),[t]),r.useEffect((function(){var e=s.current;if(e!==n)return function(){var n,e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},r=requestAnimationFrame((function(){n=requestAnimationFrame((function(){e=requestAnimationFrame(t)}))}));return function(){cancelAnimationFrame(r),cancelAnimationFrame(n),cancelAnimationFrame(e)}}((function(){var t=d.current,r=a(c);if(d.current=r,n)v("MOUNT");else if("none"===(null==c?void 0:c.display))v("UNMOUNT");else{v(e&&t!==r?"ANIMATION_OUT":"UNMOUNT")}s.current=n}))}),[n,c,v]),r.useEffect((function(){if(t){var e=function(n){var e=a(c),r=n.animationName===e;n.target===t&&r&&v("ANIMATION_END")},r=function(e){n||e.target!==t||v("TRANSITION_OUT")},i=function(n){n.target===t&&v("TRANSITION_END")};return t.addEventListener("animationcancel",e),t.addEventListener("animationend",e),t.addEventListener("transitionrun",r),t.addEventListener("transitioncancel",i),t.addEventListener("transitionend",i),function(){t.removeEventListener("animationcancel",e),t.removeEventListener("animationend",e),t.removeEventListener("transitionrun",r),t.removeEventListener("transitioncancel",i),t.removeEventListener("transitionend",i)}}}),[t,n,c,v]),{ref:function(n){return u(n)},isPresent:["mounted","unmountSuspended"].includes(l)}}(e),c="function"==typeof u?u({present:o.isPresent}):r.Children.only(u),f=t(o.ref,c.ref);return"function"==typeof u||o.isPresent?r.cloneElement(c,{ref:f}):null};function a(n){return(null==n?void 0:n.animationName)||"none"}exports.Presence=o,o.displayName="Presence"; | ||
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"; | ||
//# 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=r=>{const{present:i,children:o}=r,u=function(e){const[r,i]=n.useState(),[o,u]=n.useState(),s=n.useRef(e),a=n.useRef(),c=e?"mounted":"unmounted",[m,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",TRANSITION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted",TRANSITION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return n.useEffect((()=>{if(r){const e=getComputedStyle(r);a.current=t(e),u(e)}}),[r]),n.useEffect((()=>{const n=s.current;if(n!==e)return function(e=(()=>{})){let n,t;const r=requestAnimationFrame((()=>{n=requestAnimationFrame((()=>{t=requestAnimationFrame(e)}))}));return()=>{cancelAnimationFrame(r),cancelAnimationFrame(n),cancelAnimationFrame(t)}}((()=>{const r=a.current,i=t(o);if(a.current=i,e)d("MOUNT");else if("none"===(null==o?void 0:o.display))d("UNMOUNT");else{const e=r!==i;d(n&&e?"ANIMATION_OUT":"UNMOUNT")}s.current=e}))}),[e,o,d]),n.useEffect((()=>{if(r){const n=e=>{const n=t(o),i=e.animationName===n;e.target===r&&i&&d("ANIMATION_END")},i=n=>{e||n.target!==r||d("TRANSITION_OUT")},u=e=>{e.target===r&&d("TRANSITION_END")};return r.addEventListener("animationcancel",n),r.addEventListener("animationend",n),r.addEventListener("transitionrun",i),r.addEventListener("transitioncancel",u),r.addEventListener("transitionend",u),()=>{r.removeEventListener("animationcancel",n),r.removeEventListener("animationend",n),r.removeEventListener("transitionrun",i),r.removeEventListener("transitioncancel",u),r.removeEventListener("transitionend",u)}}}),[r,e,o,d]),{ref:e=>i(e),isPresent:["mounted","unmountSuspended"].includes(m)}}(i),s="function"==typeof o?o({present:u.isPresent}):n.Children.only(o),a=e(u.ref,s.ref);return"function"==typeof o||u.isPresent?n.cloneElement(s,{ref:a}):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*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"; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@radix-ui/react-presence", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"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
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
23662
28