intelicoreact 1.4.65 → 1.4.66
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.
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.initHintContainer = exports.getParentNode = exports.getHintContainerId = exports.getHintContainer = exports.HandleScrollObj = exports.HandleClickOutsideObj = void 0;
|
|
7
|
+
const getHintContainerId = hintId => "hint-container-for-hint--id-".concat(hintId);
|
|
8
|
+
exports.getHintContainerId = getHintContainerId;
|
|
9
|
+
const getHintContainer = hintId => {
|
|
10
|
+
return document.getElementById(getHintContainerId(hintId));
|
|
11
|
+
};
|
|
12
|
+
exports.getHintContainer = getHintContainer;
|
|
13
|
+
const getParentNode = () => {
|
|
14
|
+
var _ref, _document$querySelect;
|
|
15
|
+
return (_ref = (_document$querySelect = document.querySelector("div#root")) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector("div#app")) !== null && _ref !== void 0 ? _ref : document.body;
|
|
16
|
+
};
|
|
17
|
+
exports.getParentNode = getParentNode;
|
|
18
|
+
const initHintContainer = (hintId, hintContainerSettings) => {
|
|
19
|
+
var _getParentNode;
|
|
20
|
+
const {
|
|
21
|
+
className
|
|
22
|
+
} = hintContainerSettings;
|
|
23
|
+
const hintContainer = document.createElement("div");
|
|
24
|
+
hintContainer.setAttribute("id", getHintContainerId(hintId));
|
|
25
|
+
hintContainer.classList.add("hint__container");
|
|
26
|
+
if (className) hintContainer.classList.add(className);
|
|
27
|
+
(_getParentNode = getParentNode()) === null || _getParentNode === void 0 || _getParentNode.append(hintContainer);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//? addEventListener можно инициализировать двумя способами
|
|
31
|
+
//? - передать прямой колбэк (ф-ю)
|
|
32
|
+
//? - передать объект в котором есть метод handleEvent (помимо handleEvent можно записать в this прочие полезные значения)
|
|
33
|
+
//? Пользуемся вторым способом, чтобы записать входные данные (вообще можно не писать, работает и просто от замыкания, но делаем по "дзену")
|
|
34
|
+
//! Метод написан с расчетом на то, что будет вызываться ТОЛЬКО открытым тултипом
|
|
35
|
+
exports.initHintContainer = initHintContainer;
|
|
36
|
+
const HandleScrollObj = function (setIsOpen) {
|
|
37
|
+
this.setIsOpen = setIsOpen;
|
|
38
|
+
this.handleEvent = function () {
|
|
39
|
+
this.setIsOpen(false);
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.HandleScrollObj = HandleScrollObj;
|
|
43
|
+
const HandleClickOutsideObj = function (id, setIsOpen) {
|
|
44
|
+
this.id = id;
|
|
45
|
+
this.setIsOpen = setIsOpen;
|
|
46
|
+
this.handleEvent = function (event) {
|
|
47
|
+
if (!getHintContainer(this.id).contains(event === null || event === void 0 ? void 0 : event.target)) {
|
|
48
|
+
this.setIsOpen(false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
exports.HandleClickOutsideObj = HandleClickOutsideObj;
|