ag-common 0.0.680 → 0.0.681

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.
@@ -39,14 +39,22 @@ const Comp = ({ pos, children, }) => {
39
39
  const ref = (0, react_1.createRef)();
40
40
  const [size, setSize] = (0, react_1.useState)();
41
41
  (0, react_1.useEffect)(() => {
42
- var _a;
43
- if ((((_a = size === null || size === void 0 ? void 0 : size.p) === null || _a === void 0 ? void 0 : _a.tooltipHeight) && size.p.tooltipWidth) || !ref.current) {
42
+ var _a, _b;
43
+ if (!ref.current) {
44
+ return;
45
+ }
46
+ const tooltipWidth = Math.max(ref.current.clientWidth, ref.current.scrollWidth);
47
+ const tooltipHeight = Math.max(ref.current.clientHeight, ref.current.scrollHeight);
48
+ if (tooltipHeight === ((_a = size === null || size === void 0 ? void 0 : size.p) === null || _a === void 0 ? void 0 : _a.tooltipHeight) ||
49
+ tooltipWidth === ((_b = size === null || size === void 0 ? void 0 : size.p) === null || _b === void 0 ? void 0 : _b.tooltipWidth) ||
50
+ tooltipHeight === 0 ||
51
+ tooltipWidth === 0) {
44
52
  return;
45
53
  }
46
54
  setSize({
47
55
  p: {
48
- tooltipWidth: ref.current.clientWidth,
49
- tooltipHeight: ref.current.clientHeight,
56
+ tooltipWidth,
57
+ tooltipHeight,
50
58
  },
51
59
  });
52
60
  }, [ref, size]);
@@ -60,21 +68,24 @@ const Comp = ({ pos, children, }) => {
60
68
  const gap = 5;
61
69
  if (size === null || size === void 0 ? void 0 : size.p) {
62
70
  left = pos.x + gap;
71
+ const newRight = pos.parentWidth - pos.x + gap;
63
72
  if (pos.x + gap + size.p.tooltipWidth > pos.parentWidth) {
64
73
  left = undefined;
65
- right = pos.parentWidth - pos.x + gap;
74
+ right = newRight;
66
75
  }
67
76
  //
68
77
  top = pos.y + gap;
69
- const newBottom = pos.parentHeight - size.p.tooltipHeight;
70
- if (top + size.p.tooltipHeight > pos.parentHeight &&
71
- //check against really tall
72
- newBottom > 0) {
78
+ if (top + size.p.tooltipHeight > pos.parentHeight) {
73
79
  top = undefined;
74
80
  bottom = pos.parentHeight - pos.y;
75
- if (bottom + size.p.tooltipHeight > pos.parentHeight) {
76
- bottom = newBottom;
77
- }
81
+ }
82
+ if (right && right + size.p.tooltipWidth > pos.parentWidth) {
83
+ right = undefined;
84
+ left = 0;
85
+ }
86
+ if (bottom && bottom + size.p.tooltipHeight > pos.parentHeight) {
87
+ bottom = undefined;
88
+ top = 0;
78
89
  }
79
90
  }
80
91
  const Content = (react_1.default.createElement(Base, { ref: ref, style: Object.assign(Object.assign({ left,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.680",
2
+ "version": "0.0.681",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",