@kep-platform/basic-component 0.4.0 → 0.5.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.
@@ -17,6 +17,18 @@ var PopupBox = styled('div').withConfig({
17
17
  })(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: var(--kep-platform-color-bg-base);\n padding: var(--kep-platform-padding-xs);\n border-radius: var(--kep-platform-border-radius-sm);\n position: fixed;\n box-shadow: var(--kep-platform-box-shadow);\n z-index: 999;\n ", ";\n"])), function (props) {
18
18
  if (props.visible) return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n left: ", "px;\n top: ", "px;\n "])), props.left || -999, props.top || -999);else return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n left: -9999px;\n top: -9999px;\n "])));
19
19
  });
20
+ var PortalComponent = function PortalComponent(_ref) {
21
+ var children = _ref.children,
22
+ rootId = _ref.rootId;
23
+ var portalRoot = document.getElementById(rootId);
24
+ if (!portalRoot) {
25
+ var newPortalRoot = document.createElement('div');
26
+ newPortalRoot.id = rootId;
27
+ document.body.appendChild(newPortalRoot);
28
+ return /*#__PURE__*/ReactDOM.createPortal(children, newPortalRoot);
29
+ }
30
+ if (portalRoot) return /*#__PURE__*/ReactDOM.createPortal(children, portalRoot);
31
+ };
20
32
  export function Popup(props) {
21
33
  var children = props.children,
22
34
  _props$trigger = props.trigger,
@@ -55,9 +67,9 @@ export function Popup(props) {
55
67
 
56
68
  var showPopupMenu = useCallback(function (e) {
57
69
  e.preventDefault();
58
- var _ref = e,
59
- clientX = _ref.clientX,
60
- clientY = _ref.clientY;
70
+ var _ref2 = e,
71
+ clientX = _ref2.clientX,
72
+ clientY = _ref2.clientY;
61
73
  setPos({
62
74
  left: clientX,
63
75
  top: clientY
@@ -82,12 +94,14 @@ export function Popup(props) {
82
94
  if (typeof outerVisible === 'boolean') setVisible(outerVisible);
83
95
  }, [outerVisible]);
84
96
  if ( /*#__PURE__*/React.isValidElement(children)) {
85
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(PopupBox, {
97
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PortalComponent, {
98
+ rootId: "popupContainer"
99
+ }, /*#__PURE__*/React.createElement(PopupBox, {
86
100
  left: pos.left,
87
101
  top: pos.top,
88
102
  visible: visible,
89
103
  ref: popupBox
90
- }, content), document.body), /*#__PURE__*/React.cloneElement(children, mergeProps));
104
+ }, content)), /*#__PURE__*/React.cloneElement(children, mergeProps));
91
105
  } else {
92
106
  return children;
93
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kep-platform/basic-component",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@ant-design/icons": "^5.3.7",
50
- "@kep-platform/hooks": "^0.4.0",
50
+ "@kep-platform/hooks": "^0.5.0",
51
51
  "color": "^4.2.3",
52
52
  "rc-pagination": "^4.1.0"
53
53
  },
@@ -87,5 +87,5 @@
87
87
  "authors": [
88
88
  "less-step-jss 1599925910@qq.com"
89
89
  ],
90
- "gitHead": "433e7c5aa465be1963b61bcfb379aa9ab81b18b6"
90
+ "gitHead": "4696479c9098c9c784e45a05eb205f148fb84b93"
91
91
  }