intelicoreact 1.5.22 → 1.5.24
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/DropdownLiveSearch/DropdownLiveSearch.js +1 -1
- package/dist/Atomic/FormElements/RangeInputs/RangeInputs.js +8 -3
- package/dist/Classes/RESTAPI/partials/ApiRequestCreators.js +19 -15
- package/dist/Functions/fieldValueFormatters.js +15 -3
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +1 -0
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ const DropdownLiveSearch = _ref => {
|
|
|
53
53
|
const labelByValue = (0, _react.useMemo)(() => {
|
|
54
54
|
var _options$find$label, _options$find;
|
|
55
55
|
return (_options$find$label = options === null || options === void 0 || (_options$find = options.find(item => item.value === value)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : "";
|
|
56
|
-
}, [value]);
|
|
56
|
+
}, [value, options]);
|
|
57
57
|
const [searchValue, setSV] = (0, _react.useState)("");
|
|
58
58
|
const [isSearchValueChangedAfterOpen, setIsSearchValueChangedAfterOpen] = (0, _react.useState)(false);
|
|
59
59
|
const dropdownLiveSearchRef = (0, _react.useRef)(null);
|
|
@@ -33,7 +33,9 @@ const RangeInputs = _ref => {
|
|
|
33
33
|
testId,
|
|
34
34
|
withZero = false,
|
|
35
35
|
fromPlaceholder = "",
|
|
36
|
-
toPlaceholder = ""
|
|
36
|
+
toPlaceholder = "",
|
|
37
|
+
disabled,
|
|
38
|
+
isDisabled
|
|
37
39
|
} = _ref;
|
|
38
40
|
const [error, setError] = (0, _react.useState)({
|
|
39
41
|
from: "",
|
|
@@ -41,6 +43,7 @@ const RangeInputs = _ref => {
|
|
|
41
43
|
});
|
|
42
44
|
const inputFromRef = (0, _react.useRef)(null);
|
|
43
45
|
const inputToRef = (0, _react.useRef)(null);
|
|
46
|
+
const isFieldDisabled = disabled || isDisabled;
|
|
44
47
|
const isValidRange = (from, to) => {
|
|
45
48
|
var _from$toString, _to$toString;
|
|
46
49
|
const correctFrom = parseFloat(from === null || from === void 0 || (_from$toString = from.toString()) === null || _from$toString === void 0 ? void 0 : _from$toString.replace(/[^\d]/g, ""));
|
|
@@ -129,7 +132,8 @@ const RangeInputs = _ref => {
|
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
},
|
|
132
|
-
placeholder: fromPlaceholder
|
|
135
|
+
placeholder: fromPlaceholder,
|
|
136
|
+
disabled: isFieldDisabled
|
|
133
137
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
134
138
|
className: "".concat(RC, "__input-to")
|
|
135
139
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
@@ -144,7 +148,8 @@ const RangeInputs = _ref => {
|
|
|
144
148
|
onKeyUp: (code, e) => {
|
|
145
149
|
if (code === 13) inputToRef.current.blur();
|
|
146
150
|
},
|
|
147
|
-
placeholder: toPlaceholder
|
|
151
|
+
placeholder: toPlaceholder,
|
|
152
|
+
disabled: isFieldDisabled
|
|
148
153
|
}))));
|
|
149
154
|
};
|
|
150
155
|
var _default = exports.default = RangeInputs;
|
|
@@ -5,8 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _utils = require("lib/dist/Functions/utils");
|
|
8
9
|
var _ApiUtils = _interopRequireDefault(require("./ApiUtils"));
|
|
9
|
-
var
|
|
10
|
+
var _utils2 = require("./_utils");
|
|
10
11
|
//? Префикс createRequest_ добавляется к крейтерам с целью разгрузить пространство имен
|
|
11
12
|
const PREFIX_OF_CLASS_UTILS = "createRequest_";
|
|
12
13
|
class ApiRequestCreators extends _ApiUtils.default {
|
|
@@ -15,19 +16,20 @@ class ApiRequestCreators extends _ApiUtils.default {
|
|
|
15
16
|
const {
|
|
16
17
|
requestsCreators
|
|
17
18
|
} = settings || {};
|
|
18
|
-
if ((0,
|
|
19
|
+
if ((0, _utils2.getIsOnlyAnObject)(requestsCreators)) _utils2.addCustomMethods.call(this, requestsCreators, PREFIX_OF_CLASS_UTILS);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
//? При типе toJson пользовательский callback на вход получит тело ответа реализованное методом Response.json()
|
|
22
23
|
//? независимо от насторойки isGetBody
|
|
23
24
|
async createRequest_toJson(props, variant) {
|
|
25
|
+
const safelyProps = (0, _utils.omitKeys)(props, ['getBodyAs']);
|
|
24
26
|
return this.splitProperties({
|
|
25
|
-
...
|
|
27
|
+
...safelyProps,
|
|
26
28
|
isGetBody: false,
|
|
27
29
|
callback: async res => {
|
|
28
|
-
var
|
|
30
|
+
var _safelyProps$callback, _safelyProps$callback2;
|
|
29
31
|
const output = await this.getResponseBody(res, 'json');
|
|
30
|
-
return await ((
|
|
32
|
+
return await ((_safelyProps$callback = (_safelyProps$callback2 = safelyProps.callback) === null || _safelyProps$callback2 === void 0 ? void 0 : _safelyProps$callback2.call(safelyProps, output)) !== null && _safelyProps$callback !== void 0 ? _safelyProps$callback : output);
|
|
31
33
|
}
|
|
32
34
|
}, variant);
|
|
33
35
|
}
|
|
@@ -36,16 +38,17 @@ class ApiRequestCreators extends _ApiUtils.default {
|
|
|
36
38
|
//? где response - объект Response, result - тело ответа реализованное методом Response.json()
|
|
37
39
|
//? независимо от насторойки isGetBody
|
|
38
40
|
async createRequest_toJsonAdvanced(props, variant) {
|
|
41
|
+
const safelyProps = (0, _utils.omitKeys)(props, ['getBodyAs']);
|
|
39
42
|
return this.splitProperties({
|
|
40
|
-
...
|
|
43
|
+
...safelyProps,
|
|
41
44
|
isGetBody: false,
|
|
42
45
|
callback: async res => {
|
|
43
|
-
var
|
|
46
|
+
var _safelyProps$callback3, _safelyProps$callback4;
|
|
44
47
|
const output = {
|
|
45
48
|
response: res,
|
|
46
|
-
result: await this.getResponseBody(await (0,
|
|
49
|
+
result: await this.getResponseBody(await (0, _utils2.getResponseClone)(res), 'json')
|
|
47
50
|
};
|
|
48
|
-
return await ((
|
|
51
|
+
return await ((_safelyProps$callback3 = (_safelyProps$callback4 = safelyProps.callback) === null || _safelyProps$callback4 === void 0 ? void 0 : _safelyProps$callback4.call(safelyProps, output)) !== null && _safelyProps$callback3 !== void 0 ? _safelyProps$callback3 : output);
|
|
49
52
|
}
|
|
50
53
|
}, variant);
|
|
51
54
|
}
|
|
@@ -53,13 +56,14 @@ class ApiRequestCreators extends _ApiUtils.default {
|
|
|
53
56
|
//? При типе blob пользовательский callback на вход получит тело ответа реализованное методом Response.blob(),
|
|
54
57
|
//? независимо от насторойки isGetBody
|
|
55
58
|
async createRequest_blob(props, variant) {
|
|
59
|
+
const safelyProps = (0, _utils.omitKeys)(props, ['getBodyAs']);
|
|
56
60
|
return this.splitProperties({
|
|
57
|
-
...
|
|
61
|
+
...safelyProps,
|
|
58
62
|
isGetBody: false,
|
|
59
63
|
callback: async res => {
|
|
60
|
-
var
|
|
61
|
-
const output = await this.getResponseBody(await (0,
|
|
62
|
-
return await ((
|
|
64
|
+
var _safelyProps$callback5, _safelyProps$callback6;
|
|
65
|
+
const output = await this.getResponseBody(await (0, _utils2.getResponseClone)(res), 'blob');
|
|
66
|
+
return await ((_safelyProps$callback5 = (_safelyProps$callback6 = safelyProps.callback) === null || _safelyProps$callback6 === void 0 ? void 0 : _safelyProps$callback6.call(safelyProps, output)) !== null && _safelyProps$callback5 !== void 0 ? _safelyProps$callback5 : output);
|
|
63
67
|
}
|
|
64
68
|
}, variant);
|
|
65
69
|
}
|
|
@@ -82,8 +86,8 @@ class ApiRequestCreators extends _ApiUtils.default {
|
|
|
82
86
|
return headers;
|
|
83
87
|
})()
|
|
84
88
|
})).then(res => {
|
|
85
|
-
var _props$
|
|
86
|
-
return (_props$
|
|
89
|
+
var _props$callback, _props$callback2;
|
|
90
|
+
return (_props$callback = (_props$callback2 = props.callback) === null || _props$callback2 === void 0 ? void 0 : _props$callback2.call(props, res)) !== null && _props$callback !== void 0 ? _props$callback : res;
|
|
87
91
|
})
|
|
88
92
|
}, variant);
|
|
89
93
|
}
|
|
@@ -199,7 +199,13 @@ const formatAsPercentage = (value, settings) => {
|
|
|
199
199
|
isCommonPercentageSymbol = true,
|
|
200
200
|
decimalPlaces = 2,
|
|
201
201
|
beforeValueSymbol = "",
|
|
202
|
-
afterValueSymbol = ""
|
|
202
|
+
afterValueSymbol = "",
|
|
203
|
+
isGlueSameRangesTogether = false,
|
|
204
|
+
// ? Тут удобный ф-л, поэтому иной раз удобно обработать обычный диапазан (НЕ проценты).
|
|
205
|
+
// ? Добавил возможность выпиливать значек процентов.
|
|
206
|
+
// todo(VL) - вообще правильно заренеймить (formatAsDiapason), а добавление процентов сделать как опцию,
|
|
207
|
+
// todo(VL) - но как обычно нет времени, нужно будет перечекать по всем проектам где тянется со старым неймингом
|
|
208
|
+
isUseAsSimpleDiapason = false
|
|
203
209
|
} = (0, _utils.getIsOnlyAnObject)(settings) ? settings : {};
|
|
204
210
|
let safelyInputValue;
|
|
205
211
|
const checkValue = value => getSafelyValue(value) || "0";
|
|
@@ -227,10 +233,16 @@ const formatAsPercentage = (value, settings) => {
|
|
|
227
233
|
to: checkValue(valuesArr[1])
|
|
228
234
|
};
|
|
229
235
|
} else {
|
|
230
|
-
|
|
236
|
+
// Вариант когда велью передано строкой (НЕ объектом) и оно не содержит сепаратора " - "
|
|
237
|
+
// - одиночные велью
|
|
238
|
+
// - некорректный диапазон
|
|
239
|
+
return "".concat(beforeValueSymbol).concat(transform(safelyInputValue)).concat(afterValueSymbol).concat(isUseAsSimpleDiapason ? '' : '%');
|
|
231
240
|
}
|
|
232
241
|
}
|
|
233
|
-
if (
|
|
242
|
+
if (safelyInputValue.from === safelyInputValue.to && !!isGlueSameRangesTogether) {
|
|
243
|
+
return "".concat(beforeValueSymbol).concat(transform(safelyInputValue.from)).concat(afterValueSymbol).concat(isUseAsSimpleDiapason ? '' : '%');
|
|
244
|
+
}
|
|
245
|
+
if (isCommonPercentageSymbol) return "".concat(beforeValueSymbol).concat(transform(safelyInputValue.from), " - ").concat(transform(safelyInputValue.to)).concat(afterValueSymbol).concat(isUseAsSimpleDiapason ? '' : '%');else return "".concat(beforeValueSymbol).concat(transform(safelyInputValue.from)).concat(isUseAsSimpleDiapason ? '' : '%', " - ").concat(transform(safelyInputValue.to)).concat(isUseAsSimpleDiapason ? '' : '%').concat(afterValueSymbol);
|
|
234
246
|
};
|
|
235
247
|
|
|
236
248
|
// eslint-disable-next-line no-control-regex
|
|
@@ -56,6 +56,7 @@ const FormWithDependOn = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
56
56
|
getActualForm
|
|
57
57
|
}) : {};
|
|
58
58
|
const getMainOfAdditional = (onChange, additionalOfOnChange) => ({
|
|
59
|
+
formId,
|
|
59
60
|
actions: anotherActions,
|
|
60
61
|
isInit: true,
|
|
61
62
|
...((0, _utils.getIsOnlyAnObject)(additionalOfOnChange) ? additionalOfOnChange : {}),
|