@react-aria/utils 3.0.0-nightly-101d0772b-250113 → 3.0.0-nightly-c53ab48ec-250115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,54 +24,67 @@ $parcel$export(module.exports, "useExitAnimation", () => $5bd06107f98811f5$expor
24
24
 
25
25
  function $5bd06107f98811f5$export$6d3443f2c48bfc20(ref, isReady = true) {
26
26
  let [isEntering, setEntering] = (0, $bsryd$react.useState)(true);
27
- $5bd06107f98811f5$var$useAnimation(ref, isEntering && isReady, (0, $bsryd$react.useCallback)(()=>setEntering(false), []));
28
- return isEntering && isReady;
27
+ let isAnimationReady = isEntering && isReady;
28
+ // There are two cases for entry animations:
29
+ // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.
30
+ // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.
31
+ //
32
+ // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).
33
+ // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).
34
+ (0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
35
+ if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {
36
+ for (let animation of ref.current.getAnimations())if (animation instanceof CSSTransition) animation.cancel();
37
+ }
38
+ }, [
39
+ ref,
40
+ isAnimationReady
41
+ ]);
42
+ $5bd06107f98811f5$var$useAnimation(ref, isAnimationReady, (0, $bsryd$react.useCallback)(()=>setEntering(false), []));
43
+ return isAnimationReady;
29
44
  }
30
45
  function $5bd06107f98811f5$export$45fda7c47f93fd48(ref, isOpen) {
31
- // State to trigger a re-render after animation is complete, which causes the element to be removed from the DOM.
32
- // Ref to track the state we're in, so we don't immediately reset isExiting to true after the animation.
33
- let [isExiting, setExiting] = (0, $bsryd$react.useState)(false);
34
- let [exitState, setExitState] = (0, $bsryd$react.useState)('idle');
35
- // If isOpen becomes false, set isExiting to true.
36
- if (!isOpen && ref.current && exitState === 'idle') {
37
- isExiting = true;
38
- setExiting(true);
39
- setExitState('exiting');
46
+ let [exitState, setExitState] = (0, $bsryd$react.useState)(isOpen ? 'open' : 'closed');
47
+ switch(exitState){
48
+ case 'open':
49
+ // If isOpen becomes false, set the state to exiting.
50
+ if (!isOpen) setExitState('exiting');
51
+ break;
52
+ case 'closed':
53
+ case 'exiting':
54
+ // If we are exiting and isOpen becomes true, the animation was interrupted.
55
+ // Reset the state to open.
56
+ if (isOpen) setExitState('open');
57
+ break;
40
58
  }
41
- // If we exited, and the element has been removed, reset exit state to idle.
42
- if (!ref.current && exitState === 'exited') setExitState('idle');
59
+ let isExiting = exitState === 'exiting';
43
60
  $5bd06107f98811f5$var$useAnimation(ref, isExiting, (0, $bsryd$react.useCallback)(()=>{
44
- setExitState('exited');
45
- setExiting(false);
61
+ // Set the state to closed, which will cause the element to be unmounted.
62
+ setExitState((state)=>state === 'exiting' ? 'closed' : state);
46
63
  }, []));
47
64
  return isExiting;
48
65
  }
49
66
  function $5bd06107f98811f5$var$useAnimation(ref, isActive, onEnd) {
50
- let prevAnimation = (0, $bsryd$react.useRef)(null);
51
- if (isActive && ref.current) // This is ok because we only read it in the layout effect below, immediately after the commit phase.
52
- // We could move this to another effect that runs every render, but this would be unnecessarily slow.
53
- // We only need the computed style right before the animation becomes active.
54
- // eslint-disable-next-line rulesdir/pure-render
55
- prevAnimation.current = window.getComputedStyle(ref.current).animation;
56
67
  (0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
57
68
  if (isActive && ref.current) {
58
- // Make sure there's actually an animation, and it wasn't there before we triggered the update.
59
- let computedStyle = window.getComputedStyle(ref.current);
60
- if (computedStyle.animationName && computedStyle.animationName !== 'none' && computedStyle.animation !== prevAnimation.current) {
61
- let onAnimationEnd = (e)=>{
62
- if (e.target === ref.current) {
63
- element.removeEventListener('animationend', onAnimationEnd);
64
- (0, $bsryd$reactdom.flushSync)(()=>{
65
- onEnd();
66
- });
67
- }
68
- };
69
- let element = ref.current;
70
- element.addEventListener('animationend', onAnimationEnd);
71
- return ()=>{
72
- element.removeEventListener('animationend', onAnimationEnd);
73
- };
74
- } else onEnd();
69
+ if (!('getAnimations' in ref.current)) {
70
+ // JSDOM
71
+ onEnd();
72
+ return;
73
+ }
74
+ let animations = ref.current.getAnimations();
75
+ if (animations.length === 0) {
76
+ onEnd();
77
+ return;
78
+ }
79
+ let canceled = false;
80
+ Promise.all(animations.map((a)=>a.finished)).then(()=>{
81
+ if (!canceled) (0, $bsryd$reactdom.flushSync)(()=>{
82
+ onEnd();
83
+ });
84
+ }).catch(()=>{});
85
+ return ()=>{
86
+ canceled = true;
87
+ };
75
88
  }
76
89
  }, [
77
90
  ref,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAMM,SAAS,0CAAkB,GAAkC,EAAE,UAAmB,IAAI;IAC3F,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,qBAAO,EAAE;IACzC,mCAAa,KAAK,cAAc,SAAS,CAAA,GAAA,wBAAU,EAAE,IAAM,YAAY,QAAQ,EAAE;IACjF,OAAO,cAAc;AACvB;AAEO,SAAS,0CAAiB,GAAkC,EAAE,MAAe;IAClF,iHAAiH;IACjH,wGAAwG;IACxG,IAAI,CAAC,WAAW,WAAW,GAAG,CAAA,GAAA,qBAAO,EAAE;IACvC,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IAEzC,kDAAkD;IAClD,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,cAAc,QAAQ;QAClD,YAAY;QACZ,WAAW;QACX,aAAa;IACf;IAEA,4EAA4E;IAC5E,IAAI,CAAC,IAAI,OAAO,IAAI,cAAc,UAChC,aAAa;IAGf,mCACE,KACA,WACA,CAAA,GAAA,wBAAU,EAAE;QACV,aAAa;QACb,WAAW;IACb,GAAG,EAAE;IAGP,OAAO;AACT;AAEA,SAAS,mCAAa,GAAkC,EAAE,QAAiB,EAAE,KAAiB;IAC5F,IAAI,gBAAgB,CAAA,GAAA,mBAAK,EAAiB;IAC1C,IAAI,YAAY,IAAI,OAAO,EACzB,qGAAqG;IACrG,qGAAqG;IACrG,6EAA6E;IAC7E,gDAAgD;IAChD,cAAc,OAAO,GAAG,OAAO,gBAAgB,CAAC,IAAI,OAAO,EAAE,SAAS;IAGxE,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,YAAY,IAAI,OAAO,EAAE;YAC3B,+FAA+F;YAC/F,IAAI,gBAAgB,OAAO,gBAAgB,CAAC,IAAI,OAAO;YACvD,IAAI,cAAc,aAAa,IAAI,cAAc,aAAa,KAAK,UAAU,cAAc,SAAS,KAAK,cAAc,OAAO,EAAE;gBAC9H,IAAI,iBAAiB,CAAC;oBACpB,IAAI,EAAE,MAAM,KAAK,IAAI,OAAO,EAAE;wBAC5B,QAAQ,mBAAmB,CAAC,gBAAgB;wBAC5C,CAAA,GAAA,yBAAQ,EAAE;4BAAO;wBAAQ;oBAC3B;gBACF;gBAEA,IAAI,UAAU,IAAI,OAAO;gBACzB,QAAQ,gBAAgB,CAAC,gBAAgB;gBACzC,OAAO;oBACL,QAAQ,mBAAmB,CAAC,gBAAgB;gBAC9C;YACF,OACE;QAEJ;IACF,GAAG;QAAC;QAAK;QAAU;KAAM;AAC3B","sources":["packages/@react-aria/utils/src/animation.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {flushSync} from 'react-dom';\nimport {RefObject, useCallback, useRef, useState} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true) {\n let [isEntering, setEntering] = useState(true);\n useAnimation(ref, isEntering && isReady, useCallback(() => setEntering(false), []));\n return isEntering && isReady;\n}\n\nexport function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean) {\n // State to trigger a re-render after animation is complete, which causes the element to be removed from the DOM.\n // Ref to track the state we're in, so we don't immediately reset isExiting to true after the animation.\n let [isExiting, setExiting] = useState(false);\n let [exitState, setExitState] = useState('idle');\n\n // If isOpen becomes false, set isExiting to true.\n if (!isOpen && ref.current && exitState === 'idle') {\n isExiting = true;\n setExiting(true);\n setExitState('exiting');\n }\n\n // If we exited, and the element has been removed, reset exit state to idle.\n if (!ref.current && exitState === 'exited') {\n setExitState('idle');\n }\n\n useAnimation(\n ref,\n isExiting,\n useCallback(() => {\n setExitState('exited');\n setExiting(false);\n }, [])\n );\n\n return isExiting;\n}\n\nfunction useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void) {\n let prevAnimation = useRef<string | null>(null);\n if (isActive && ref.current) {\n // This is ok because we only read it in the layout effect below, immediately after the commit phase.\n // We could move this to another effect that runs every render, but this would be unnecessarily slow.\n // We only need the computed style right before the animation becomes active.\n // eslint-disable-next-line rulesdir/pure-render\n prevAnimation.current = window.getComputedStyle(ref.current).animation;\n }\n\n useLayoutEffect(() => {\n if (isActive && ref.current) {\n // Make sure there's actually an animation, and it wasn't there before we triggered the update.\n let computedStyle = window.getComputedStyle(ref.current);\n if (computedStyle.animationName && computedStyle.animationName !== 'none' && computedStyle.animation !== prevAnimation.current) {\n let onAnimationEnd = (e: AnimationEvent) => {\n if (e.target === ref.current) {\n element.removeEventListener('animationend', onAnimationEnd);\n flushSync(() => {onEnd();});\n }\n };\n\n let element = ref.current;\n element.addEventListener('animationend', onAnimationEnd);\n return () => {\n element.removeEventListener('animationend', onAnimationEnd);\n };\n } else {\n onEnd();\n }\n }\n }, [ref, isActive, onEnd]);\n}\n"],"names":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I;gBACrC,QAAQ;gBACR;gBACA;YACF;YAEA,IAAI,aAAa,IAAI,OAAO,CAAC,aAAa;YAC1C,IAAI,WAAW,MAAM,KAAK,GAAG;gBAC3B;gBACA;YACF;YAEA,IAAI,WAAW;YACf,QAAQ,GAAG,CAAC,WAAW,GAAG,CAAC,CAAA,IAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;gBAChD,IAAI,CAAC,UACH,CAAA,GAAA,yBAAQ,EAAE;oBACR;gBACF;YAEJ,GAAG,KAAK,CAAC,KAAO;YAEhB,OAAO;gBACL,WAAW;YACb;QACF;IACF,GAAG;QAAC;QAAK;QAAU;KAAM;AAC3B","sources":["packages/@react-aria/utils/src/animation.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {flushSync} from 'react-dom';\nimport {RefObject, useCallback, useState} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true) {\n let [isEntering, setEntering] = useState(true);\n let isAnimationReady = isEntering && isReady;\n \n // There are two cases for entry animations:\n // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.\n // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.\n //\n // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).\n // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).\n useLayoutEffect(() => {\n if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {\n for (let animation of ref.current.getAnimations()) {\n if (animation instanceof CSSTransition) {\n animation.cancel();\n }\n }\n }\n }, [ref, isAnimationReady]);\n\n useAnimation(ref, isAnimationReady, useCallback(() => setEntering(false), []));\n return isAnimationReady;\n}\n\nexport function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean) {\n let [exitState, setExitState] = useState<'closed' | 'open' | 'exiting'>(isOpen ? 'open' : 'closed');\n\n switch (exitState) {\n case 'open':\n // If isOpen becomes false, set the state to exiting.\n if (!isOpen) {\n setExitState('exiting');\n }\n break;\n case 'closed':\n case 'exiting':\n // If we are exiting and isOpen becomes true, the animation was interrupted.\n // Reset the state to open.\n if (isOpen) {\n setExitState('open');\n }\n break;\n }\n\n let isExiting = exitState === 'exiting';\n useAnimation(\n ref,\n isExiting,\n useCallback(() => {\n // Set the state to closed, which will cause the element to be unmounted.\n setExitState(state => state === 'exiting' ? 'closed' : state);\n }, [])\n );\n\n return isExiting;\n}\n\nfunction useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void) {\n useLayoutEffect(() => {\n if (isActive && ref.current) {\n if (!('getAnimations' in ref.current)) {\n // JSDOM\n onEnd();\n return;\n }\n \n let animations = ref.current.getAnimations();\n if (animations.length === 0) {\n onEnd();\n return;\n }\n\n let canceled = false;\n Promise.all(animations.map(a => a.finished)).then(() => {\n if (!canceled) {\n flushSync(() => {\n onEnd();\n });\n }\n }).catch(() => {});\n \n return () => {\n canceled = true;\n };\n }\n }, [ref, isActive, onEnd]);\n}\n"],"names":[],"version":3,"file":"animation.main.js.map"}
@@ -1,6 +1,6 @@
1
1
  import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.mjs";
2
2
  import {flushSync as $jJMAe$flushSync} from "react-dom";
3
- import {useState as $jJMAe$useState, useCallback as $jJMAe$useCallback, useRef as $jJMAe$useRef} from "react";
3
+ import {useState as $jJMAe$useState, useCallback as $jJMAe$useCallback} from "react";
4
4
 
5
5
  /*
6
6
  * Copyright 2020 Adobe. All rights reserved.
@@ -17,54 +17,67 @@ import {useState as $jJMAe$useState, useCallback as $jJMAe$useCallback, useRef a
17
17
 
18
18
  function $d3f049242431219c$export$6d3443f2c48bfc20(ref, isReady = true) {
19
19
  let [isEntering, setEntering] = (0, $jJMAe$useState)(true);
20
- $d3f049242431219c$var$useAnimation(ref, isEntering && isReady, (0, $jJMAe$useCallback)(()=>setEntering(false), []));
21
- return isEntering && isReady;
20
+ let isAnimationReady = isEntering && isReady;
21
+ // There are two cases for entry animations:
22
+ // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.
23
+ // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.
24
+ //
25
+ // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).
26
+ // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).
27
+ (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
28
+ if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {
29
+ for (let animation of ref.current.getAnimations())if (animation instanceof CSSTransition) animation.cancel();
30
+ }
31
+ }, [
32
+ ref,
33
+ isAnimationReady
34
+ ]);
35
+ $d3f049242431219c$var$useAnimation(ref, isAnimationReady, (0, $jJMAe$useCallback)(()=>setEntering(false), []));
36
+ return isAnimationReady;
22
37
  }
23
38
  function $d3f049242431219c$export$45fda7c47f93fd48(ref, isOpen) {
24
- // State to trigger a re-render after animation is complete, which causes the element to be removed from the DOM.
25
- // Ref to track the state we're in, so we don't immediately reset isExiting to true after the animation.
26
- let [isExiting, setExiting] = (0, $jJMAe$useState)(false);
27
- let [exitState, setExitState] = (0, $jJMAe$useState)('idle');
28
- // If isOpen becomes false, set isExiting to true.
29
- if (!isOpen && ref.current && exitState === 'idle') {
30
- isExiting = true;
31
- setExiting(true);
32
- setExitState('exiting');
39
+ let [exitState, setExitState] = (0, $jJMAe$useState)(isOpen ? 'open' : 'closed');
40
+ switch(exitState){
41
+ case 'open':
42
+ // If isOpen becomes false, set the state to exiting.
43
+ if (!isOpen) setExitState('exiting');
44
+ break;
45
+ case 'closed':
46
+ case 'exiting':
47
+ // If we are exiting and isOpen becomes true, the animation was interrupted.
48
+ // Reset the state to open.
49
+ if (isOpen) setExitState('open');
50
+ break;
33
51
  }
34
- // If we exited, and the element has been removed, reset exit state to idle.
35
- if (!ref.current && exitState === 'exited') setExitState('idle');
52
+ let isExiting = exitState === 'exiting';
36
53
  $d3f049242431219c$var$useAnimation(ref, isExiting, (0, $jJMAe$useCallback)(()=>{
37
- setExitState('exited');
38
- setExiting(false);
54
+ // Set the state to closed, which will cause the element to be unmounted.
55
+ setExitState((state)=>state === 'exiting' ? 'closed' : state);
39
56
  }, []));
40
57
  return isExiting;
41
58
  }
42
59
  function $d3f049242431219c$var$useAnimation(ref, isActive, onEnd) {
43
- let prevAnimation = (0, $jJMAe$useRef)(null);
44
- if (isActive && ref.current) // This is ok because we only read it in the layout effect below, immediately after the commit phase.
45
- // We could move this to another effect that runs every render, but this would be unnecessarily slow.
46
- // We only need the computed style right before the animation becomes active.
47
- // eslint-disable-next-line rulesdir/pure-render
48
- prevAnimation.current = window.getComputedStyle(ref.current).animation;
49
60
  (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
50
61
  if (isActive && ref.current) {
51
- // Make sure there's actually an animation, and it wasn't there before we triggered the update.
52
- let computedStyle = window.getComputedStyle(ref.current);
53
- if (computedStyle.animationName && computedStyle.animationName !== 'none' && computedStyle.animation !== prevAnimation.current) {
54
- let onAnimationEnd = (e)=>{
55
- if (e.target === ref.current) {
56
- element.removeEventListener('animationend', onAnimationEnd);
57
- (0, $jJMAe$flushSync)(()=>{
58
- onEnd();
59
- });
60
- }
61
- };
62
- let element = ref.current;
63
- element.addEventListener('animationend', onAnimationEnd);
64
- return ()=>{
65
- element.removeEventListener('animationend', onAnimationEnd);
66
- };
67
- } else onEnd();
62
+ if (!('getAnimations' in ref.current)) {
63
+ // JSDOM
64
+ onEnd();
65
+ return;
66
+ }
67
+ let animations = ref.current.getAnimations();
68
+ if (animations.length === 0) {
69
+ onEnd();
70
+ return;
71
+ }
72
+ let canceled = false;
73
+ Promise.all(animations.map((a)=>a.finished)).then(()=>{
74
+ if (!canceled) (0, $jJMAe$flushSync)(()=>{
75
+ onEnd();
76
+ });
77
+ }).catch(()=>{});
78
+ return ()=>{
79
+ canceled = true;
80
+ };
68
81
  }
69
82
  }, [
70
83
  ref,
@@ -1,6 +1,6 @@
1
1
  import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";
2
2
  import {flushSync as $jJMAe$flushSync} from "react-dom";
3
- import {useState as $jJMAe$useState, useCallback as $jJMAe$useCallback, useRef as $jJMAe$useRef} from "react";
3
+ import {useState as $jJMAe$useState, useCallback as $jJMAe$useCallback} from "react";
4
4
 
5
5
  /*
6
6
  * Copyright 2020 Adobe. All rights reserved.
@@ -17,54 +17,67 @@ import {useState as $jJMAe$useState, useCallback as $jJMAe$useCallback, useRef a
17
17
 
18
18
  function $d3f049242431219c$export$6d3443f2c48bfc20(ref, isReady = true) {
19
19
  let [isEntering, setEntering] = (0, $jJMAe$useState)(true);
20
- $d3f049242431219c$var$useAnimation(ref, isEntering && isReady, (0, $jJMAe$useCallback)(()=>setEntering(false), []));
21
- return isEntering && isReady;
20
+ let isAnimationReady = isEntering && isReady;
21
+ // There are two cases for entry animations:
22
+ // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.
23
+ // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.
24
+ //
25
+ // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).
26
+ // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).
27
+ (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
28
+ if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {
29
+ for (let animation of ref.current.getAnimations())if (animation instanceof CSSTransition) animation.cancel();
30
+ }
31
+ }, [
32
+ ref,
33
+ isAnimationReady
34
+ ]);
35
+ $d3f049242431219c$var$useAnimation(ref, isAnimationReady, (0, $jJMAe$useCallback)(()=>setEntering(false), []));
36
+ return isAnimationReady;
22
37
  }
23
38
  function $d3f049242431219c$export$45fda7c47f93fd48(ref, isOpen) {
24
- // State to trigger a re-render after animation is complete, which causes the element to be removed from the DOM.
25
- // Ref to track the state we're in, so we don't immediately reset isExiting to true after the animation.
26
- let [isExiting, setExiting] = (0, $jJMAe$useState)(false);
27
- let [exitState, setExitState] = (0, $jJMAe$useState)('idle');
28
- // If isOpen becomes false, set isExiting to true.
29
- if (!isOpen && ref.current && exitState === 'idle') {
30
- isExiting = true;
31
- setExiting(true);
32
- setExitState('exiting');
39
+ let [exitState, setExitState] = (0, $jJMAe$useState)(isOpen ? 'open' : 'closed');
40
+ switch(exitState){
41
+ case 'open':
42
+ // If isOpen becomes false, set the state to exiting.
43
+ if (!isOpen) setExitState('exiting');
44
+ break;
45
+ case 'closed':
46
+ case 'exiting':
47
+ // If we are exiting and isOpen becomes true, the animation was interrupted.
48
+ // Reset the state to open.
49
+ if (isOpen) setExitState('open');
50
+ break;
33
51
  }
34
- // If we exited, and the element has been removed, reset exit state to idle.
35
- if (!ref.current && exitState === 'exited') setExitState('idle');
52
+ let isExiting = exitState === 'exiting';
36
53
  $d3f049242431219c$var$useAnimation(ref, isExiting, (0, $jJMAe$useCallback)(()=>{
37
- setExitState('exited');
38
- setExiting(false);
54
+ // Set the state to closed, which will cause the element to be unmounted.
55
+ setExitState((state)=>state === 'exiting' ? 'closed' : state);
39
56
  }, []));
40
57
  return isExiting;
41
58
  }
42
59
  function $d3f049242431219c$var$useAnimation(ref, isActive, onEnd) {
43
- let prevAnimation = (0, $jJMAe$useRef)(null);
44
- if (isActive && ref.current) // This is ok because we only read it in the layout effect below, immediately after the commit phase.
45
- // We could move this to another effect that runs every render, but this would be unnecessarily slow.
46
- // We only need the computed style right before the animation becomes active.
47
- // eslint-disable-next-line rulesdir/pure-render
48
- prevAnimation.current = window.getComputedStyle(ref.current).animation;
49
60
  (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
50
61
  if (isActive && ref.current) {
51
- // Make sure there's actually an animation, and it wasn't there before we triggered the update.
52
- let computedStyle = window.getComputedStyle(ref.current);
53
- if (computedStyle.animationName && computedStyle.animationName !== 'none' && computedStyle.animation !== prevAnimation.current) {
54
- let onAnimationEnd = (e)=>{
55
- if (e.target === ref.current) {
56
- element.removeEventListener('animationend', onAnimationEnd);
57
- (0, $jJMAe$flushSync)(()=>{
58
- onEnd();
59
- });
60
- }
61
- };
62
- let element = ref.current;
63
- element.addEventListener('animationend', onAnimationEnd);
64
- return ()=>{
65
- element.removeEventListener('animationend', onAnimationEnd);
66
- };
67
- } else onEnd();
62
+ if (!('getAnimations' in ref.current)) {
63
+ // JSDOM
64
+ onEnd();
65
+ return;
66
+ }
67
+ let animations = ref.current.getAnimations();
68
+ if (animations.length === 0) {
69
+ onEnd();
70
+ return;
71
+ }
72
+ let canceled = false;
73
+ Promise.all(animations.map((a)=>a.finished)).then(()=>{
74
+ if (!canceled) (0, $jJMAe$flushSync)(()=>{
75
+ onEnd();
76
+ });
77
+ }).catch(()=>{});
78
+ return ()=>{
79
+ canceled = true;
80
+ };
68
81
  }
69
82
  }, [
70
83
  ref,
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAMM,SAAS,0CAAkB,GAAkC,EAAE,UAAmB,IAAI;IAC3F,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IACzC,mCAAa,KAAK,cAAc,SAAS,CAAA,GAAA,kBAAU,EAAE,IAAM,YAAY,QAAQ,EAAE;IACjF,OAAO,cAAc;AACvB;AAEO,SAAS,0CAAiB,GAAkC,EAAE,MAAe;IAClF,iHAAiH;IACjH,wGAAwG;IACxG,IAAI,CAAC,WAAW,WAAW,GAAG,CAAA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ils/src/animation.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {flushSync} from 'react-dom';\nimport {RefObject, useCallback, useRef, useState} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true) {\n let [isEntering, setEntering] = useState(true);\n useAnimation(ref, isEntering && isReady, useCallback(() => setEntering(false), []));\n return isEntering && isReady;\n}\n\nexport function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean) {\n // State to trigger a re-render after animation is complete, which causes the element to be removed from the DOM.\n // Ref to track the state we're in, so we don't immediately reset isExiting to true after the animation.\n let [isExiting, setExiting] = useState(false);\n let [exitState, setExitState] = useState('idle');\n\n // If isOpen becomes false, set isExiting to true.\n if (!isOpen && ref.current && exitState === 'idle') {\n isExiting = true;\n setExiting(true);\n setExitState('exiting');\n }\n\n // If we exited, and the element has been removed, reset exit state to idle.\n if (!ref.current && exitState === 'exited') {\n setExitState('idle');\n }\n\n useAnimation(\n ref,\n isExiting,\n useCallback(() => {\n setExitState('exited');\n setExiting(false);\n }, [])\n );\n\n return isExiting;\n}\n\nfunction useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void) {\n let prevAnimation = useRef<string | null>(null);\n if (isActive && ref.current) {\n // This is ok because we only read it in the layout effect below, immediately after the commit phase.\n // We could move this to another effect that runs every render, but this would be unnecessarily slow.\n // We only need the computed style right before the animation becomes active.\n // eslint-disable-next-line rulesdir/pure-render\n prevAnimation.current = window.getComputedStyle(ref.current).animation;\n }\n\n useLayoutEffect(() => {\n if (isActive && ref.current) {\n // Make sure there's actually an animation, and it wasn't there before we triggered the update.\n let computedStyle = window.getComputedStyle(ref.current);\n if (computedStyle.animationName && computedStyle.animationName !== 'none' && computedStyle.animation !== prevAnimation.current) {\n let onAnimationEnd = (e: AnimationEvent) => {\n if (e.target === ref.current) {\n element.removeEventListener('animationend', onAnimationEnd);\n flushSync(() => {onEnd();});\n }\n };\n\n let element = ref.current;\n element.addEventListener('animationend', onAnimationEnd);\n return () => {\n element.removeEventListener('animationend', onAnimationEnd);\n };\n } else {\n onEnd();\n }\n }\n }, [ref, isActive, onEnd]);\n}\n"],"names":[],"version":3,"file":"animation.module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAMM,SAAS,0CAAkB,GAAkC,EAAE,UAAmB,IAAI;IAC3F,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IACzC,IAAI,mBAAmB,cAAc;IAErC,4CAA4C;IAC5C,kIAAkI;IAClI,4IAA4I;IAC5I,EAAE;IACF,mJAAmJ;IACnJ,+FAA+F;IAC/F,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,oBAAoB,IAAI,OAAO,IAAI,mBAAmB,IAAI,OAAO,EAAE;YACrE,KAAK,IAAI,aAAa,IAAI,OAAO,CAAC,aAAa,GAC7C,IAAI,qBAAqB,eACvB,UAAU,MAAM;QAGtB;IACF,GAAG;QAAC;QAAK;KAAiB;IAE1B,mCAAa,KAAK,kBAAkB,CAAA,GAAA,kBAAU,EAAE,IAAM,YAAY,QAAQ,EAAE;IAC5E,OAAO;AACT;AAEO,SAAS,0CAAiB,GAAkC,EAAE,MAAe;IAClF,IAAI,CAAC,WAAW,aAAa,GAAG,CAAA,GAAA,eAAO,EAAiC,SAAS,SAAS;IAE1F,OAAQ;QACN,KAAK;YACH,qDAAqD;YACrD,IAAI,CAAC,QACH,aAAa;YAEf;QACF,KAAK;QACL,KAAK;YACH,4EAA4E;YAC5E,2BAA2B;YAC3B,IAAI,QACF,aAAa;YAEf;IACJ;IAEA,IAAI,YAAY,cAAc;IAC9B,mCACE,KACA,WACA,CAAA,GAAA,kBAAU,EAAE;QACV,yEAAyE;QACzE,aAAa,CAAA,QAAS,UAAU,YAAY,WAAW;IACzD,GAAG,EAAE;IAGP,OAAO;AACT;AAEA,SAAS,mCAAa,GAAkC,EAAE,QAAiB,EAAE,KAAiB;IAC5F,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,YAAY,IAAI,OAAO,EAAE;YAC3B,IAAI,CAAE,CAAA,mBAAmB,IAAI,OAAO,AAAD,GAAI;gBACrC,QAAQ;gBACR;gBACA;YACF;YAEA,IAAI,aAAa,IAAI,OAAO,CAAC,aAAa;YAC1C,IAAI,WAAW,MAAM,KAAK,GAAG;gBAC3B;gBACA;YACF;YAEA,IAAI,WAAW;YACf,QAAQ,GAAG,CAAC,WAAW,GAAG,CAAC,CAAA,IAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;gBAChD,IAAI,CAAC,UACH,CAAA,GAAA,gBAAQ,EAAE;oBACR;gBACF;YAEJ,GAAG,KAAK,CAAC,KAAO;YAEhB,OAAO;gBACL,WAAW;YACb;QACF;IACF,GAAG;QAAC;QAAK;QAAU;KAAM;AAC3B","sources":["packages/@react-aria/utils/src/animation.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {flushSync} from 'react-dom';\nimport {RefObject, useCallback, useState} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true) {\n let [isEntering, setEntering] = useState(true);\n let isAnimationReady = isEntering && isReady;\n \n // There are two cases for entry animations:\n // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.\n // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.\n //\n // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).\n // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).\n useLayoutEffect(() => {\n if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {\n for (let animation of ref.current.getAnimations()) {\n if (animation instanceof CSSTransition) {\n animation.cancel();\n }\n }\n }\n }, [ref, isAnimationReady]);\n\n useAnimation(ref, isAnimationReady, useCallback(() => setEntering(false), []));\n return isAnimationReady;\n}\n\nexport function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean) {\n let [exitState, setExitState] = useState<'closed' | 'open' | 'exiting'>(isOpen ? 'open' : 'closed');\n\n switch (exitState) {\n case 'open':\n // If isOpen becomes false, set the state to exiting.\n if (!isOpen) {\n setExitState('exiting');\n }\n break;\n case 'closed':\n case 'exiting':\n // If we are exiting and isOpen becomes true, the animation was interrupted.\n // Reset the state to open.\n if (isOpen) {\n setExitState('open');\n }\n break;\n }\n\n let isExiting = exitState === 'exiting';\n useAnimation(\n ref,\n isExiting,\n useCallback(() => {\n // Set the state to closed, which will cause the element to be unmounted.\n setExitState(state => state === 'exiting' ? 'closed' : state);\n }, [])\n );\n\n return isExiting;\n}\n\nfunction useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void) {\n useLayoutEffect(() => {\n if (isActive && ref.current) {\n if (!('getAnimations' in ref.current)) {\n // JSDOM\n onEnd();\n return;\n }\n \n let animations = ref.current.getAnimations();\n if (animations.length === 0) {\n onEnd();\n return;\n }\n\n let canceled = false;\n Promise.all(animations.map(a => a.finished)).then(() => {\n if (!canceled) {\n flushSync(() => {\n onEnd();\n });\n }\n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ect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useId.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/chain.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/domHelpers.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/mergeProps.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/mergeRefs.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/filterDOMProps.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/focusWithoutScrolling.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/getOffset.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/platform.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/openLink.tsx","packages/@react-aria/utils/src/packages/@react-aria/utils/src/runAfterTransition.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useDrag1D.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useGlobalListeners.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useLabels.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useObjectRef.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useUpdateEffect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useUpdateLayoutEffect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useResizeObserver.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useSyncRef.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/isScrollable.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/getScrollParent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/getScrollParents.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useViewportSize.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useDescription.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useEffectEvent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useEvent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useValueEffect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/scrollIntoView.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/isVirtualEvent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useDeepMemo.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useFormReset.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useLoadMore.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/constants.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/keyboard.tsx","packages/@react-aria/utils/src/packages/@react-aria/utils/src/animation.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/index.ts","packages/@react-aria/utils/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useId, mergeIds, useSlotId} from './useId';\nexport {chain} from './chain';\nexport {getOwnerDocument, getOwnerWindow} from './domHelpers';\nexport {mergeProps} from './mergeProps';\nexport {mergeRefs} from './mergeRefs';\nexport {filterDOMProps} from './filterDOMProps';\nexport {focusWithoutScrolling} from './focusWithoutScrolling';\nexport {getOffset} from './getOffset';\nexport {openLink, getSyntheticLinkProps, useSyntheticLinkProps, RouterProvider, shouldClientNavigate, useRouter, useLinkProps} from './openLink';\nexport {runAfterTransition} from './runAfterTransition';\nexport {useDrag1D} from './useDrag1D';\nexport {useGlobalListeners} from './useGlobalListeners';\nexport {useLabels} from './useLabels';\nexport {useObjectRef} from './useObjectRef';\nexport {useUpdateEffect} from './useUpdateEffect';\nexport {useUpdateLayoutEffect} from './useUpdateLayoutEffect';\nexport {useLayoutEffect} from './useLayoutEffect';\nexport {useResizeObserver} from './useResizeObserver';\nexport {useSyncRef} from './useSyncRef';\nexport {getScrollParent} from './getScrollParent';\nexport {getScrollParents} from './getScrollParents';\nexport {isScrollable} from './isScrollable';\nexport {useViewportSize} from './useViewportSize';\nexport {useDescription} from './useDescription';\nexport {isMac, isIPhone, isIPad, isIOS, isAppleDevice, isWebKit, isChrome, isAndroid, isFirefox} from './platform';\nexport {useEvent} from './useEvent';\nexport {useValueEffect} from './useValueEffect';\nexport {scrollIntoView, scrollIntoViewport} from './scrollIntoView';\nexport {clamp, snapValueToStep} from '@react-stately/utils';\nexport {isVirtualClick, isVirtualPointerEvent} from './isVirtualEvent';\nexport {useEffectEvent} from './useEffectEvent';\nexport {useDeepMemo} from './useDeepMemo';\nexport {useFormReset} from './useFormReset';\nexport {useLoadMore} from './useLoadMore';\nexport {CLEAR_FOCUS_EVENT, FOCUS_EVENT, UPDATE_ACTIVEDESCENDANT} from './constants';\nexport {isCtrlKeyPressed} from './keyboard';\nexport {useEnterAnimation, useExitAnimation} from './animation';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;AAiBA,OAAO,MAAM,6CAED,CAAC;ACOb;;;GAGG;AACH,sBAAsB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAqChD;AAED;;;GAGG;AACH,yBAAyB,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAkBzD;AAED;;;;GAIG;AACH,0BAA0B,QAAQ,GAAE,aAAa,CAAC,GAAG,CAAM,GAAG,MAAM,CAcnE;ACpGD;;GAEG;AACH,sBAAsB,GAAG,SAAS,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAQnE;ACvBD,OAAO,MAAM,uBAAwB,OAAO,GAAG,IAAI,G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,iCAAiC;IACjC,KAAK,CAAC,EAAE,GAAG,CAAA;CACZ;AAED,4BAA4B,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,YAAU,WAAW,GAAG,IAAI,CAAC,QA+CnF;ACpED,OAAO,MAAM,4CAA4C,CAAC;AAC1D,OAAO,MAAM,gCAAgC,CAAC;AAC9C,OAAO,MAAM,8DAA8D,CAAC;ACD5E;IACE,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,iCAAiC,CAAC,EAAE,KAAK,WAMxC;ACVD,kCAAkC,GAAG,EAAE,YAAU,WAAW,GAAG,IAAI,CAAC,EAAE,OAAO,GAAE,OAAc,WAsB5F;AAED,iCAAiC,GAAG,EAAE,YAAU,WAAW,GAAG,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,WA+BnF;AChCD,OAAO,EAAC,KAAK,EAAE,eAAe,EAAC,MAAM,sBAAsB,CAAC","sources":["packages/@react-aria/utils/src/packages/@react-aria/utils/src/useLayoutEffect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useId.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/chain.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/domHelpers.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/mergeProps.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/mergeRefs.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/filterDOMProps.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/focusWithoutScrolling.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/getOffset.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/platform.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/openLink.tsx","packages/@react-aria/utils/src/packages/@react-aria/utils/src/runAfterTransition.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useDrag1D.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useGlobalListeners.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useLabels.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useObjectRef.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useUpdateEffect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useUpdateLayoutEffect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useResizeObserver.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useSyncRef.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/isScrollable.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/getScrollParent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/getScrollParents.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useViewportSize.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useDescription.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useEffectEvent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useEvent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useValueEffect.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/scrollIntoView.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/isVirtualEvent.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useDeepMemo.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useFormReset.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/useLoadMore.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/constants.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/keyboard.tsx","packages/@react-aria/utils/src/packages/@react-aria/utils/src/animation.ts","packages/@react-aria/utils/src/packages/@react-aria/utils/src/index.ts","packages/@react-aria/utils/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useId, mergeIds, useSlotId} from './useId';\nexport {chain} from './chain';\nexport {getOwnerDocument, getOwnerWindow} from './domHelpers';\nexport {mergeProps} from './mergeProps';\nexport {mergeRefs} from './mergeRefs';\nexport {filterDOMProps} from './filterDOMProps';\nexport {focusWithoutScrolling} from './focusWithoutScrolling';\nexport {getOffset} from './getOffset';\nexport {openLink, getSyntheticLinkProps, useSyntheticLinkProps, RouterProvider, shouldClientNavigate, useRouter, useLinkProps} from './openLink';\nexport {runAfterTransition} from './runAfterTransition';\nexport {useDrag1D} from './useDrag1D';\nexport {useGlobalListeners} from './useGlobalListeners';\nexport {useLabels} from './useLabels';\nexport {useObjectRef} from './useObjectRef';\nexport {useUpdateEffect} from './useUpdateEffect';\nexport {useUpdateLayoutEffect} from './useUpdateLayoutEffect';\nexport {useLayoutEffect} from './useLayoutEffect';\nexport {useResizeObserver} from './useResizeObserver';\nexport {useSyncRef} from './useSyncRef';\nexport {getScrollParent} from './getScrollParent';\nexport {getScrollParents} from './getScrollParents';\nexport {isScrollable} from './isScrollable';\nexport {useViewportSize} from './useViewportSize';\nexport {useDescription} from './useDescription';\nexport {isMac, isIPhone, isIPad, isIOS, isAppleDevice, isWebKit, isChrome, isAndroid, isFirefox} from './platform';\nexport {useEvent} from './useEvent';\nexport {useValueEffect} from './useValueEffect';\nexport {scrollIntoView, scrollIntoViewport} from './scrollIntoView';\nexport {clamp, snapValueToStep} from '@react-stately/utils';\nexport {isVirtualClick, isVirtualPointerEvent} from './isVirtualEvent';\nexport {useEffectEvent} from './useEffectEvent';\nexport {useDeepMemo} from './useDeepMemo';\nexport {useFormReset} from './useFormReset';\nexport {useLoadMore} from './useLoadMore';\nexport {CLEAR_FOCUS_EVENT, FOCUS_EVENT, UPDATE_ACTIVEDESCENDANT} from './constants';\nexport {isCtrlKeyPressed} from './keyboard';\nexport {useEnterAnimation, useExitAnimation} from './animation';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/utils",
3
- "version": "3.0.0-nightly-101d0772b-250113",
3
+ "version": "3.0.0-nightly-c53ab48ec-250115",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,9 +22,9 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/ssr": "3.0.0-nightly-101d0772b-250113",
26
- "@react-stately/utils": "3.0.0-nightly-101d0772b-250113",
27
- "@react-types/shared": "3.0.0-nightly-101d0772b-250113",
25
+ "@react-aria/ssr": "3.0.0-nightly-c53ab48ec-250115",
26
+ "@react-stately/utils": "3.0.0-nightly-c53ab48ec-250115",
27
+ "@react-types/shared": "3.0.0-nightly-c53ab48ec-250115",
28
28
  "@swc/helpers": "^0.5.0",
29
29
  "clsx": "^2.0.0"
30
30
  },
package/src/animation.ts CHANGED
@@ -11,39 +11,60 @@
11
11
  */
12
12
 
13
13
  import {flushSync} from 'react-dom';
14
- import {RefObject, useCallback, useRef, useState} from 'react';
14
+ import {RefObject, useCallback, useState} from 'react';
15
15
  import {useLayoutEffect} from './useLayoutEffect';
16
16
 
17
17
  export function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true) {
18
18
  let [isEntering, setEntering] = useState(true);
19
- useAnimation(ref, isEntering && isReady, useCallback(() => setEntering(false), []));
20
- return isEntering && isReady;
19
+ let isAnimationReady = isEntering && isReady;
20
+
21
+ // There are two cases for entry animations:
22
+ // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.
23
+ // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.
24
+ //
25
+ // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).
26
+ // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).
27
+ useLayoutEffect(() => {
28
+ if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {
29
+ for (let animation of ref.current.getAnimations()) {
30
+ if (animation instanceof CSSTransition) {
31
+ animation.cancel();
32
+ }
33
+ }
34
+ }
35
+ }, [ref, isAnimationReady]);
36
+
37
+ useAnimation(ref, isAnimationReady, useCallback(() => setEntering(false), []));
38
+ return isAnimationReady;
21
39
  }
22
40
 
23
41
  export function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean) {
24
- // State to trigger a re-render after animation is complete, which causes the element to be removed from the DOM.
25
- // Ref to track the state we're in, so we don't immediately reset isExiting to true after the animation.
26
- let [isExiting, setExiting] = useState(false);
27
- let [exitState, setExitState] = useState('idle');
42
+ let [exitState, setExitState] = useState<'closed' | 'open' | 'exiting'>(isOpen ? 'open' : 'closed');
28
43
 
29
- // If isOpen becomes false, set isExiting to true.
30
- if (!isOpen && ref.current && exitState === 'idle') {
31
- isExiting = true;
32
- setExiting(true);
33
- setExitState('exiting');
34
- }
35
-
36
- // If we exited, and the element has been removed, reset exit state to idle.
37
- if (!ref.current && exitState === 'exited') {
38
- setExitState('idle');
44
+ switch (exitState) {
45
+ case 'open':
46
+ // If isOpen becomes false, set the state to exiting.
47
+ if (!isOpen) {
48
+ setExitState('exiting');
49
+ }
50
+ break;
51
+ case 'closed':
52
+ case 'exiting':
53
+ // If we are exiting and isOpen becomes true, the animation was interrupted.
54
+ // Reset the state to open.
55
+ if (isOpen) {
56
+ setExitState('open');
57
+ }
58
+ break;
39
59
  }
40
60
 
61
+ let isExiting = exitState === 'exiting';
41
62
  useAnimation(
42
63
  ref,
43
64
  isExiting,
44
65
  useCallback(() => {
45
- setExitState('exited');
46
- setExiting(false);
66
+ // Set the state to closed, which will cause the element to be unmounted.
67
+ setExitState(state => state === 'exiting' ? 'closed' : state);
47
68
  }, [])
48
69
  );
49
70
 
@@ -51,35 +72,32 @@ export function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boo
51
72
  }
52
73
 
53
74
  function useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void) {
54
- let prevAnimation = useRef<string | null>(null);
55
- if (isActive && ref.current) {
56
- // This is ok because we only read it in the layout effect below, immediately after the commit phase.
57
- // We could move this to another effect that runs every render, but this would be unnecessarily slow.
58
- // We only need the computed style right before the animation becomes active.
59
- // eslint-disable-next-line rulesdir/pure-render
60
- prevAnimation.current = window.getComputedStyle(ref.current).animation;
61
- }
62
-
63
75
  useLayoutEffect(() => {
64
76
  if (isActive && ref.current) {
65
- // Make sure there's actually an animation, and it wasn't there before we triggered the update.
66
- let computedStyle = window.getComputedStyle(ref.current);
67
- if (computedStyle.animationName && computedStyle.animationName !== 'none' && computedStyle.animation !== prevAnimation.current) {
68
- let onAnimationEnd = (e: AnimationEvent) => {
69
- if (e.target === ref.current) {
70
- element.removeEventListener('animationend', onAnimationEnd);
71
- flushSync(() => {onEnd();});
72
- }
73
- };
74
-
75
- let element = ref.current;
76
- element.addEventListener('animationend', onAnimationEnd);
77
- return () => {
78
- element.removeEventListener('animationend', onAnimationEnd);
79
- };
80
- } else {
77
+ if (!('getAnimations' in ref.current)) {
78
+ // JSDOM
81
79
  onEnd();
80
+ return;
82
81
  }
82
+
83
+ let animations = ref.current.getAnimations();
84
+ if (animations.length === 0) {
85
+ onEnd();
86
+ return;
87
+ }
88
+
89
+ let canceled = false;
90
+ Promise.all(animations.map(a => a.finished)).then(() => {
91
+ if (!canceled) {
92
+ flushSync(() => {
93
+ onEnd();
94
+ });
95
+ }
96
+ }).catch(() => {});
97
+
98
+ return () => {
99
+ canceled = true;
100
+ };
83
101
  }
84
102
  }, [ref, isActive, onEnd]);
85
103
  }