react-transition-state 2.1.0 → 2.1.1-alpha.1
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.
package/dist/cjs/index.js
CHANGED
|
@@ -31,6 +31,10 @@ const getEndStatus = (status, unmountOnExit) => {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
const getTimeout = timeout => typeof timeout === 'object' ? [timeout.enter, timeout.exit] : [timeout, timeout];
|
|
34
|
+
const nextTick = (transitState, status) => setTimeout(() => {
|
|
35
|
+
// Reading document.body.offsetTop can force browser to repaint before transition to the next state
|
|
36
|
+
isNaN(document.body.offsetTop) || transitState(status + 1);
|
|
37
|
+
}, 0);
|
|
34
38
|
|
|
35
39
|
const updateState$1 = (status, setState, latestState, timeoutId, onChange) => {
|
|
36
40
|
clearTimeout(timeoutId.current);
|
|
@@ -72,7 +76,7 @@ const useTransition = ({
|
|
|
72
76
|
break;
|
|
73
77
|
case PRE_ENTER:
|
|
74
78
|
case PRE_EXIT:
|
|
75
|
-
timeoutId.current =
|
|
79
|
+
timeoutId.current = nextTick(transitState, status);
|
|
76
80
|
break;
|
|
77
81
|
}
|
|
78
82
|
};
|
|
@@ -166,7 +170,7 @@ const useTransitionMap = ({
|
|
|
166
170
|
break;
|
|
167
171
|
case PRE_ENTER:
|
|
168
172
|
case PRE_EXIT:
|
|
169
|
-
config.timeoutId =
|
|
173
|
+
config.timeoutId = nextTick(transitState, status);
|
|
170
174
|
break;
|
|
171
175
|
}
|
|
172
176
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
-
import { getState, ENTERED, startOrEnd,
|
|
2
|
+
import { getState, ENTERED, startOrEnd, getEndStatus, PRE_EXIT, EXITING, getTimeout, nextTick, PRE_ENTER, ENTERING } from './utils.js';
|
|
3
3
|
|
|
4
4
|
const updateState = (status, setState, latestState, timeoutId, onChange) => {
|
|
5
5
|
clearTimeout(timeoutId.current);
|
|
@@ -41,7 +41,7 @@ const useTransition = ({
|
|
|
41
41
|
break;
|
|
42
42
|
case PRE_ENTER:
|
|
43
43
|
case PRE_EXIT:
|
|
44
|
-
timeoutId.current =
|
|
44
|
+
timeoutId.current = nextTick(transitState, status);
|
|
45
45
|
break;
|
|
46
46
|
}
|
|
47
47
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useRef, useCallback } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ENTERED, startOrEnd, getEndStatus, PRE_EXIT, EXITING, getTimeout, nextTick, PRE_ENTER, ENTERING, getState } from './utils.js';
|
|
3
3
|
|
|
4
4
|
const initialStateMap = new Map();
|
|
5
5
|
const initialConfigMap = new Map();
|
|
@@ -79,7 +79,7 @@ const useTransitionMap = ({
|
|
|
79
79
|
break;
|
|
80
80
|
case PRE_ENTER:
|
|
81
81
|
case PRE_EXIT:
|
|
82
|
-
config.timeoutId =
|
|
82
|
+
config.timeoutId = nextTick(transitState, status);
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
85
|
};
|
package/dist/es/hooks/utils.js
CHANGED
|
@@ -25,5 +25,9 @@ const getEndStatus = (status, unmountOnExit) => {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
const getTimeout = timeout => typeof timeout === 'object' ? [timeout.enter, timeout.exit] : [timeout, timeout];
|
|
28
|
+
const nextTick = (transitState, status) => setTimeout(() => {
|
|
29
|
+
// Reading document.body.offsetTop can force browser to repaint before transition to the next state
|
|
30
|
+
isNaN(document.body.offsetTop) || transitState(status + 1);
|
|
31
|
+
}, 0);
|
|
28
32
|
|
|
29
|
-
export { ENTERED, ENTERING, EXITED, EXITING, PRE_ENTER, PRE_EXIT, STATUS, UNMOUNTED, getEndStatus, getState, getTimeout, startOrEnd };
|
|
33
|
+
export { ENTERED, ENTERING, EXITED, EXITING, PRE_ENTER, PRE_EXIT, STATUS, UNMOUNTED, getEndStatus, getState, getTimeout, nextTick, startOrEnd };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-transition-state",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1-alpha.1",
|
|
4
4
|
"description": "Zero dependency React transition state machine.",
|
|
5
5
|
"author": "Zheng Song",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,25 +41,25 @@
|
|
|
41
41
|
"react-dom": ">=16.8.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "^7.
|
|
45
|
-
"@babel/preset-env": "^7.
|
|
44
|
+
"@babel/core": "^7.22.5",
|
|
45
|
+
"@babel/preset-env": "^7.22.5",
|
|
46
46
|
"@rollup/plugin-babel": "^6.0.3",
|
|
47
|
-
"@testing-library/react": "^
|
|
48
|
-
"@types/jest": "^29.
|
|
47
|
+
"@testing-library/react": "^14.0.0",
|
|
48
|
+
"@types/jest": "^29.5.2",
|
|
49
49
|
"babel-plugin-pure-annotations": "^0.1.2",
|
|
50
50
|
"dtslint": "^4.1.6",
|
|
51
|
-
"eslint": "^8.
|
|
52
|
-
"eslint-config-prettier": "^8.
|
|
51
|
+
"eslint": "^8.41.0",
|
|
52
|
+
"eslint-config-prettier": "^8.8.0",
|
|
53
53
|
"eslint-plugin-jest": "^27.2.1",
|
|
54
54
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
55
|
-
"jest": "^29.
|
|
56
|
-
"jest-environment-jsdom": "^29.
|
|
55
|
+
"jest": "^29.5.0",
|
|
56
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
57
57
|
"npm-run-all": "^4.1.5",
|
|
58
|
-
"prettier": "^2.8.
|
|
58
|
+
"prettier": "^2.8.8",
|
|
59
59
|
"react": "^18.2.0",
|
|
60
60
|
"react-dom": "^18.2.0",
|
|
61
61
|
"regenerator-runtime": "^0.13.11",
|
|
62
|
-
"rollup": "^3.
|
|
63
|
-
"typescript": "^
|
|
62
|
+
"rollup": "^3.25.1",
|
|
63
|
+
"typescript": "^5.1.3"
|
|
64
64
|
}
|
|
65
65
|
}
|