intelicoreact 1.5.17 → 1.5.19

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.
@@ -15,8 +15,6 @@ var _utils2 = require("./partials/_utils");
15
15
  require("./Hint.scss");
16
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
- // ToDo - не понятно зачем (ф-я не используется), но не трогаю
19
- const time = (Date.now() * Math.random() / 1000).toString().replace(/\./g, "_");
20
18
  const Hint = _ref => {
21
19
  var _ref2, _label$replace;
22
20
  let {
@@ -37,6 +35,7 @@ const Hint = _ref => {
37
35
  isHoverableContent = false
38
36
  } = _ref;
39
37
  const hintRef = (0, _react.useRef)(null);
38
+ const timeoutRef = (0, _react.useRef)(null);
40
39
  const [hintId] = (0, _react.useState)((_ref2 = key !== null && key !== void 0 ? key : id) !== null && _ref2 !== void 0 ? _ref2 : Math.random().toString(16).slice(2));
41
40
  const [isOpen, setIsOpen] = (0, _react.useState)(false);
42
41
 
@@ -117,13 +116,32 @@ const Hint = _ref => {
117
116
  if (!hc) return null;
118
117
  return /*#__PURE__*/(0, _reactDom.createPortal)(getHintMarkUp(className), hc);
119
118
  };
119
+ const handle = {
120
+ onMouseEnter: () => {
121
+ if (handleOpenType === "hover") {
122
+ timeoutRef.current = setTimeout(() => {
123
+ setIsOpen(true);
124
+ !isOpen && onClickCallback();
125
+ }, 350);
126
+ }
127
+ },
128
+ onMouseLeave: () => {
129
+ if (!isHoverableContent && handleOpenType === "hover") {
130
+ clearTimeout(timeoutRef.current);
131
+ timeoutRef.current = setTimeout(() => {
132
+ setIsOpen(false);
133
+ }, 1000);
134
+ }
135
+ }
136
+ };
120
137
  (0, _react.useEffect)(() => {
121
138
  (0, _utils2.initHintContainer)(hintId, hintContainer);
139
+ return () => {
140
+ clearTimeout(timeoutRef.current);
141
+ };
122
142
  }, []);
123
143
  (0, _react.useEffect)(() => {
124
144
  setHintContainerStyles();
125
-
126
- //! Обеспечиваем работу колбэка ТОЛЬКО для открытых тултипов
127
145
  if (isOpen) {
128
146
  document.addEventListener("scroll", handleScroll, true);
129
147
  document.addEventListener("click", handleClickOutside, true);
@@ -131,6 +149,9 @@ const Hint = _ref => {
131
149
  document.removeEventListener("scroll", handleScroll, true);
132
150
  document.removeEventListener("click", handleClickOutside, true);
133
151
  }
152
+ return () => {
153
+ clearTimeout(timeoutRef.current);
154
+ };
134
155
  }, [isOpen]);
135
156
  return /*#__PURE__*/_react.default.createElement("div", {
136
157
  className: (0, _classnames.default)("hint", className),
@@ -140,8 +161,8 @@ const Hint = _ref => {
140
161
  "data-testid": typeof label === "string" && label.length ? (_label$replace = label.replace) === null || _label$replace === void 0 ? void 0 : _label$replace.call(label, /\s/g, "-") : testId,
141
162
  "aria-label": isAccessability && label || "",
142
163
  onClick: () => handleOpenType === "click" && (isCallbackExist ? onClickCallback() : setIsOpen(!isOpen)),
143
- onMouseEnter: () => handleOpenType === "hover" && setIsOpen(true),
144
- onMouseLeave: () => !isHoverableContent && handleOpenType === "hover" && setIsOpen(false),
164
+ onMouseEnter: handle.onMouseEnter,
165
+ onMouseLeave: handle.onMouseLeave,
145
166
  className: (0, _classnames.default)("hint__button", {
146
167
  hint__button_active: isOpen
147
168
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "1.5.17",
3
+ "version": "1.5.19",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [