react-miui 0.17.1 → 0.17.2
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/CHANGELOG.md +6 -0
- package/dist/components/ui/modal/Modal.d.ts +1 -0
- package/dist/components/ui/modal/Modal.d.ts.map +1 -1
- package/dist/components/ui/modal/Modal.js +8 -2
- package/dist/components/ui/modal/Modal.js.map +1 -1
- package/docs/classes/Drawer.html +14 -14
- package/docs/classes/Pop.html +14 -14
- package/docs/classes/ToasterProvider.html +10 -10
- package/docs/enums/ICON.html +14 -14
- package/docs/functions/Action.html +4 -4
- package/docs/functions/Button.html +4 -4
- package/docs/functions/Card.html +4 -4
- package/docs/functions/Checkbox.html +4 -4
- package/docs/functions/Choice.html +5 -5
- package/docs/functions/DirectionPad.html +4 -4
- package/docs/functions/EqualActions.html +4 -4
- package/docs/functions/HandleEsc.html +4 -4
- package/docs/functions/Header.html +4 -4
- package/docs/functions/HeaderIconAction.html +4 -4
- package/docs/functions/Icon-1.html +4 -4
- package/docs/functions/If.html +4 -4
- package/docs/functions/Input.html +5 -5
- package/docs/functions/Item-1.html +4 -4
- package/docs/functions/KeyValue.html +4 -4
- package/docs/functions/Label.html +4 -4
- package/docs/functions/List-1.html +4 -4
- package/docs/functions/Message.html +4 -4
- package/docs/functions/Modal-1.html +4 -4
- package/docs/functions/ModalButtons-1.html +4 -4
- package/docs/functions/PopOption.html +4 -4
- package/docs/functions/SearchContainer.html +4 -4
- package/docs/functions/Section-1.html +4 -4
- package/docs/functions/Select.html +4 -4
- package/docs/functions/Selector.html +5 -5
- package/docs/functions/Spacer.html +4 -4
- package/docs/functions/Stats.html +4 -4
- package/docs/functions/StickyHeader-1.html +4 -4
- package/docs/functions/StickyHeader.Content.html +5 -5
- package/docs/functions/Table.html +4 -4
- package/docs/functions/TextArea.html +4 -4
- package/docs/functions/Toggle.html +4 -4
- package/docs/functions/useToaster.html +5 -5
- package/docs/index.html +4 -4
- package/docs/modules/Item.html +7 -7
- package/docs/modules/List.html +6 -6
- package/docs/modules/Modal.html +6 -6
- package/docs/modules/ModalButtons.html +6 -6
- package/docs/modules/Section.html +6 -6
- package/docs/modules/StickyHeader.html +6 -6
- package/docs/modules.html +4 -4
- package/docs/pages/tutorials/Test.html +4 -4
- package/docs/variables/Item.Label.html +5 -5
- package/docs/variables/Item.Value.html +5 -5
- package/docs/variables/List.Header.html +5 -5
- package/docs/variables/Modal.NegateMargin.html +5 -5
- package/docs/variables/ModalButtons.Button.html +5 -5
- package/docs/variables/Section.Container.html +5 -5
- package/esm/components/ui/modal/Modal.d.ts +1 -0
- package/esm/components/ui/modal/Modal.d.ts.map +1 -1
- package/esm/components/ui/modal/Modal.js +8 -2
- package/esm/components/ui/modal/Modal.js.map +1 -1
- package/package.json +15 -14
- package/src/components/ui/modal/Modal.tsx +11 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import classnames from "classnames";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
4
5
|
|
|
5
6
|
import { makeVariants } from "../../../utils/index.js";
|
|
6
7
|
|
|
@@ -17,6 +18,7 @@ interface Props {
|
|
|
17
18
|
title?: React.ReactNode;
|
|
18
19
|
className?: string;
|
|
19
20
|
variant?: Variant | Variant[];
|
|
21
|
+
portal?: boolean | HTMLElement;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
interface SubComponents {
|
|
@@ -32,6 +34,7 @@ const Modal: React.FC<Props> & SubComponents = ({
|
|
|
32
34
|
className,
|
|
33
35
|
onOverlayClick = "close",
|
|
34
36
|
closeOnEsc = true,
|
|
37
|
+
portal = true,
|
|
35
38
|
variant,
|
|
36
39
|
}) => {
|
|
37
40
|
const [isClosing, setIsClosing] = useState(false);
|
|
@@ -119,7 +122,7 @@ const Modal: React.FC<Props> & SubComponents = ({
|
|
|
119
122
|
[styles.full]: v.includes("full"),
|
|
120
123
|
});
|
|
121
124
|
|
|
122
|
-
|
|
125
|
+
const tree = (
|
|
123
126
|
<div
|
|
124
127
|
className={overlayCls}
|
|
125
128
|
onClick={handleOverlayClick}
|
|
@@ -132,6 +135,13 @@ const Modal: React.FC<Props> & SubComponents = ({
|
|
|
132
135
|
</div>
|
|
133
136
|
</div>
|
|
134
137
|
);
|
|
138
|
+
|
|
139
|
+
if (portal) {
|
|
140
|
+
const root = typeof portal === "boolean" ? document.body : portal;
|
|
141
|
+
return createPortal(tree, root);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return tree;
|
|
135
145
|
};
|
|
136
146
|
Modal.NegateMargin = ModalNegateMargin;
|
|
137
147
|
|