intelicoreact 0.3.69 → 0.3.70
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.
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +81 -11
- package/dist/Atomic/FormElements/Dropdown/Dropdown.scss +10 -1
- package/dist/Atomic/FormElements/RangeSlider/RangeSlider.js +39 -5
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +15 -4
- package/dist/Atomic/UI/Hint/Hint.js +68 -6
- package/dist/Atomic/UI/Hint/Hint.scss +10 -3
- package/dist/Classes/AbortableFetch.js +24 -11
- package/package.json +2 -2
|
@@ -29,6 +29,8 @@ require("./Dropdown.scss");
|
|
|
29
29
|
|
|
30
30
|
var _fieldValueFormatters = require("../../../Functions/fieldValueFormatters");
|
|
31
31
|
|
|
32
|
+
var _reactDom = require("react-dom");
|
|
33
|
+
|
|
32
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
35
|
|
|
34
36
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -56,7 +58,10 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
56
58
|
isListTop = _ref.isListTop,
|
|
57
59
|
_ref$isNotValidateASC = _ref.isNotValidateASCII,
|
|
58
60
|
isNotValidateASCII = _ref$isNotValidateASC === void 0 ? false : _ref$isNotValidateASC,
|
|
59
|
-
testId = _ref.testId
|
|
61
|
+
testId = _ref.testId,
|
|
62
|
+
fieldKey = _ref.fieldKey,
|
|
63
|
+
id = _ref.id;
|
|
64
|
+
var dropdownId = fieldKey || id;
|
|
60
65
|
|
|
61
66
|
var _useState = (0, _react.useState)(false),
|
|
62
67
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -76,6 +81,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
76
81
|
isFocusedByClick = _useState6[0],
|
|
77
82
|
setIsFocusedByClick = _useState6[1];
|
|
78
83
|
|
|
84
|
+
var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
79
85
|
if (!options) return null;
|
|
80
86
|
|
|
81
87
|
var moveOtherToEnd = function moveOtherToEnd(options) {
|
|
@@ -157,9 +163,11 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
157
163
|
};
|
|
158
164
|
|
|
159
165
|
var handleClickOutside = function handleClickOutside(event) {
|
|
160
|
-
|
|
166
|
+
var _getListContainer;
|
|
167
|
+
|
|
168
|
+
if (!((_getListContainer = getListContainer()) !== null && _getListContainer !== void 0 && _getListContainer.contains(event.target))) {
|
|
161
169
|
setIsOpen(false);
|
|
162
|
-
setSearchValue(
|
|
170
|
+
setSearchValue('');
|
|
163
171
|
}
|
|
164
172
|
};
|
|
165
173
|
|
|
@@ -242,6 +250,75 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
242
250
|
if (isWithAnyScrolling) callback(e);else if (Math.round(e.target.clientHeight + e.target.scrollTop + scrollingInaccuracy) >= e.target.scrollHeight) callback(e);
|
|
243
251
|
}
|
|
244
252
|
}, [filteredOptions]);
|
|
253
|
+
|
|
254
|
+
var getParentNode = function getParentNode() {
|
|
255
|
+
var _document$querySelect;
|
|
256
|
+
|
|
257
|
+
return (_document$querySelect = document.querySelector('div#root')) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('div#app');
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
var initListContainer = function initListContainer() {
|
|
261
|
+
var dropdownList = document.createElement('div');
|
|
262
|
+
dropdownList.setAttribute('id', dropdownId);
|
|
263
|
+
dropdownList.classList.add('dropdown__container');
|
|
264
|
+
getParentNode().append(dropdownList);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
var getListContainer = function getListContainer() {
|
|
268
|
+
return document.getElementById(dropdownId);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
var setListContainerStyles = function setListContainerStyles() {
|
|
272
|
+
var _sw$getBoundingClient;
|
|
273
|
+
|
|
274
|
+
var lc = getListContainer();
|
|
275
|
+
if (!lc || !isOpen) return false;
|
|
276
|
+
|
|
277
|
+
var _dropdownRef$current$ = dropdownRef === null || dropdownRef === void 0 ? void 0 : dropdownRef.current.getBoundingClientRect(),
|
|
278
|
+
width = _dropdownRef$current$.width,
|
|
279
|
+
height = _dropdownRef$current$.height,
|
|
280
|
+
left = _dropdownRef$current$.left,
|
|
281
|
+
top = _dropdownRef$current$.top,
|
|
282
|
+
bottom = _dropdownRef$current$.bottom;
|
|
283
|
+
|
|
284
|
+
var sw = lc.getElementsByClassName('dropdown__list')[0];
|
|
285
|
+
var swHeight = sw === null || sw === void 0 ? void 0 : (_sw$getBoundingClient = sw.getBoundingClientRect()) === null || _sw$getBoundingClient === void 0 ? void 0 : _sw$getBoundingClient.height;
|
|
286
|
+
lc.style.width = "".concat(width, "px");
|
|
287
|
+
lc.style.left = "".concat(left, "px");
|
|
288
|
+
lc.style.top = "".concat(windowHeight - top - height >= swHeight ? top + height : top - swHeight, "px");
|
|
289
|
+
lc.style.maxHeight = "".concat(swHeight, "px");
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
var renderListContainer = function renderListContainer() {
|
|
293
|
+
var lc = getListContainer();
|
|
294
|
+
if (!lc) return null;
|
|
295
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)(getListMarkUp(), lc);
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
var getListMarkUp = function getListMarkUp() {
|
|
299
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
300
|
+
className: (0, _classnames.default)("".concat(RC, "__list"), (0, _defineProperty2.default)({}, "".concat(RC, "__list-top"), isListTop)),
|
|
301
|
+
ref: dropdownListRef
|
|
302
|
+
}, depend.options.map(function (filteredOption) {
|
|
303
|
+
var _filteredOption$items2;
|
|
304
|
+
|
|
305
|
+
return (_filteredOption$items2 = filteredOption.items) !== null && _filteredOption$items2 !== void 0 && _filteredOption$items2.length ? filteredOptionList(filteredOption) : getMarkupForElement(filteredOption);
|
|
306
|
+
}), disabled && isOpen && /*#__PURE__*/_react.default.createElement(_DropdownLoader.default, null));
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
var closeList = handleClickOutside;
|
|
310
|
+
(0, _react.useEffect)(initListContainer, []);
|
|
311
|
+
(0, _react.useLayoutEffect)(function () {
|
|
312
|
+
window.addEventListener('resize', setListContainerStyles);
|
|
313
|
+
window.addEventListener('mousewheel', closeList);
|
|
314
|
+
return function () {
|
|
315
|
+
window.removeEventListener('resize', setListContainerStyles);
|
|
316
|
+
window.removeEventListener('mousewheel', closeList);
|
|
317
|
+
};
|
|
318
|
+
}, [getListContainer]);
|
|
319
|
+
(0, _react.useEffect)(function () {
|
|
320
|
+
setListContainerStyles();
|
|
321
|
+
}, [isOpen]);
|
|
245
322
|
(0, _react.useEffect)(function () {
|
|
246
323
|
if (!value) setSearchValue(null);
|
|
247
324
|
document.addEventListener('click', handleClickOutside, true);
|
|
@@ -315,14 +392,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
315
392
|
onClick: function onClick() {
|
|
316
393
|
return setIsOpen(!isOpen);
|
|
317
394
|
}
|
|
318
|
-
}, isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen &&
|
|
319
|
-
className: (0, _classnames.default)("".concat(RC, "__list"), (0, _defineProperty2.default)({}, "".concat(RC, "__list-top"), isListTop)),
|
|
320
|
-
ref: dropdownListRef
|
|
321
|
-
}, depend.options.map(function (filteredOption) {
|
|
322
|
-
var _filteredOption$items2;
|
|
323
|
-
|
|
324
|
-
return (_filteredOption$items2 = filteredOption.items) !== null && _filteredOption$items2 !== void 0 && _filteredOption$items2.length ? filteredOptionList(filteredOption) : getMarkupForElement(filteredOption);
|
|
325
|
-
}), disabled && isOpen && /*#__PURE__*/_react.default.createElement(_DropdownLoader.default, null)));
|
|
395
|
+
}, isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen && renderListContainer());
|
|
326
396
|
};
|
|
327
397
|
|
|
328
398
|
var _default = Dropdown;
|
|
@@ -7,6 +7,13 @@
|
|
|
7
7
|
width: 100%;
|
|
8
8
|
border-radius: 7px;
|
|
9
9
|
|
|
10
|
+
&__container {
|
|
11
|
+
display: block;
|
|
12
|
+
position: fixed;
|
|
13
|
+
z-index: 99999;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
&__trigger {
|
|
11
18
|
background: #ffffff;
|
|
12
19
|
border: 1px solid #e2e5ec;
|
|
@@ -58,7 +65,6 @@
|
|
|
58
65
|
padding: 5px 0;
|
|
59
66
|
max-height: 320px;
|
|
60
67
|
overflow-y: auto;
|
|
61
|
-
position: absolute;
|
|
62
68
|
top: 100%;
|
|
63
69
|
z-index: 6;
|
|
64
70
|
|
|
@@ -105,6 +111,9 @@
|
|
|
105
111
|
line-height: 20px;
|
|
106
112
|
letter-spacing: 0.2px;
|
|
107
113
|
position: relative;
|
|
114
|
+
width: 100%;
|
|
115
|
+
text-align: left;
|
|
116
|
+
|
|
108
117
|
&:after {
|
|
109
118
|
content: "";
|
|
110
119
|
position: absolute;
|
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.default = RangeSlider;
|
|
11
11
|
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
12
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
15
|
|
|
14
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -27,6 +29,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
27
29
|
|
|
28
30
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
31
|
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
+
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
35
|
+
|
|
30
36
|
// require('./lib/customEventListener.js');
|
|
31
37
|
function RangeSlider(_ref) {
|
|
32
38
|
var _value$from, _value$to;
|
|
@@ -161,7 +167,7 @@ function RangeSlider(_ref) {
|
|
|
161
167
|
};
|
|
162
168
|
|
|
163
169
|
var getRangeOffset = function getRangeOffset() {
|
|
164
|
-
return getTrackXByPoints(
|
|
170
|
+
return getTrackXByPoints(fromValue);
|
|
165
171
|
};
|
|
166
172
|
|
|
167
173
|
var getXByPoints = function getXByPoints(pts) {
|
|
@@ -182,13 +188,29 @@ function RangeSlider(_ref) {
|
|
|
182
188
|
if (validate) {
|
|
183
189
|
if (value < min) {
|
|
184
190
|
setFrom(min);
|
|
191
|
+
setFrezeedValues(function (v) {
|
|
192
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
193
|
+
from: min
|
|
194
|
+
});
|
|
195
|
+
});
|
|
185
196
|
return;
|
|
186
197
|
}
|
|
187
198
|
|
|
188
199
|
if (value > to - minRange) {
|
|
189
200
|
setFrom(to - minRange);
|
|
201
|
+
setFrezeedValues(function (v) {
|
|
202
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
203
|
+
from: to - minRange
|
|
204
|
+
});
|
|
205
|
+
});
|
|
190
206
|
return;
|
|
191
207
|
}
|
|
208
|
+
|
|
209
|
+
setFrezeedValues(function (v) {
|
|
210
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
211
|
+
from: value
|
|
212
|
+
});
|
|
213
|
+
});
|
|
192
214
|
}
|
|
193
215
|
|
|
194
216
|
setFrom(value);
|
|
@@ -198,13 +220,29 @@ function RangeSlider(_ref) {
|
|
|
198
220
|
if (validate) {
|
|
199
221
|
if (value > max) {
|
|
200
222
|
setTo(max);
|
|
223
|
+
setFrezeedValues(function (v) {
|
|
224
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
225
|
+
to: max
|
|
226
|
+
});
|
|
227
|
+
});
|
|
201
228
|
return;
|
|
202
229
|
}
|
|
203
230
|
|
|
204
231
|
if (value < from + minRange) {
|
|
205
232
|
setTo(from + minRange);
|
|
233
|
+
setFrezeedValues(function (v) {
|
|
234
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
235
|
+
to: from + minRange
|
|
236
|
+
});
|
|
237
|
+
});
|
|
206
238
|
return;
|
|
207
239
|
}
|
|
240
|
+
|
|
241
|
+
setFrezeedValues(function (v) {
|
|
242
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
243
|
+
to: value
|
|
244
|
+
});
|
|
245
|
+
});
|
|
208
246
|
}
|
|
209
247
|
|
|
210
248
|
setTo(value);
|
|
@@ -242,10 +280,6 @@ function RangeSlider(_ref) {
|
|
|
242
280
|
|
|
243
281
|
var onRangeInputBlur = function onRangeInputBlur(e, type) {
|
|
244
282
|
onRangeChange(type, type === 'from' ? from : to);
|
|
245
|
-
setFrezeedValues({
|
|
246
|
-
from: from,
|
|
247
|
-
to: to
|
|
248
|
-
});
|
|
249
283
|
};
|
|
250
284
|
|
|
251
285
|
(0, _react.useEffect)(function () {
|
|
@@ -87,6 +87,7 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
87
87
|
setSearchValue = _useState4[1];
|
|
88
88
|
|
|
89
89
|
var dropdownRef = (0, _react.useRef)(null);
|
|
90
|
+
var inputRef = (0, _react.useRef)(null);
|
|
90
91
|
var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
91
92
|
var singleLevelOptions = options === null || options === void 0 ? void 0 : options.reduce(function (acc, item) {
|
|
92
93
|
return [].concat((0, _toConsumableArray2.default)(acc), (0, _toConsumableArray2.default)(item.groupName ? item.list : [item]));
|
|
@@ -135,9 +136,11 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
135
136
|
};
|
|
136
137
|
|
|
137
138
|
var getMarkupForElement = function getMarkupForElement(item) {
|
|
139
|
+
var _title$toString;
|
|
140
|
+
|
|
138
141
|
var title = item.title || item.label;
|
|
139
142
|
return title.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '') ? /*#__PURE__*/_react.default.createElement("button", {
|
|
140
|
-
key:
|
|
143
|
+
key: title === null || title === void 0 ? void 0 : (_title$toString = title.toString()) === null || _title$toString === void 0 ? void 0 : _title$toString.replace(/ /g, '_'),
|
|
141
144
|
onClick: function onClick() {
|
|
142
145
|
return onChangeHandler(item);
|
|
143
146
|
},
|
|
@@ -239,10 +242,10 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
239
242
|
}, headerContent) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
240
243
|
className: "".concat(RC, "__list ").concat(headerContent ? "".concat(RC, "__list--with-header") : '', " ").concat(footerContent ? "".concat(RC, "__list--with-footer") : '')
|
|
241
244
|
}, (options === null || options === void 0 ? void 0 : options.length) > 0 ? options === null || options === void 0 ? void 0 : options.map(function (option) {
|
|
242
|
-
var _option$list;
|
|
245
|
+
var _option$groupName, _option$groupName$toS, _option$list;
|
|
243
246
|
|
|
244
247
|
return option.groupName ? /*#__PURE__*/_react.default.createElement("div", {
|
|
245
|
-
key: option.
|
|
248
|
+
key: (_option$groupName = option.groupName) === null || _option$groupName === void 0 ? void 0 : (_option$groupName$toS = _option$groupName.toString()) === null || _option$groupName$toS === void 0 ? void 0 : _option$groupName$toS.replace(/ /g, '_').concat(Date.now()),
|
|
246
249
|
className: (0, _classnames.default)("".concat(RC, "-group"), option.className)
|
|
247
250
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
248
251
|
className: "".concat(RC, "-group__name")
|
|
@@ -257,7 +260,14 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
257
260
|
};
|
|
258
261
|
|
|
259
262
|
(0, _react.useEffect)(initListContainer, []);
|
|
260
|
-
|
|
263
|
+
|
|
264
|
+
var closeList = function closeList(e) {
|
|
265
|
+
var _inputRef$current;
|
|
266
|
+
|
|
267
|
+
handleClickOutside(e);
|
|
268
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.blur();
|
|
269
|
+
};
|
|
270
|
+
|
|
261
271
|
(0, _react.useLayoutEffect)(function () {
|
|
262
272
|
window.addEventListener('resize', setListContainerStyles);
|
|
263
273
|
window.addEventListener('mousewheel', closeList);
|
|
@@ -326,6 +336,7 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
326
336
|
}
|
|
327
337
|
});
|
|
328
338
|
}), chosenOptions.length === 0 || !noTagsWrap ? /*#__PURE__*/_react.default.createElement("input", {
|
|
339
|
+
ref: inputRef,
|
|
329
340
|
className: "".concat(RC, "__input"),
|
|
330
341
|
value: searchValue,
|
|
331
342
|
onChange: function onChange(e) {
|
|
@@ -19,11 +19,17 @@ var _reactFeather = require("react-feather");
|
|
|
19
19
|
|
|
20
20
|
require("./Hint.scss");
|
|
21
21
|
|
|
22
|
+
var _reactDom = require("react-dom");
|
|
23
|
+
|
|
22
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
25
|
|
|
24
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
27
|
|
|
28
|
+
var time = (Date.now() * Math.random() / 1000).toString().replace(/\./g, "_");
|
|
29
|
+
|
|
26
30
|
var Hint = function Hint(_ref) {
|
|
31
|
+
var _ref2;
|
|
32
|
+
|
|
27
33
|
var hint = _ref.hint,
|
|
28
34
|
_ref$side = _ref.side,
|
|
29
35
|
side = _ref$side === void 0 ? 'right' : _ref$side,
|
|
@@ -33,7 +39,10 @@ var Hint = function Hint(_ref) {
|
|
|
33
39
|
_ref$variant = _ref.variant,
|
|
34
40
|
variant = _ref$variant === void 0 ? 'filled' : _ref$variant,
|
|
35
41
|
_ref$handleOpenType = _ref.handleOpenType,
|
|
36
|
-
handleOpenType = _ref$handleOpenType === void 0 ? 'click' : _ref$handleOpenType
|
|
42
|
+
handleOpenType = _ref$handleOpenType === void 0 ? 'click' : _ref$handleOpenType,
|
|
43
|
+
key = _ref.key,
|
|
44
|
+
id = _ref.id;
|
|
45
|
+
var hintId = (_ref2 = key !== null && key !== void 0 ? key : id) !== null && _ref2 !== void 0 ? _ref2 : time;
|
|
37
46
|
|
|
38
47
|
var _useState = (0, _react.useState)(false),
|
|
39
48
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -41,13 +50,69 @@ var Hint = function Hint(_ref) {
|
|
|
41
50
|
setIsOpen = _useState2[1];
|
|
42
51
|
|
|
43
52
|
var hintRef = (0, _react.useRef)(null);
|
|
53
|
+
var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
44
54
|
|
|
45
55
|
var handleClickOutside = function handleClickOutside(event) {
|
|
46
|
-
if (
|
|
56
|
+
if (!getHintContainer().contains(event === null || event === void 0 ? void 0 : event.target)) {
|
|
47
57
|
setIsOpen(false);
|
|
48
58
|
}
|
|
49
59
|
};
|
|
50
60
|
|
|
61
|
+
var getParentNode = function getParentNode() {
|
|
62
|
+
var _document$querySelect;
|
|
63
|
+
|
|
64
|
+
return (_document$querySelect = document.querySelector('div#root')) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('div#app');
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var initHintContainer = function initHintContainer() {
|
|
68
|
+
var hint = document.createElement('div');
|
|
69
|
+
hint.setAttribute('id', hintId);
|
|
70
|
+
hint.classList.add('hint__container');
|
|
71
|
+
getParentNode().append(hint);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var getHintContainer = function getHintContainer() {
|
|
75
|
+
return document.getElementById(hintId);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
var getHintMarkUp = function getHintMarkUp() {
|
|
79
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
80
|
+
"data-testid": 'test-hint-text',
|
|
81
|
+
className: (0, _classnames.default)('hint__text', "hint__text_".concat(side))
|
|
82
|
+
}, hint);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
var setHintContainerStyles = function setHintContainerStyles() {
|
|
86
|
+
var _sw$getBoundingClient;
|
|
87
|
+
|
|
88
|
+
var hc = getHintContainer();
|
|
89
|
+
if (!hc || !isOpen) return false;
|
|
90
|
+
|
|
91
|
+
var _hintRef$current$getB = hintRef === null || hintRef === void 0 ? void 0 : hintRef.current.getBoundingClientRect(),
|
|
92
|
+
width = _hintRef$current$getB.width,
|
|
93
|
+
height = _hintRef$current$getB.height,
|
|
94
|
+
left = _hintRef$current$getB.left,
|
|
95
|
+
top = _hintRef$current$getB.top,
|
|
96
|
+
bottom = _hintRef$current$getB.bottom;
|
|
97
|
+
|
|
98
|
+
var sw = hc.getElementsByClassName('hint__text')[0];
|
|
99
|
+
var swHeight = sw === null || sw === void 0 ? void 0 : (_sw$getBoundingClient = sw.getBoundingClientRect()) === null || _sw$getBoundingClient === void 0 ? void 0 : _sw$getBoundingClient.height;
|
|
100
|
+
hc.style.width = isOpen ? width === null || width === void 0 ? void 0 : width.toString().concat('px') : 0;
|
|
101
|
+
hc.style.left = isOpen ? left === null || left === void 0 ? void 0 : left.toString().concat('px') : 0;
|
|
102
|
+
hc.style.top = isOpen ? top === null || top === void 0 ? void 0 : top.toString().concat('px') : 0;
|
|
103
|
+
hc.style.maxHeight = isOpen ? swHeight === null || swHeight === void 0 ? void 0 : swHeight.toString().concat('px') : 0;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
var renderHintContainer = function renderHintContainer() {
|
|
107
|
+
var hc = getHintContainer();
|
|
108
|
+
if (!hc) return null;
|
|
109
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)(getHintMarkUp(), hc);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
(0, _react.useEffect)(initHintContainer, []);
|
|
113
|
+
(0, _react.useEffect)(function () {
|
|
114
|
+
setHintContainerStyles();
|
|
115
|
+
}, [isOpen]);
|
|
51
116
|
(0, _react.useEffect)(function () {
|
|
52
117
|
document.addEventListener('click', handleClickOutside, true);
|
|
53
118
|
return function () {
|
|
@@ -106,10 +171,7 @@ var Hint = function Hint(_ref) {
|
|
|
106
171
|
className: (0, _classnames.default)('hint__label', {
|
|
107
172
|
'color--primary': isOpen
|
|
108
173
|
})
|
|
109
|
-
}, label[0].toUpperCase() + label.slice(1))), isOpen &&
|
|
110
|
-
"data-testid": 'test-hint-text',
|
|
111
|
-
className: (0, _classnames.default)('hint__text', "hint__text_".concat(side))
|
|
112
|
-
}, hint));
|
|
174
|
+
}, label[0].toUpperCase() + label.slice(1))), isOpen && renderHintContainer());
|
|
113
175
|
};
|
|
114
176
|
|
|
115
177
|
var _default = Hint;
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
display: inline-block;
|
|
4
4
|
font-size: 0;
|
|
5
5
|
|
|
6
|
+
&__container {
|
|
7
|
+
display: block;
|
|
8
|
+
position: fixed;
|
|
9
|
+
z-index: 99999;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
&__button {
|
|
7
14
|
display: flex;
|
|
8
15
|
cursor: pointer;
|
|
@@ -68,8 +75,8 @@
|
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
&_left {
|
|
71
|
-
top: -
|
|
72
|
-
right:
|
|
78
|
+
top: -4px;
|
|
79
|
+
right: 28px;
|
|
73
80
|
&:before {
|
|
74
81
|
top: 8px;
|
|
75
82
|
right: -4.25px;
|
|
@@ -77,7 +84,7 @@
|
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
&_top {
|
|
80
|
-
bottom:
|
|
87
|
+
bottom: 8px;
|
|
81
88
|
left: -4px;
|
|
82
89
|
&:before {
|
|
83
90
|
left: 8px;
|
|
@@ -255,6 +255,14 @@ var AbortableFetch = /*#__PURE__*/function () {
|
|
|
255
255
|
mergeProps = itemObj.mergeProps,
|
|
256
256
|
isNoPathPrefix = itemObj.isNoPathPrefix,
|
|
257
257
|
isSkipEveryPromiseCallback = itemObj.isSkipEveryPromiseCallback;
|
|
258
|
+
var safelyMergeProps = mergeProps instanceof Object && !Array.isArray(mergeProps) ? mergeProps : {};
|
|
259
|
+
|
|
260
|
+
var getMergeProps = function getMergeProps(key) {
|
|
261
|
+
var _safelyMergeProps$all;
|
|
262
|
+
|
|
263
|
+
return (_safelyMergeProps$all = safelyMergeProps.all) !== null && _safelyMergeProps$all !== void 0 ? _safelyMergeProps$all : safelyMergeProps[key];
|
|
264
|
+
};
|
|
265
|
+
|
|
258
266
|
if (!path || typeof path !== 'string') return ac;
|
|
259
267
|
|
|
260
268
|
var _ref3 = options || {},
|
|
@@ -272,30 +280,35 @@ var AbortableFetch = /*#__PURE__*/function () {
|
|
|
272
280
|
|
|
273
281
|
return [].concat((0, _toConsumableArray2.default)(ac), [_objectSpread({
|
|
274
282
|
path: path,
|
|
275
|
-
pathPrefix:
|
|
283
|
+
pathPrefix: getMergeProps('pathPrefix') === 'onlyLocal' || isNoPathPrefix ? '' : (0, _classPrivateFieldGet2.default)(_this2, _pathPrefix) || '',
|
|
276
284
|
method: function () {
|
|
277
|
-
if (
|
|
278
|
-
return
|
|
285
|
+
if (getMergeProps('method') === 'onlyLocal') return method || 'GET';
|
|
286
|
+
return getMergeProps('method') === 'onlyGlobal' ? (0, _classPrivateFieldGet2.default)(_this2, _method) || 'GET' : method || (0, _classPrivateFieldGet2.default)(_this2, _method) || 'GET';
|
|
279
287
|
}(),
|
|
280
288
|
queryParameters: function () {
|
|
281
|
-
|
|
282
|
-
|
|
289
|
+
var _getMergeProps, _getMergeProps2;
|
|
290
|
+
|
|
291
|
+
if (((_getMergeProps = getMergeProps('queryParameters')) !== null && _getMergeProps !== void 0 ? _getMergeProps : getMergeProps('query')) === 'onlyLocal') {
|
|
292
|
+
return _this2.getQueryString(_this2.getQueryArray(queryParameters));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return ((_getMergeProps2 = getMergeProps('queryParameters')) !== null && _getMergeProps2 !== void 0 ? _getMergeProps2 : getMergeProps('query')) === 'onlyGlobal' ? _this2.getQueryString(_this2.getQueryArray((0, _classPrivateFieldGet2.default)(_this2, _queryParameters))) : _this2.getQueryString([].concat((0, _toConsumableArray2.default)(_this2.getQueryArray((0, _classPrivateFieldGet2.default)(_this2, _queryParameters))), (0, _toConsumableArray2.default)(_this2.getQueryArray(queryParameters))));
|
|
283
296
|
}(),
|
|
284
297
|
headers: function () {
|
|
285
|
-
if (
|
|
286
|
-
return
|
|
298
|
+
if (getMergeProps('headers') === 'onlyLocal') return _this2.getHeadersObj(headers || {});
|
|
299
|
+
return getMergeProps('headers') === 'onlyGlobal' ? _this2.getHeadersObj(_objectSpread({}, (0, _classPrivateFieldGet2.default)(_this2, _headers) || {})) : _this2.getHeadersObj(_objectSpread(_objectSpread({}, (0, _classPrivateFieldGet2.default)(_this2, _headers) || {}), headers || {}));
|
|
287
300
|
}(),
|
|
288
301
|
body: function () {
|
|
289
|
-
if (
|
|
290
|
-
if (
|
|
302
|
+
if (getMergeProps('body') === 'onlyLocal') return body || null;
|
|
303
|
+
if (getMergeProps('body') === 'onlyGlobal') return (0, _classPrivateFieldGet2.default)(_this2, _body) || null;
|
|
291
304
|
|
|
292
305
|
if (body && (0, _classPrivateFieldGet2.default)(_this2, _body) && (0, _typeof2.default)(body) === (0, _typeof2.default)((0, _classPrivateFieldGet2.default)(_this2, _body)) && (0, _typeof2.default)(body) === 'object') {
|
|
293
306
|
return Array.isArray(body) ? [].concat((0, _toConsumableArray2.default)((0, _classPrivateFieldGet2.default)(_this2, _body)), (0, _toConsumableArray2.default)(body)) : _objectSpread(_objectSpread({}, (0, _classPrivateFieldGet2.default)(_this2, _body)), body);
|
|
294
307
|
} else return body || (0, _classPrivateFieldGet2.default)(_this2, _body) || null;
|
|
295
308
|
}(),
|
|
296
309
|
options: function () {
|
|
297
|
-
if (
|
|
298
|
-
return
|
|
310
|
+
if (getMergeProps('options') === 'onlyLocal') return _objectSpread({}, optionsRest || {});
|
|
311
|
+
return getMergeProps('options') === 'onlyGlobal' ? _objectSpread({}, (0, _classPrivateFieldGet2.default)(_this2, _options) || {}) : _objectSpread(_objectSpread({}, (0, _classPrivateFieldGet2.default)(_this2, _options) || {}), optionsRest || {});
|
|
299
312
|
}(),
|
|
300
313
|
callback: callback,
|
|
301
314
|
isSkipEveryPromiseCallback: isSkipEveryPromiseCallback
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intelicoreact",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.70",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
14
|
-
"build": "
|
|
14
|
+
"build": "babel src --out-dir dist --copy-files --no-copy-ignored",
|
|
15
15
|
"release": "babel src --out-dir dist --copy-files --no-copy-ignored && npm publish && node ../../IntelicoKitVersioningBot/main.js"
|
|
16
16
|
},
|
|
17
17
|
"author": "Andrey Isakov",
|