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.
Files changed (63) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/components/ui/modal/Modal.d.ts +1 -0
  3. package/dist/components/ui/modal/Modal.d.ts.map +1 -1
  4. package/dist/components/ui/modal/Modal.js +8 -2
  5. package/dist/components/ui/modal/Modal.js.map +1 -1
  6. package/docs/classes/Drawer.html +14 -14
  7. package/docs/classes/Pop.html +14 -14
  8. package/docs/classes/ToasterProvider.html +10 -10
  9. package/docs/enums/ICON.html +14 -14
  10. package/docs/functions/Action.html +4 -4
  11. package/docs/functions/Button.html +4 -4
  12. package/docs/functions/Card.html +4 -4
  13. package/docs/functions/Checkbox.html +4 -4
  14. package/docs/functions/Choice.html +5 -5
  15. package/docs/functions/DirectionPad.html +4 -4
  16. package/docs/functions/EqualActions.html +4 -4
  17. package/docs/functions/HandleEsc.html +4 -4
  18. package/docs/functions/Header.html +4 -4
  19. package/docs/functions/HeaderIconAction.html +4 -4
  20. package/docs/functions/Icon-1.html +4 -4
  21. package/docs/functions/If.html +4 -4
  22. package/docs/functions/Input.html +5 -5
  23. package/docs/functions/Item-1.html +4 -4
  24. package/docs/functions/KeyValue.html +4 -4
  25. package/docs/functions/Label.html +4 -4
  26. package/docs/functions/List-1.html +4 -4
  27. package/docs/functions/Message.html +4 -4
  28. package/docs/functions/Modal-1.html +4 -4
  29. package/docs/functions/ModalButtons-1.html +4 -4
  30. package/docs/functions/PopOption.html +4 -4
  31. package/docs/functions/SearchContainer.html +4 -4
  32. package/docs/functions/Section-1.html +4 -4
  33. package/docs/functions/Select.html +4 -4
  34. package/docs/functions/Selector.html +5 -5
  35. package/docs/functions/Spacer.html +4 -4
  36. package/docs/functions/Stats.html +4 -4
  37. package/docs/functions/StickyHeader-1.html +4 -4
  38. package/docs/functions/StickyHeader.Content.html +5 -5
  39. package/docs/functions/Table.html +4 -4
  40. package/docs/functions/TextArea.html +4 -4
  41. package/docs/functions/Toggle.html +4 -4
  42. package/docs/functions/useToaster.html +5 -5
  43. package/docs/index.html +4 -4
  44. package/docs/modules/Item.html +7 -7
  45. package/docs/modules/List.html +6 -6
  46. package/docs/modules/Modal.html +6 -6
  47. package/docs/modules/ModalButtons.html +6 -6
  48. package/docs/modules/Section.html +6 -6
  49. package/docs/modules/StickyHeader.html +6 -6
  50. package/docs/modules.html +4 -4
  51. package/docs/pages/tutorials/Test.html +4 -4
  52. package/docs/variables/Item.Label.html +5 -5
  53. package/docs/variables/Item.Value.html +5 -5
  54. package/docs/variables/List.Header.html +5 -5
  55. package/docs/variables/Modal.NegateMargin.html +5 -5
  56. package/docs/variables/ModalButtons.Button.html +5 -5
  57. package/docs/variables/Section.Container.html +5 -5
  58. package/esm/components/ui/modal/Modal.d.ts +1 -0
  59. package/esm/components/ui/modal/Modal.d.ts.map +1 -1
  60. package/esm/components/ui/modal/Modal.js +8 -2
  61. package/esm/components/ui/modal/Modal.js.map +1 -1
  62. package/package.json +15 -14
  63. 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
- return (
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