@rc-component/portal 1.0.0-5 → 1.0.0-6
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/es/Portal.d.ts +2 -0
- package/es/Portal.js +6 -2
- package/lib/Portal.d.ts +2 -0
- package/lib/Portal.js +6 -2
- package/package.json +1 -1
package/es/Portal.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface PortalProps {
|
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
/** Show the portal children */
|
|
9
9
|
open?: boolean;
|
|
10
|
+
/** Remove `children` when `open` is `false`. Set `false` will not handle remove process */
|
|
11
|
+
autoDestroy?: boolean;
|
|
10
12
|
/** Lock screen scroll when open */
|
|
11
13
|
autoLock?: boolean;
|
|
12
14
|
/** @private debug name. Do not use in prod */
|
package/es/Portal.js
CHANGED
|
@@ -32,6 +32,8 @@ export default function Portal(props) {
|
|
|
32
32
|
autoLock = props.autoLock,
|
|
33
33
|
getContainer = props.getContainer,
|
|
34
34
|
debug = props.debug,
|
|
35
|
+
_props$autoDestroy = props.autoDestroy,
|
|
36
|
+
autoDestroy = _props$autoDestroy === void 0 ? true : _props$autoDestroy,
|
|
35
37
|
children = props.children;
|
|
36
38
|
|
|
37
39
|
var _React$useState = React.useState(open),
|
|
@@ -42,8 +44,10 @@ export default function Portal(props) {
|
|
|
42
44
|
useScrollLocker(autoLock && open); // ====================== Should Render ======================
|
|
43
45
|
|
|
44
46
|
React.useEffect(function () {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
if (autoDestroy || open) {
|
|
48
|
+
setMergedRender(open);
|
|
49
|
+
}
|
|
50
|
+
}, [open, autoDestroy]); // ======================== Container ========================
|
|
47
51
|
|
|
48
52
|
var _React$useState3 = React.useState(function () {
|
|
49
53
|
return getPortalContainer(getContainer);
|
package/lib/Portal.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface PortalProps {
|
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
/** Show the portal children */
|
|
9
9
|
open?: boolean;
|
|
10
|
+
/** Remove `children` when `open` is `false`. Set `false` will not handle remove process */
|
|
11
|
+
autoDestroy?: boolean;
|
|
10
12
|
/** Lock screen scroll when open */
|
|
11
13
|
autoLock?: boolean;
|
|
12
14
|
/** @private debug name. Do not use in prod */
|
package/lib/Portal.js
CHANGED
|
@@ -50,6 +50,8 @@ function Portal(props) {
|
|
|
50
50
|
autoLock = props.autoLock,
|
|
51
51
|
getContainer = props.getContainer,
|
|
52
52
|
debug = props.debug,
|
|
53
|
+
_props$autoDestroy = props.autoDestroy,
|
|
54
|
+
autoDestroy = _props$autoDestroy === void 0 ? true : _props$autoDestroy,
|
|
53
55
|
children = props.children;
|
|
54
56
|
|
|
55
57
|
var _React$useState = React.useState(open),
|
|
@@ -60,8 +62,10 @@ function Portal(props) {
|
|
|
60
62
|
(0, _useScrollLocker.default)(autoLock && open); // ====================== Should Render ======================
|
|
61
63
|
|
|
62
64
|
React.useEffect(function () {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
if (autoDestroy || open) {
|
|
66
|
+
setMergedRender(open);
|
|
67
|
+
}
|
|
68
|
+
}, [open, autoDestroy]); // ======================== Container ========================
|
|
65
69
|
|
|
66
70
|
var _React$useState3 = React.useState(function () {
|
|
67
71
|
return getPortalContainer(getContainer);
|