intelicoreact 1.4.84 → 1.4.86

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.
@@ -68,6 +68,7 @@ const FileLoaderDescription = _ref => {
68
68
  accordionListContent = [],
69
69
  maxFilesCount = 10,
70
70
  isWithoutAccordion,
71
+ error: outerError,
71
72
  ...props
72
73
  } = _ref;
73
74
  const uniqueFileLoaderDescriptionId = "".concat(id || testId || fieldKey || "component-".concat(_utils.uuid === null || _utils.uuid === void 0 ? void 0 : (0, _utils.uuid)()));
@@ -85,9 +86,11 @@ const FileLoaderDescription = _ref => {
85
86
  const handle = {
86
87
  checkOverflow: function (fields) {
87
88
  let error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
89
+ let outerError = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
88
90
  return fields.length < maxFilesCount ? [...fields, {
89
91
  ...(0, _utils.clone)(uploadTriggerStucture),
90
- error
92
+ error,
93
+ outerError
91
94
  }] : fields;
92
95
  },
93
96
  applyFields: newFields => {
@@ -136,6 +139,9 @@ const FileLoaderDescription = _ref => {
136
139
  }
137
140
  }
138
141
  };
142
+ (0, _react.useEffect)(() => {
143
+ setFields(handle.checkOverflow(fields.filter(item => item.id !== UPLOAD_TRIGGER_KEY), null, outerError));
144
+ }, [outerError]);
139
145
  return /*#__PURE__*/_react.default.createElement("div", {
140
146
  id: uniqueFileLoaderDescriptionId,
141
147
  testId: uniqueFileLoaderDescriptionId,
@@ -156,12 +162,9 @@ const FileLoaderDescription = _ref => {
156
162
  return /*#__PURE__*/_react.default.createElement(_FileLoaderLocal.default, {
157
163
  className: "".concat(RC, "__list-item"),
158
164
  key: field.id,
159
- id: "loader-".concat(uniqueFileLoaderDescriptionId, "-field-").concat(field.id)
160
- // key={`${fieldKey ?? Date.now()}/${field.id}`}
161
- // fieldKey={`${fieldKey ?? Date.now()}/${field.id}`}
162
- // id={field.id}
163
- ,
165
+ id: "loader-".concat(uniqueFileLoaderDescriptionId, "-field-").concat(field.id),
164
166
  error: field.error,
167
+ outerError: field.outerError,
165
168
  label: "Upload document",
166
169
  accept: field.accept,
167
170
  value: field.value,
@@ -19,6 +19,7 @@ const FileLoaderLocal = _ref => {
19
19
  fieldKey,
20
20
  label,
21
21
  error,
22
+ outerError,
22
23
  isRequired,
23
24
  accept,
24
25
  onChange,
@@ -90,7 +91,9 @@ const FileLoaderLocal = _ref => {
90
91
  };
91
92
  return /*#__PURE__*/_react.default.createElement("div", {
92
93
  "data-testid": "input--file-loader-local--key-".concat(testId),
93
- className: (0, _classnames.default)("file-loader-local", className)
94
+ className: (0, _classnames.default)("file-loader-local", className, {
95
+ ['file-loader-local_outer-error']: !!outerError
96
+ })
94
97
  }, /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({
95
98
  onChange: handle.change,
96
99
  className: "file-loader-local__file-input",
@@ -117,7 +120,9 @@ const FileLoaderLocal = _ref => {
117
120
  className: "file-loader-local__label-text"
118
121
  }, value || label), error && /*#__PURE__*/_react.default.createElement("span", {
119
122
  className: "file-loader-local__error"
120
- }, error))), value && !isNoTrashIcon && /*#__PURE__*/_react.default.createElement(_reactFeather.Trash2, {
123
+ }, error), typeof outerError === 'string' && /*#__PURE__*/_react.default.createElement("span", {
124
+ className: "file-loader-local__error"
125
+ }, outerError))), value && !isNoTrashIcon && /*#__PURE__*/_react.default.createElement(_reactFeather.Trash2, {
121
126
  className: "file-loader-local__trash-icon",
122
127
  onClick: () => onChange({
123
128
  id,
@@ -11,6 +11,10 @@
11
11
  background-color: #ffffff;
12
12
  box-shadow: 0px 2px 8px rgb(39 73 113 / 15%);
13
13
 
14
+ &_outer-error {
15
+ border: 1px solid #fa564c;
16
+ }
17
+
14
18
  &__top-label {
15
19
  margin-bottom: 16px;
16
20
 
@@ -292,48 +292,47 @@ function formatToReplaceAllWhiteSpace(str) {
292
292
  // ****************************
293
293
  // filter
294
294
  // ****************************
295
+ //? Намерянно выпилил определение дефолтного значение на уровне параметров, чтобы сделать null рабочим значением
296
+ //? decimalPlaces === null теперь точно определяет режим ввода БЕЗ ограничей десятичных знаков
297
+ const filterFloat = (inputValue, decimalPlaces) => {
298
+ var _ref2;
299
+ const replaser = input => ('' + input).replace(/[^\.\d]/g, '');
300
+ const value = getSafelyValue(inputValue);
295
301
 
296
- // export const filterFloat = (inputValue, decimalPlaces = null) => {
297
- // const value = getSafelyValue(inputValue);
298
- // const replaser = input => ('' + input).replace(/[^\.\d]/g, '');
299
- //
300
- // if (value.length === 1 && (value[0] === '.' || value[0] === ',')) return '0.';
301
- // let output = ('' + value)?.replace(/,/g, '.');
302
- // if (value.length > 1 && value[0] === '0' && value[1] !== '.' && value[0] !== ',') output = value.slice(1);
303
- //
304
- // const previousValue = '' + output.slice(0, -1);
305
- // const lastSym = '' + output.slice(-1);
306
- //
307
- // if (
308
- // decimalPlaces &&
309
- // typeof decimalPlaces === 'number' &&
310
- // previousValue.includes('.') &&
311
- // previousValue.indexOf('.') + 1 + decimalPlaces === previousValue.length
312
- // )
313
- // return replaser(previousValue);
314
- // return replaser(lastSym === '.' && previousValue.includes('.') ? previousValue : output);
315
- // };
302
+ //? safelyDecimalPlaces ТОЧНО либо null, либо целое число
303
+ const safelyDecimalPlaces = (() => {
304
+ if (decimalPlaces === null) return decimalPlaces;
305
+ const DEFAULT_VALUE = 2;
306
+ const isNumber = typeof decimalPlaces === 'number' || typeof decimalPlaces === 'string' && !Number.isNaN(+decimalPlaces);
316
307
 
317
- const filterFloat = function (inputValue) {
318
- var _output, _output2, _output3, _output4;
319
- let decimalPlaces = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
320
- const value = getSafelyValue(inputValue);
321
- const replacer = input => {
322
- var _String;
323
- return (_String = String(input)) === null || _String === void 0 ? void 0 : _String.replace(/[^\.\d,]/g, "");
324
- };
325
- if (value.length === 1 && (value[0] === "." || value[0] === ",")) return "0.";
326
- let output = value;
327
- const previousValue = String((_output = output) === null || _output === void 0 ? void 0 : _output.slice(0, -1));
328
- const lastSym = String((_output2 = output) === null || _output2 === void 0 ? void 0 : _output2.slice(-1));
329
- if (decimalPlaces && typeof decimalPlaces === "number" && previousValue !== null && previousValue !== void 0 && previousValue.includes(".") && (previousValue === null || previousValue === void 0 ? void 0 : previousValue.indexOf(".")) + 1 + decimalPlaces === (previousValue === null || previousValue === void 0 ? void 0 : previousValue.length)) {
330
- return replacer(previousValue);
331
- }
332
- if ((_output3 = output) !== null && _output3 !== void 0 && _output3.includes(".") && output[((_output4 = output) === null || _output4 === void 0 ? void 0 : _output4.indexOf(".")) + 3] !== undefined && Number(output)) {
333
- var _Number;
334
- output = (_Number = Number(output)) === null || _Number === void 0 ? void 0 : _Number.toFixed(decimalPlaces);
308
+ //? защита от дробного значения decimalPlaces
309
+ return isNumber ? Number((+decimalPlaces).toFixed()) : DEFAULT_VALUE;
310
+ })();
311
+
312
+ // Обработка кейса если первым символом нажата точка
313
+ if (value.length === 1 && (value[0] === '.' || value[0] === ',')) return '0.';
314
+
315
+ // Приводим запятые к корректному разделителю, но не выпиливаем
316
+ let output = (_ref2 = '' + value) === null || _ref2 === void 0 ? void 0 : _ref2.replace(/,/g, '.');
317
+
318
+ // Выпилить первый ноль, если это не дробь
319
+ if (value.length > 1 && value[0] === '0' && value[1] !== '.' && value[0] !== ',') output = value.slice(1);
320
+ const previousValue = '' + output.slice(0, -1);
321
+ const lastSym = '' + output.slice(-1);
322
+
323
+ // Обработка кейса второй точки в дроби
324
+ if (lastSym === '.' && previousValue.includes('.')) output = previousValue;
325
+
326
+ // if (localStorage.getItem('useDeb')) debugger;
327
+
328
+ // Логика ограничения по decimalPlaces
329
+ if (typeof safelyDecimalPlaces === 'number') {
330
+ if (!safelyDecimalPlaces && lastSym === '.') return replaser(previousValue);
331
+ if (previousValue.includes('.') && previousValue.indexOf('.') + 1 + safelyDecimalPlaces === (previousValue === null || previousValue === void 0 ? void 0 : previousValue.length)) {
332
+ return replaser(previousValue);
333
+ }
335
334
  }
336
- return replacer(lastSym === "." && previousValue !== null && previousValue !== void 0 && previousValue.includes(".") ? previousValue : output);
335
+ return replaser(output);
337
336
  };
338
337
  exports.filterFloat = filterFloat;
339
338
  const filterNumeric = (value, settings) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "1.4.84",
3
+ "version": "1.4.86",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [