intelicoreact 1.0.72 → 1.0.74

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.
@@ -79,18 +79,23 @@ var Dropdown = function Dropdown(_ref) {
79
79
  searchValue = _useState4[0],
80
80
  setSearchValue = _useState4[1];
81
81
 
82
+ var _useState5 = (0, _react.useState)(false),
83
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
84
+ isSearching = _useState6[0],
85
+ setIsSearching = _useState6[1];
86
+
82
87
  var dropdownRef = (0, _react.useRef)(null);
83
88
  var dropdownListRef = (0, _react.useRef)(null);
84
89
 
85
- var _useState5 = (0, _react.useState)(null),
86
- _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
87
- initListHeight = _useState6[0],
88
- setInitListHeight = _useState6[1];
89
-
90
- var _useState7 = (0, _react.useState)(false),
90
+ var _useState7 = (0, _react.useState)(null),
91
91
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
92
- isFocusedByClick = _useState8[0],
93
- setIsFocusedByClick = _useState8[1];
92
+ initListHeight = _useState8[0],
93
+ setInitListHeight = _useState8[1];
94
+
95
+ var _useState9 = (0, _react.useState)(false),
96
+ _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
97
+ isFocusedByClick = _useState10[0],
98
+ setIsFocusedByClick = _useState10[1];
94
99
 
95
100
  if (!options) return null;
96
101
 
@@ -177,7 +182,6 @@ var Dropdown = function Dropdown(_ref) {
177
182
 
178
183
  if (!((_getListContainer = getListContainer()) !== null && _getListContainer !== void 0 && _getListContainer.contains(event.target))) {
179
184
  setIsOpen(false);
180
- setSearchValue('');
181
185
  }
182
186
  };
183
187
 
@@ -190,6 +194,10 @@ var Dropdown = function Dropdown(_ref) {
190
194
  var hightlightedText = function hightlightedText(text, postfix) {
191
195
  var _text;
192
196
 
197
+ var prepare = function prepare(text) {
198
+ return text === null || text === void 0 ? void 0 : text.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
199
+ };
200
+
193
201
  text = text.replace(/["&<>]/g, function (a) {
194
202
  return {
195
203
  '"': '&quot;',
@@ -198,7 +206,7 @@ var Dropdown = function Dropdown(_ref) {
198
206
  '>': '&gt;'
199
207
  }[a];
200
208
  });
201
- var main = searchValue ? (_text = text) === null || _text === void 0 ? void 0 : _text.replace(new RegExp(searchValue, 'i'), function (match) {
209
+ var main = searchValue ? (_text = text) === null || _text === void 0 ? void 0 : _text.replace(new RegExp(prepare(searchValue), 'i'), function (match) {
202
210
  return "<span class=\"bg--yellow\">".concat(match, "</span>");
203
211
  }) : text;
204
212
  var postfixPart = postfix ? "<span class=\"dropdown__list-item-postfix\">".concat(postfix, "</span>") : '';
@@ -363,7 +371,7 @@ var Dropdown = function Dropdown(_ref) {
363
371
  }, [getListContainer]);
364
372
  (0, _react.useEffect)(function () {
365
373
  setListContainerStyles();
366
- }, [isOpen]);
374
+ }, [isOpen, searchValue]);
367
375
  (0, _react.useEffect)(function () {
368
376
  if (!value) setSearchValue(null);
369
377
  document.addEventListener('click', handleClickOutside, true);
@@ -419,13 +427,19 @@ var Dropdown = function Dropdown(_ref) {
419
427
  }
420
428
  }, isSearchable ? /*#__PURE__*/_react.default.createElement("input", {
421
429
  className: "".concat(RC, "__input"),
422
- value: searchValue || selectedLabel || '',
430
+ value: isSearching ? searchValue !== null && searchValue !== void 0 ? searchValue : '' : selectedLabel || '',
423
431
  onChange: function onChange(e) {
424
432
  onSearchHandler(e.target.value);
425
433
  },
426
434
  placeholder: placeholder,
427
435
  onFocus: function onFocus(e) {
428
- e.target.select(); // setIsOpen(true);
436
+ setSearchValue(selectedLabel);
437
+ setIsSearching(true);
438
+ e.target.select();
439
+ },
440
+ onBlur: function onBlur() {
441
+ setSearchValue(null);
442
+ setIsSearching(false);
429
443
  },
430
444
  onClick: function onClick() {
431
445
  return setIsOpen(!isOpen);
@@ -7,6 +7,8 @@ var _typeof3 = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
+ exports.transformUTCTimeToLocal = transformUTCTimeToLocal;
11
+ exports.transformUTCHoursToLocal = transformUTCHoursToLocal;
10
12
  exports.downloadEmulation = downloadEmulation;
11
13
  exports.compareAlphabetical = exports.setCarretToEnd = exports.compare = exports.downloadFile = exports.checkedRef = exports.capitalized = exports.firstLetterCapital = exports.changeMeta = exports.addBitDepthPoints = exports.throttle = exports.debounce = exports.getColorById = exports.getStyles = exports.logout = exports.omitKeys = exports.clone = exports.useOutsideToggle = exports.handleObjectChange = void 0;
12
14
 
@@ -78,12 +80,46 @@ var clone = function clone(obj) {
78
80
  }
79
81
 
80
82
  return data;
81
- }; //принимает обьект и массив ключей обьекта
82
- //возвращает обьект с теми полями, которых нет в массиве ключей
83
+ }; //TimeUtils
83
84
 
84
85
 
85
86
  exports.clone = clone;
86
87
 
88
+ function transformUTCTimeToLocal(date) {
89
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'YYYY-MM-DD HH:mm:ss';
90
+ if (!date) return;
91
+ var utcDate = moment.utc(date).toDate();
92
+ return moment(utcDate, format).local().format(format);
93
+ }
94
+
95
+ function transformUTCHoursToLocal(time) {
96
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'HH:mm:ss';
97
+ if (!time) return;
98
+ var splitedTime = time.split(':');
99
+ var offset = moment().utcOffset();
100
+ var HH = +splitedTime[0];
101
+ var mm = +splitedTime[1];
102
+ var ss = splitedTime[2];
103
+ mm = mm + offset;
104
+
105
+ while (mm > 59) {
106
+ mm -= 60;
107
+ HH += 1;
108
+ }
109
+
110
+ if (HH > 23) HH -= 24;
111
+
112
+ while (mm < 0) {
113
+ mm += 60;
114
+ HH -= 1;
115
+ }
116
+
117
+ if (HH < 0) HH += 24;
118
+ return "".concat(HH, ":").concat(mm, ":").concat(ss);
119
+ } //принимает обьект и массив ключей обьекта
120
+ //возвращает обьект с теми полями, которых нет в массиве ключей
121
+
122
+
87
123
  var omitKeys = function omitKeys() {
88
124
  var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
89
125
  var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -311,17 +347,38 @@ var setCarretToEnd = function setCarretToEnd(input) {
311
347
  input.value = tmp;
312
348
  }, 10);
313
349
  };
350
+ /**
351
+ * "Sort an array of objects by a given key, alphabetically."
352
+ *
353
+ * The function takes three parameters:
354
+ *
355
+ * - `a`: The first item to compare.
356
+ * - `b`: The second item to compare.
357
+ * - `key`: The key to compare by
358
+ * @param a - The first item to compare
359
+ * @param b - The second item to compare
360
+ * @param [key=label] - The key to sort by.
361
+ * @returns A function that takes in 3 parameters, a, b, and key.
362
+ */
363
+
314
364
 
315
365
  exports.setCarretToEnd = setCarretToEnd;
316
366
 
317
367
  var compareAlphabetical = function compareAlphabetical(a, b) {
368
+ var _item, _item2;
369
+
318
370
  var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'label';
371
+ var item1 = a === null || a === void 0 ? void 0 : a[key];
372
+ var item2 = b === null || b === void 0 ? void 0 : b[key];
373
+ if (typeof item1 !== "string" || typeof item2 !== "string") return 0;
374
+ item1 = (_item = item1) === null || _item === void 0 ? void 0 : _item.toLowerCase();
375
+ item2 = (_item2 = item2) === null || _item2 === void 0 ? void 0 : _item2.toLowerCase();
319
376
 
320
- if ((a === null || a === void 0 ? void 0 : a[key]) < (b === null || b === void 0 ? void 0 : b[key])) {
377
+ if (item1 < item2) {
321
378
  return -1;
322
379
  }
323
380
 
324
- if ((a === null || a === void 0 ? void 0 : a[key]) > (b === null || b === void 0 ? void 0 : b[key])) {
381
+ if (item1 > item2) {
325
382
  return 1;
326
383
  }
327
384
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "1.0.72",
3
+ "version": "1.0.74",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [