linear-react-components-ui 1.1.25-beta.3 → 1.1.25-beta.5

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.
@@ -1,6 +1,7 @@
1
1
  @import "colors.scss";
2
2
 
3
3
  .tooltip-component {
4
+ --arrow-position: 50%;
4
5
  font-family: 'Roboto', sans-serif;
5
6
  position: absolute;
6
7
  padding: 8px;
@@ -13,7 +14,7 @@
13
14
  z-index: 999999;
14
15
  pointer-events: none;
15
16
  max-width: 300px;
16
- word-break: break-word;
17
+ word-break: break-word;
17
18
  &.left::after {
18
19
  content: " ";
19
20
  position: absolute;
@@ -34,11 +35,11 @@
34
35
  border-style: solid;
35
36
  border-color: transparent rgba(black, 0.85) transparent transparent;
36
37
  }
37
- &.top::after {
38
+ &.top::after {
38
39
  content: " ";
39
40
  position: absolute;
40
41
  top: 100%;
41
- left: 50%;
42
+ left: var(--arrow-position);
42
43
  margin-left: -5px;
43
44
  border-width: 5px;
44
45
  border-style: solid;
@@ -48,7 +49,7 @@
48
49
  content: " ";
49
50
  position: absolute;
50
51
  bottom: 100%;
51
- left: 50%;
52
+ left: var(--arrow-position);
52
53
  margin-left: -5px;
53
54
  border-width: 5px;
54
55
  border-style: solid;
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("../assets/styles/tooltip.scss");
7
8
  var _react = _interopRequireWildcard(require("react"));
8
9
  var _reactDom = _interopRequireDefault(require("react-dom"));
9
10
  var uuid = _interopRequireWildcard(require("uuid"));
10
- require("../assets/styles/tooltip.scss");
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
13
  const TooltipContent = _ref => {
@@ -113,6 +113,31 @@ function useTooltip(_ref) {
113
113
  setTooltipStyle(style);
114
114
  }
115
115
  }, [tooltipDimensions, stateTooltipPosition]);
116
+ (0, _react.useEffect)(() => {
117
+ if (targetElement.current && tooltipElement.current && showTooltip) {
118
+ var _targetElement$curren, _targetElement$curren2;
119
+ const targetRect = (_targetElement$curren = (_targetElement$curren2 = targetElement.current) === null || _targetElement$curren2 === void 0 ? void 0 : _targetElement$curren2.getBoundingClientRect()) !== null && _targetElement$curren !== void 0 ? _targetElement$curren : {
120
+ x: 0,
121
+ width: 0
122
+ };
123
+ const elementHorizontalPosition = targetRect.x;
124
+ const widthElement = targetRect.width;
125
+ const centerOfElement = elementHorizontalPosition + widthElement / 2;
126
+ requestAnimationFrame(() => {
127
+ var _tooltipElement$curre, _tooltipElement$curre2, _tooltipElement$curre3;
128
+ const tooltipRect = (_tooltipElement$curre = (_tooltipElement$curre2 = tooltipElement.current) === null || _tooltipElement$curre2 === void 0 ? void 0 : _tooltipElement$curre2.getBoundingClientRect()) !== null && _tooltipElement$curre !== void 0 ? _tooltipElement$curre : {
129
+ x: 0,
130
+ width: 0
131
+ };
132
+ const tooltipHorizontalPosition = tooltipRect.x;
133
+ const widthTooltip = tooltipRect.width;
134
+ const centerOfTooltip = tooltipHorizontalPosition + widthTooltip / 2;
135
+ const centerDifferenceBetweenElementAndTooltip = Number(((centerOfElement - centerOfTooltip) / widthTooltip * 100).toFixed(2));
136
+ const sumDifference = (0.5 + centerDifferenceBetweenElementAndTooltip / 100) * 100;
137
+ (_tooltipElement$curre3 = tooltipElement.current) === null || _tooltipElement$curre3 === void 0 ? void 0 : _tooltipElement$curre3.style.setProperty('--arrow-position', "".concat(sumDifference, "%"));
138
+ });
139
+ }
140
+ }, [showTooltip, tooltipElement.current, targetElement.current]);
116
141
  (0, _react.useEffect)(() => {
117
142
  setStateTooltipPosition(positionProp);
118
143
  }, [window.scrollY, window.scrollX, window.innerWidth]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.1.25-beta.3",
3
+ "version": "1.1.25-beta.5",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",