intelicoreact 1.0.30 → 1.0.32

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,18 +1,21 @@
1
1
  .inputColor {
2
2
  position: relative;
3
+
3
4
  &__color-block {
4
5
  position: absolute;
5
- left: 5px;
6
+ z-index: 1;
6
7
  top: 50%;
7
- transform: translateY(-50%);
8
+ left: 5px;
9
+
8
10
  min-width: 16px;
9
11
  max-width: 16px;
10
12
  min-height: 16px;
11
13
  max-height: 16px;
12
- z-index: 1;
14
+
15
+ transform: translateY(-50%);
13
16
  }
17
+
14
18
  .input {
15
19
  padding-left: 25px;
16
20
  }
17
-
18
21
  }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.default = void 0;
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
+
16
+ var _react = _interopRequireWildcard(require("react"));
17
+
18
+ var _classnames = _interopRequireDefault(require("classnames"));
19
+
20
+ var _reactFeather = require("react-feather");
21
+
22
+ var _Input = _interopRequireDefault(require("../Input/Input"));
23
+
24
+ var _fieldValueFormatters = require("../../../Functions/fieldValueFormatters");
25
+
26
+ require("./InputLink.scss");
27
+
28
+ var _excluded = ["icon", "value", "withHttpsPrefix", "onRedirect", "testId", "onChange", "withDelete"];
29
+
30
+ 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); }
31
+
32
+ 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; }
33
+
34
+ var InputColor = function InputColor(_ref) {
35
+ var icon = _ref.icon,
36
+ value = _ref.value,
37
+ _ref$withHttpsPrefix = _ref.withHttpsPrefix,
38
+ withHttpsPrefix = _ref$withHttpsPrefix === void 0 ? {
39
+ isTurnOn: false,
40
+ isSecure: false,
41
+ isBorderErrorWithEmptyHost: false
42
+ } : _ref$withHttpsPrefix,
43
+ onRedirect = _ref.onRedirect,
44
+ _ref$testId = _ref.testId,
45
+ testId = _ref$testId === void 0 ? 'input' : _ref$testId,
46
+ onChange = _ref.onChange,
47
+ withDelete = _ref.withDelete,
48
+ args = (0, _objectWithoutProperties2.default)(_ref, _excluded);
49
+
50
+ var _ref2 = withHttpsPrefix || {},
51
+ isSecure = _ref2.isSecure,
52
+ isPrefix = _ref2.isTurnOn;
53
+
54
+ var inputRef = (0, _react.useRef)(null);
55
+ var handle = {
56
+ redirect: function redirect() {
57
+ var _ref3 = withHttpsPrefix || {},
58
+ isBorderErrorWithEmptyHost = _ref3.isBorderErrorWithEmptyHost,
59
+ isSecure = _ref3.isSecure,
60
+ isPrefix = _ref3.isTurnOn;
61
+
62
+ if (isPrefix && isBorderErrorWithEmptyHost) {
63
+ if (isSecure && (value === null || value === void 0 ? void 0 : value.length) <= 8 || !isSecure && (value === null || value === void 0 ? void 0 : value.length) <= 7) {
64
+ return null;
65
+ }
66
+ }
67
+
68
+ window.open("http".concat(isSecure ? 's' : '', "://").concat(value.replace(/https?:\/\/?/g, '')), '_blank');
69
+ onRedirect === null || onRedirect === void 0 ? void 0 : onRedirect();
70
+ },
71
+ change: function change(e) {
72
+ var _inputRef$current;
73
+
74
+ var inputValue = e !== null && e !== void 0 && e.target ? (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(e.target.value) : (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(e);
75
+ var cursorPosition = (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.selectionStart;
76
+
77
+ if (isSecure && cursorPosition <= 8 || !isSecure && cursorPosition <= 7) {
78
+ cursorPosition++;
79
+ }
80
+
81
+ setTimeout(function () {
82
+ var _inputRef$current2;
83
+
84
+ (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.setSelectionRange(cursorPosition, cursorPosition);
85
+ }, 0);
86
+ if (isPrefix) inputValue = (0, _fieldValueFormatters.formatToReplaceAllWhiteSpace)(inputValue.replace(/https?:\/\/?/g, ''));
87
+ onChange === null || onChange === void 0 ? void 0 : onChange(inputValue.toString());
88
+ }
89
+ };
90
+ return /*#__PURE__*/_react.default.createElement("div", {
91
+ className: (0, _classnames.default)('inputLink', {
92
+ 'inputLink--withDelete': withDelete && value && value.length > 0
93
+ })
94
+ }, isPrefix && /*#__PURE__*/_react.default.createElement("div", {
95
+ className: (0, _classnames.default)('inputColor__prefix')
96
+ }, isSecure ? 'https://' : 'http://'), /*#__PURE__*/_react.default.createElement(_Input.default, (0, _extends2.default)({}, args, {
97
+ withDelete: withDelete,
98
+ value: value,
99
+ onChange: handle.change,
100
+ testId: "inputLink--key-".concat(testId),
101
+ type: "text",
102
+ autoComplete: "url",
103
+ ref: inputRef,
104
+ className: (0, _classnames.default)({
105
+ 'prefix-gutter--secured': isPrefix && isSecure,
106
+ 'prefix-gutter--no-secured': isPrefix && !isSecure
107
+ })
108
+ })), /*#__PURE__*/_react.default.createElement("div", {
109
+ onClick: function onClick() {
110
+ return handle.redirect();
111
+ },
112
+ className: (0, _classnames.default)('inputLink__icon pointer')
113
+ }, value && (icon || /*#__PURE__*/_react.default.createElement(_reactFeather.ExternalLink, null))));
114
+ };
115
+
116
+ var _default = InputColor;
117
+ exports.default = _default;
@@ -0,0 +1,58 @@
1
+ .inputLink {
2
+ position: relative;
3
+
4
+ &__icon {
5
+ position: absolute;
6
+ z-index: 1;
7
+ top: 50%;
8
+ right: 5px;
9
+
10
+ width: fit-content;
11
+ height: fit-content;
12
+
13
+ transform: translateY(-50%);
14
+
15
+ svg {
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+
20
+ min-width: 16px;
21
+ max-width: 16px;
22
+ min-height: 16px;
23
+ max-height: 16px;
24
+
25
+ stroke: #6B81DD;
26
+ }
27
+ }
28
+
29
+ .input {
30
+ padding-right: 25px;
31
+ }
32
+
33
+ .input__close {
34
+ right: 20px;
35
+ }
36
+
37
+ .prefix-gutter--secured {
38
+ padding-left: 52px;
39
+ }
40
+
41
+ .prefix-gutter--no-secured {
42
+ padding-left: 45px;
43
+ }
44
+ }
45
+
46
+ .inputColor__prefix {
47
+ position: absolute;
48
+ z-index: 1;
49
+ top: 50%;
50
+ left: 11px;
51
+
52
+ cursor: default;
53
+ transform: translateY(-50%);
54
+ pointer-events: none;
55
+
56
+ font-size: 13px;
57
+ font-weight: 400;
58
+ }
@@ -133,7 +133,8 @@ var NumericInput = function NumericInput(_ref) {
133
133
  change: function change(e) {
134
134
  var inputValue = e.target ? (0, _fieldValueFormatters.filterNumeric)(e.target.value, {
135
135
  type: 'int'
136
- }) : e; // ToDo - не совсем понятно что проверяется, т.к. при нажатии инкремента/декримента все равно в change приходит число, а не эвент
136
+ }) : e; // ToDo - не совсем понятно что проверяется, т.к. при нажатии инкремента/декримента
137
+ //ToDo все равно в change приходит число, а не эвент
137
138
  // ToDo - боюсь сломать, временно оставляю, выпилить через какое-то время
138
139
  // if (inputValue && (decRef.current?.contains?.(e.target) || incRef.current?.contains?.(e.target))) {
139
140
  // if (symbolsLimit) inputValue = inputValue.toString().substring(0, +symbolsLimit);
@@ -215,13 +215,13 @@ var TagsDropdown = function TagsDropdown(_ref) {
215
215
  };
216
216
 
217
217
  var setListContainerStyles = function setListContainerStyles() {
218
- var _getComputedStyle$mar, _getComputedStyle, _getComputedStyle$mar2, _getComputedStyle$max, _getComputedStyle2, _getComputedStyle2$ma, _sw$getBoundingClient, _dl$getBoundingClient;
218
+ var _dropdownRef$current$, _dropdownRef$current, _getComputedStyle$mar, _getComputedStyle, _getComputedStyle$mar2, _getComputedStyle$max, _getComputedStyle2, _getComputedStyle2$ma, _dl$getBoundingClient, _sw$getBoundingClient;
219
219
 
220
220
  var lc = getListContainer();
221
221
  if (!lc || !isOpen) return false;
222
222
  var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
223
223
 
224
- var _ref6 = (dropdownRef === null || dropdownRef === void 0 ? void 0 : dropdownRef.current.getBoundingClientRect()) || {},
224
+ var _ref6 = (_dropdownRef$current$ = dropdownRef === null || dropdownRef === void 0 ? void 0 : (_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.getBoundingClientRect()) !== null && _dropdownRef$current$ !== void 0 ? _dropdownRef$current$ : {},
225
225
  width = _ref6.width,
226
226
  height = _ref6.height,
227
227
  left = _ref6.left,
@@ -232,15 +232,19 @@ var TagsDropdown = function TagsDropdown(_ref) {
232
232
  var margin = parseInt((_getComputedStyle$mar = (_getComputedStyle = getComputedStyle(sw)) === null || _getComputedStyle === void 0 ? void 0 : (_getComputedStyle$mar2 = _getComputedStyle.marginTop) === null || _getComputedStyle$mar2 === void 0 ? void 0 : _getComputedStyle$mar2.replace('px', '')) !== null && _getComputedStyle$mar !== void 0 ? _getComputedStyle$mar : 0);
233
233
  var maxHeight = initListHeight !== null && initListHeight !== void 0 ? initListHeight : parseInt((_getComputedStyle$max = (_getComputedStyle2 = getComputedStyle(dl)) === null || _getComputedStyle2 === void 0 ? void 0 : (_getComputedStyle2$ma = _getComputedStyle2.maxHeight) === null || _getComputedStyle2$ma === void 0 ? void 0 : _getComputedStyle2$ma.replace('px', '')) !== null && _getComputedStyle$max !== void 0 ? _getComputedStyle$max : 0);
234
234
  if (initListHeight === null) setInitListHeight(maxHeight);
235
- var delta = ((_sw$getBoundingClient = sw.getBoundingClientRect()) === null || _sw$getBoundingClient === void 0 ? void 0 : _sw$getBoundingClient.height) - ((_dl$getBoundingClient = dl.getBoundingClientRect()) === null || _dl$getBoundingClient === void 0 ? void 0 : _dl$getBoundingClient.height);
236
235
  var toTop = top - margin;
237
236
  var toBottom = windowHeight - top - height - margin * 2;
238
- var swHeight = toTop >= maxHeight || toBottom >= maxHeight ? maxHeight - 3 * margin : toTop > toBottom ? toTop - 3 * margin : toBottom - 4 * margin;
237
+ var dlHeight = dl === null || dl === void 0 ? void 0 : (_dl$getBoundingClient = dl.getBoundingClientRect()) === null || _dl$getBoundingClient === void 0 ? void 0 : _dl$getBoundingClient.height;
238
+ var swHeight = sw === null || sw === void 0 ? void 0 : (_sw$getBoundingClient = sw.getBoundingClientRect()) === null || _sw$getBoundingClient === void 0 ? void 0 : _sw$getBoundingClient.height;
239
+ var controlsHeight = swHeight - dlHeight;
240
+ if (swHeight > maxHeight) swHeight = maxHeight - 2 * margin;
241
+ var maxSwHeight = toTop - margin >= maxHeight || toBottom - margin >= maxHeight ? maxHeight - 3 * margin : toTop > toBottom ? toTop - 3 * margin : toBottom - 4 * margin;
239
242
  var listPos = toTop < toBottom || toBottom >= swHeight ? 'bottom' : 'top';
243
+ if (swHeight > (listPos === 'top' ? toTop : toBottom)) swHeight = (listPos === 'top' ? toTop : toBottom) - 3 * margin;
240
244
  lc.style.minWidth = "".concat(width, "px");
241
245
  lc.style.left = "".concat(left, "px");
242
- lc.style.top = "".concat(listPos === 'bottom' ? top + height : top - swHeight - 3 * margin, "px");
243
- dl.style.maxHeight = "".concat(swHeight - delta, "px");
246
+ lc.style.top = "".concat(listPos === 'bottom' ? top + height : top - swHeight - 2 * margin, "px");
247
+ dl.style.maxHeight = "".concat(maxSwHeight - controlsHeight, "px");
244
248
  };
245
249
 
246
250
  var renderListContainer = function renderListContainer() {
@@ -282,10 +286,6 @@ var TagsDropdown = function TagsDropdown(_ref) {
282
286
  }, footerContent) : null);
283
287
  };
284
288
 
285
- (0, _react.useEffect)(function () {
286
- initListContainer();
287
- }, []);
288
-
289
289
  var closeList = function closeList(e) {
290
290
  var _inputRef$current;
291
291
 
@@ -293,6 +293,9 @@ var TagsDropdown = function TagsDropdown(_ref) {
293
293
  inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.blur();
294
294
  };
295
295
 
296
+ (0, _react.useLayoutEffect)(function () {
297
+ initListContainer();
298
+ }, []);
296
299
  (0, _react.useLayoutEffect)(function () {
297
300
  window.addEventListener('resize', setListContainerStyles);
298
301
  window.addEventListener('mousewheel', closeList);
@@ -303,7 +306,7 @@ var TagsDropdown = function TagsDropdown(_ref) {
303
306
  window.removeEventListener('mouseup', handleClickOutside);
304
307
  };
305
308
  }, [getListContainer]);
306
- (0, _react.useEffect)(function () {
309
+ (0, _react.useLayoutEffect)(function () {
307
310
  setListContainerStyles();
308
311
  }, [isOpen, chosenOptions]);
309
312
  (0, _react.useEffect)(function () {
@@ -26,6 +26,8 @@
26
26
  }
27
27
 
28
28
  .lds-ring.lds-ring_little {
29
+ top: calc(50% - 15px);
30
+
29
31
  width: 30px;
30
32
  height: 30px;
31
33
  }
@@ -48,10 +50,11 @@
48
50
  }
49
51
 
50
52
  .lds-ring_little div {
51
- top: -10px;
53
+ top: -15%;
54
+ left: -15%;
52
55
 
53
- width: 30px !important;
54
- height: 30px !important;
56
+ width: 100% !important;
57
+ height: 100% !important;
55
58
 
56
59
  border: 4px solid #000 !important;
57
60
  border-color: #000 transparent transparent !important;
@@ -45,6 +45,10 @@ var AdvancedTags = function AdvancedTags(_ref) {
45
45
  var onShowMoreClick = function onShowMoreClick() {
46
46
  setShowedItems(showMore ? items : [items[0], items[1]]);
47
47
  setShowMore(!showMore);
48
+ return function () {
49
+ setShowedItems([items[0], items[1]]);
50
+ setShowMore(true);
51
+ };
48
52
  };
49
53
 
50
54
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -18,7 +18,8 @@ var _Button = _interopRequireDefault(require("../Button/Button"));
18
18
  require("./ButtonsBar.scss");
19
19
 
20
20
  var ButtonsBar = function ButtonsBar(_ref) {
21
- var rejectBtnLabel = _ref.rejectBtnLabel,
21
+ var className = _ref.className,
22
+ rejectBtnLabel = _ref.rejectBtnLabel,
22
23
  rejectBtnIcon = _ref.rejectBtnIcon,
23
24
  rejectBtnVariant = _ref.rejectBtnVariant,
24
25
  rejectBtnClass = _ref.rejectBtnClass,
@@ -36,7 +37,7 @@ var ButtonsBar = function ButtonsBar(_ref) {
36
37
  _ref$testIdSecondBtn = _ref.testIdSecondBtn,
37
38
  testIdSecondBtn = _ref$testIdSecondBtn === void 0 ? 'test-btn-bar-second' : _ref$testIdSecondBtn;
38
39
  return /*#__PURE__*/_react.default.createElement("div", {
39
- className: "button-bar"
40
+ className: (0, _classnames.default)('button-bar', className)
40
41
  }, rejectLink ? /*#__PURE__*/_react.default.createElement(_reactRouterDom.Link, {
41
42
  className: "text-decoration-none",
42
43
  to: rejectLink
@@ -3,10 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.formatToReplaceAllWhiteSpace = formatToReplaceAllWhiteSpace;
6
7
  exports.filterNumeric = exports.filterFloat = exports.formatToHex = exports.formatToLimitLength = exports.formatNumberValueToMask = exports.formatToCutOffDotAtTheEnd = exports.formatToOnlyASCIICodeText = exports.formatToLetters = exports.formatToPriceWithUSD = exports.formatToTwoDigitAfterDot = exports.formatToDollarSign = exports.formatToAddBitDepthPoints = exports.formatToRemoveComa = exports.formatOnlyNumbers = exports.intlNumbersFormatter = exports.getSafelyValue = void 0;
7
8
 
8
- // The first word "format" in the function name means a logic in which the function transforms the incoming value in any case.
9
- // The first word "filter" in the function name means a logic in which the function works as a changer for sequential input
9
+ // The first word "format" in the function name means a
10
+ //logic in which the function transforms the incoming value in any case.
11
+ // The first word "filter" in the function name means a
12
+ // logic in which the function works as a changer for sequential input
13
+
14
+ /**
15
+ * If the value is not undefined or null, return the value's toString() method, otherwise return an
16
+ * empty string.
17
+ */
10
18
  var getSafelyValue = function getSafelyValue(value) {
11
19
  var _value$toString;
12
20
 
@@ -81,8 +89,8 @@ var intlNumbersFormatter = function intlNumbersFormatter(inputValue) {
81
89
  //валюта
82
90
  currencyDisplay: currencyDisplay,
83
91
  //валюта в виде символа
84
- minimumFractionDigits: isRenderAlways ? quantity : 0,
85
92
  //минимально не надо отображать центы, если их нет, иначе всегда будет .00
93
+ minimumFractionDigits: isRenderAlways ? quantity : 0,
86
94
  maximumFractionDigits: quantity //максимально отображать 2 цифры после запятой, если центы всё же есть
87
95
 
88
96
  };
@@ -214,19 +222,39 @@ var formatToLimitLength = function formatToLimitLength(inputValue, limit) {
214
222
  var value = getSafelyValue(inputValue);
215
223
  return limit && typeof limit === 'number' && !Number.isNaN(limit) && (value === null || value === void 0 ? void 0 : value.length) > limit ? value.substr(0, limit) : value;
216
224
  };
225
+ /**
226
+ * It takes a string and returns a hexadecimal string
227
+ * @param inputValue - The value to be formatted.
228
+ * @param withSharp - boolean - if true, the returned value will have a sharp (#) at the beginning.
229
+ * @returns A function that takes two arguments, inputValue and withSharp.
230
+ */
231
+
217
232
 
218
233
  exports.formatToLimitLength = formatToLimitLength;
219
234
 
220
- var formatToHex = function formatToHex(inputValue) {
235
+ var formatToHex = function formatToHex(_ref2) {
236
+ var inputValue = _ref2.inputValue,
237
+ withSharp = _ref2.withSharp;
221
238
  var value = getSafelyValue(inputValue);
222
- return "#".concat(value.toString().replace(/[^a-f0-9]/gi, ''));
223
- }; // *** filter ***
239
+ return "".concat(withSharp ? '#' : '').concat(value.toString().replace(/[^a-f0-9]/gi, ''));
240
+ };
241
+ /**
242
+ * It takes a string and returns a string with all white space removed
243
+ * @param str - The string to be formatted.
244
+ * @returns A string with all white space removed.
245
+ */
224
246
 
225
247
 
226
248
  exports.formatToHex = formatToHex;
227
249
 
250
+ function formatToReplaceAllWhiteSpace(str) {
251
+ var value = getSafelyValue(str);
252
+ return value.replace(/\s+/g, '');
253
+ } // *** filter ***
254
+
255
+
228
256
  var filterFloat = function filterFloat(inputValue) {
229
- var _ref2;
257
+ var _ref3;
230
258
 
231
259
  var decimalPlaces = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
232
260
  var value = getSafelyValue(inputValue);
@@ -236,7 +264,7 @@ var filterFloat = function filterFloat(inputValue) {
236
264
  };
237
265
 
238
266
  if (value.length === 1 && (value[0] === '.' || value[0] === ',')) return '0.';
239
- var output = (_ref2 = '' + value) === null || _ref2 === void 0 ? void 0 : _ref2.replace(/,/g, '.');
267
+ var output = (_ref3 = '' + value) === null || _ref3 === void 0 ? void 0 : _ref3.replace(/,/g, '.');
240
268
  if (value.length > 1 && value[0] === '0' && value[1] !== '.' && value[0] !== ',') output = value.slice(1);
241
269
  var previousValue = '' + output.slice(0, -1);
242
270
  var lastSym = '' + output.slice(-1);
@@ -247,10 +275,10 @@ var filterFloat = function filterFloat(inputValue) {
247
275
  exports.filterFloat = filterFloat;
248
276
 
249
277
  var filterNumeric = function filterNumeric(value, settings) {
250
- var _ref3 = settings || {},
251
- _ref3$type = _ref3.type,
252
- type = _ref3$type === void 0 ? 'float' : _ref3$type,
253
- decimalPlaces = _ref3.decimalPlaces;
278
+ var _ref4 = settings || {},
279
+ _ref4$type = _ref4.type,
280
+ type = _ref4$type === void 0 ? 'float' : _ref4$type,
281
+ decimalPlaces = _ref4.decimalPlaces;
254
282
 
255
283
  var executor = type === 'float' ? filterFloat : formatOnlyNumbers;
256
284
  return executor(getSafelyValue(value), decimalPlaces);
@@ -10,7 +10,8 @@ exports.addRangeDefault = void 0;
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
 
12
12
  // Взято из https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Math/round
13
- // При импорте любой ф-и из этого файла отработает самовызывающаяся ф-я и расширит объект Math 3-мя ф-ми: round10, floor10, ceil10
13
+ // При импорте любой ф-и из этого файла отработает самовызывающаяся ф-я и расширит
14
+ // объект Math 3-мя ф-ми: round10, floor10, ceil10
14
15
  (function () {
15
16
  /**
16
17
  * Корректировка округления десятичных дробей.
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.default = exports.useInputHighlightError = void 0;
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _react = _interopRequireWildcard(require("react"));
15
+
16
+ var _index = require("../Constants/index.constants");
17
+
18
+ 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); }
19
+
20
+ 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; }
21
+
22
+ var useInputHighlightError = function useInputHighlightError(_ref) {
23
+ var value = _ref.value,
24
+ blinkTime = _ref.blinkTime,
25
+ isUseErrorsBlink = _ref.isUseErrorsBlink;
26
+ var DEFAULT_BLINK_TIME = 100;
27
+
28
+ var _useState = (0, _react.useState)(false),
29
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
30
+ isToHighlightError = _useState2[0],
31
+ setIsToHighlightError = _useState2[1];
32
+
33
+ var _useState3 = (0, _react.useState)(false),
34
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
35
+ isAttemptToChange = _useState4[0],
36
+ setIsAttemptToChange = _useState4[1];
37
+
38
+ var _useState5 = (0, _react.useState)(value),
39
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
40
+ prevValue = _useState6[0],
41
+ setPreviousValue = _useState6[1];
42
+
43
+ function hasHighlightError(e) {
44
+ var changedValue = "".concat(value !== null && value !== void 0 ? value : '');
45
+ var previousValue = "".concat(prevValue !== null && prevValue !== void 0 ? prevValue : '');
46
+ var short = previousValue.length <= changedValue.length ? previousValue : changedValue;
47
+ var long = previousValue.length > changedValue.length ? previousValue : changedValue;
48
+ var infoAboutDifferencesSameness = short.split('').reduce(function (acc, symbol, idx) {
49
+ if (acc.countOn && symbol === long[idx]) acc.same.push(symbol);else {
50
+ acc.countOn = false;
51
+ acc.differences.push([idx, symbol]);
52
+ }
53
+ return acc;
54
+ }, {
55
+ same: [],
56
+ countOn: true,
57
+ differences: []
58
+ });
59
+ var samePart = infoAboutDifferencesSameness.same.join('');
60
+ var differencesLength = infoAboutDifferencesSameness.differences.length;
61
+ var currentSet = changedValue === null || changedValue === void 0 ? void 0 : changedValue.replace(samePart, '');
62
+ if (!_index.KEYBOARD_SERVICE_KEYS.includes(e.key) && changedValue === previousValue) setIsAttemptToChange(!(!differencesLength && e.key === currentSet));
63
+ }
64
+
65
+ (0, _react.useEffect)(function () {
66
+ if (isUseErrorsBlink && isAttemptToChange) {
67
+ setIsAttemptToChange(null);
68
+ setIsToHighlightError(true);
69
+ setTimeout(function () {
70
+ setIsToHighlightError(false);
71
+ }, blinkTime || DEFAULT_BLINK_TIME);
72
+ }
73
+ }, [isAttemptToChange]);
74
+ return {
75
+ isToHighlightError: isToHighlightError,
76
+ setPreviousValue: setPreviousValue,
77
+ setIsToHighlightError: setIsToHighlightError,
78
+ hasHighlightError: hasHighlightError
79
+ };
80
+ };
81
+
82
+ exports.useInputHighlightError = useInputHighlightError;
83
+ var _default = useInputHighlightError;
84
+ exports.default = _default;
@@ -135,7 +135,7 @@ function usePasswordChecker() {
135
135
  })
136
136
  }, /*#__PURE__*/_react.default.createElement("div", {
137
137
  className: "password-checker__body-item__icon"
138
- }, " ", icon, " "), " ", /*#__PURE__*/_react.default.createElement("div", {
138
+ }, " ", icon, " "), ' ', /*#__PURE__*/_react.default.createElement("div", {
139
139
  className: "password-checker__body-item__text"
140
140
  }, " ", text, " "), ' ');
141
141
  }), ' '), ' ');
@@ -7,7 +7,12 @@ var _typeof3 = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.checkedRef = 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;
10
+ exports.downloadEmulation = downloadEmulation;
11
+ exports.downloadFile = exports.checkedRef = 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
+
13
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
14
+
15
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
16
 
12
17
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
18
 
@@ -205,4 +210,83 @@ var checkedRef = function checkedRef(ref) {
205
210
  } : ref : null;
206
211
  };
207
212
 
208
- exports.checkedRef = checkedRef;
213
+ exports.checkedRef = checkedRef;
214
+
215
+ function downloadEmulation(data, filename) {
216
+ var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'image/*';
217
+ var file = new Blob([data], {
218
+ type: type
219
+ });
220
+ if (window.navigator.msSaveOrOpenBlob) // IE10+
221
+ window.navigator.msSaveOrOpenBlob(file, filename);else {
222
+ // Others
223
+ var a = document.createElement('a'),
224
+ url = URL.createObjectURL(file);
225
+ a.href = url;
226
+ a.download = filename;
227
+ document.body.appendChild(a);
228
+ a.click();
229
+ setTimeout(function () {
230
+ document.body.removeChild(a);
231
+ window.URL.revokeObjectURL(url);
232
+ }, 0);
233
+ }
234
+ }
235
+
236
+ var downloadFile = /*#__PURE__*/function () {
237
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref) {
238
+ var url, name, type, response;
239
+ return _regenerator.default.wrap(function _callee2$(_context2) {
240
+ while (1) {
241
+ switch (_context2.prev = _context2.next) {
242
+ case 0:
243
+ url = _ref.url, name = _ref.name, type = _ref.type;
244
+ _context2.next = 3;
245
+ return fetch(url).then( /*#__PURE__*/function () {
246
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(res) {
247
+ return _regenerator.default.wrap(function _callee$(_context) {
248
+ while (1) {
249
+ switch (_context.prev = _context.next) {
250
+ case 0:
251
+ _context.next = 2;
252
+ return res.blob();
253
+
254
+ case 2:
255
+ _context.t0 = _context.sent;
256
+ _context.t1 = type !== null && type !== void 0 ? type : res.headers.get('content-type');
257
+ return _context.abrupt("return", {
258
+ data: _context.t0,
259
+ type: _context.t1
260
+ });
261
+
262
+ case 5:
263
+ case "end":
264
+ return _context.stop();
265
+ }
266
+ }
267
+ }, _callee);
268
+ }));
269
+
270
+ return function (_x2) {
271
+ return _ref3.apply(this, arguments);
272
+ };
273
+ }());
274
+
275
+ case 3:
276
+ response = _context2.sent;
277
+ downloadEmulation(response.data, name, response.type);
278
+
279
+ case 5:
280
+ case "end":
281
+ return _context2.stop();
282
+ }
283
+ }
284
+ }, _callee2);
285
+ }));
286
+
287
+ return function downloadFile(_x) {
288
+ return _ref2.apply(this, arguments);
289
+ };
290
+ }();
291
+
292
+ exports.downloadFile = downloadFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [