intelicoreact 0.3.42 → 0.3.44
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.
|
@@ -214,7 +214,7 @@ var Input = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
216
|
(0, _react.useLayoutEffect)(function () {
|
|
217
|
-
if (isUseBitDepthPoints) setFormatedValue((0, _fieldValueFormatters.formatToAddBitDepthPoints)(value === undefined || value === null ? '' : value));
|
|
217
|
+
if (isUseBitDepthPoints) setFormatedValue((0, _fieldValueFormatters.formatToAddBitDepthPoints)(value === undefined || value === null ? '' : value, onlyNumbers));
|
|
218
218
|
}, [value]);
|
|
219
219
|
(0, _react.useEffect)(function () {
|
|
220
220
|
var _inputRef$current, _inputRef$current$foc;
|
|
@@ -134,16 +134,13 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
134
134
|
var inputValue = e.target ? (0, _fieldValueFormatters.filterNumeric)(e.target.value, {
|
|
135
135
|
type: 'int'
|
|
136
136
|
}) : e;
|
|
137
|
-
if (inputValue
|
|
137
|
+
if (Number.isNaN(+inputValue) || +inputValue < 0) inputValue = min || '0'; // ToDo - не совсем понятно что проверяется, т.к. при нажатии инкремента/декримента все равно в change приходит число, а не эвент
|
|
138
138
|
// ToDo - боюсь сломать, временно оставляю, выпилить через какое-то время
|
|
139
139
|
// if (inputValue && (decRef.current?.contains?.(e.target) || incRef.current?.contains?.(e.target))) {
|
|
140
140
|
|
|
141
141
|
if (inputValue) {
|
|
142
142
|
inputValue = parseFloat(inputValue);
|
|
143
|
-
|
|
144
|
-
if (min && +min > inputValue) {
|
|
145
|
-
inputValue = min;
|
|
146
|
-
} else if (max && +max < inputValue) inputValue = max;
|
|
143
|
+
if (max && +max < inputValue) inputValue = max;
|
|
147
144
|
}
|
|
148
145
|
|
|
149
146
|
if (symbolsLimit) inputValue = inputValue.toString().substring(0, +symbolsLimit);
|
|
@@ -154,14 +151,14 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
154
151
|
handle.change(min || '');
|
|
155
152
|
},
|
|
156
153
|
focus: function focus(e) {
|
|
157
|
-
if (isFocused) return;
|
|
158
154
|
setIsFocused(true);
|
|
155
|
+
setEditing(true);
|
|
159
156
|
if (onFocus) onFocus(e);
|
|
160
157
|
},
|
|
161
158
|
blur: function blur(e) {
|
|
162
|
-
if (!isFocused) return;
|
|
163
159
|
setIsFocused(false);
|
|
164
160
|
setEditing(false);
|
|
161
|
+
if (inputValue < +min) setInputValue(min);
|
|
165
162
|
if (onBlur) onBlur(e);
|
|
166
163
|
},
|
|
167
164
|
keyDown: function keyDown(e) {
|
|
@@ -270,13 +267,8 @@ var NumericInput = function NumericInput(_ref) {
|
|
|
270
267
|
value: inputValueFormated,
|
|
271
268
|
disabled: disabled,
|
|
272
269
|
onChange: handle.change,
|
|
273
|
-
onFocus:
|
|
274
|
-
|
|
275
|
-
setEditing(true);
|
|
276
|
-
},
|
|
277
|
-
onBlur: function onBlur() {
|
|
278
|
-
return setEditing(false);
|
|
279
|
-
},
|
|
270
|
+
onFocus: handle.focus,
|
|
271
|
+
onBlur: handle.blur,
|
|
280
272
|
onKeyDown: handle.keyDown,
|
|
281
273
|
onKeyUp: handle.keyUp,
|
|
282
274
|
min: min,
|
|
@@ -52,7 +52,7 @@ var SwitcherRadio = function SwitcherRadio(_ref) {
|
|
|
52
52
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
53
53
|
className: (0, _classnames.default)("".concat(RC, "__wrap"), (0, _defineProperty2.default)({}, "switcher-radio_".concat(direction), direction), {
|
|
54
54
|
disabled: disabled
|
|
55
|
-
})
|
|
55
|
+
}, className)
|
|
56
56
|
}, options === null || options === void 0 ? void 0 : options.map(function (option, index) {
|
|
57
57
|
return /*#__PURE__*/_react.default.createElement(_RadioInput.default, (0, _extends2.default)({}, option, {
|
|
58
58
|
key: option.id || option.value || index,
|
|
@@ -16,8 +16,11 @@ var getSafelyValue = function getSafelyValue(value) {
|
|
|
16
16
|
}; // базовая реализация
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var intlNumbersFormatter = function intlNumbersFormatter(
|
|
19
|
+
var intlNumbersFormatter = function intlNumbersFormatter(inputValue) {
|
|
20
20
|
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21
|
+
var previousValue = '' + inputValue.slice(0, -1);
|
|
22
|
+
var lastSym = '' + inputValue.slice(-1);
|
|
23
|
+
var value = lastSym === '.' ? previousValue : inputValue;
|
|
21
24
|
if (Number.isNaN(+value)) return '';
|
|
22
25
|
var _settings$locale = settings.locale,
|
|
23
26
|
locale = _settings$locale === void 0 ? "en-US" : _settings$locale,
|
|
@@ -83,7 +86,8 @@ var intlNumbersFormatter = function intlNumbersFormatter(value) {
|
|
|
83
86
|
maximumFractionDigits: quantity //максимально отображать 2 цифры после запятой, если центы всё же есть
|
|
84
87
|
|
|
85
88
|
};
|
|
86
|
-
|
|
89
|
+
var output = new Intl.NumberFormat(locale, priceSettings).format(value);
|
|
90
|
+
return lastSym === '.' ? output + lastSym : output;
|
|
87
91
|
}; // *** format ***
|
|
88
92
|
|
|
89
93
|
|
|
@@ -101,8 +105,12 @@ var formatToRemoveComa = function formatToRemoveComa(value) {
|
|
|
101
105
|
|
|
102
106
|
exports.formatToRemoveComa = formatToRemoveComa;
|
|
103
107
|
|
|
104
|
-
var formatToAddBitDepthPoints = function formatToAddBitDepthPoints(value) {
|
|
105
|
-
return intlNumbersFormatter(getSafelyValue(value)
|
|
108
|
+
var formatToAddBitDepthPoints = function formatToAddBitDepthPoints(value, settings) {
|
|
109
|
+
return intlNumbersFormatter(getSafelyValue(value), {
|
|
110
|
+
fractionDigits: {
|
|
111
|
+
quantity: (settings === null || settings === void 0 ? void 0 : settings.type) === 'int' ? 0 : settings === null || settings === void 0 ? void 0 : settings.decimalPlaces
|
|
112
|
+
}
|
|
113
|
+
});
|
|
106
114
|
};
|
|
107
115
|
|
|
108
116
|
exports.formatToAddBitDepthPoints = formatToAddBitDepthPoints;
|
|
@@ -131,7 +139,7 @@ var formatToTwoDigitAfterDot = function formatToTwoDigitAfterDot(value) {
|
|
|
131
139
|
exports.formatToTwoDigitAfterDot = formatToTwoDigitAfterDot;
|
|
132
140
|
|
|
133
141
|
var formatToPriceWithUSD = function formatToPriceWithUSD(value) {
|
|
134
|
-
return intlNumbersFormatter(getSafelyValue(value)
|
|
142
|
+
return intlNumbersFormatter(getSafelyValue(value), {
|
|
135
143
|
withSymbol: 'currency',
|
|
136
144
|
currency: {
|
|
137
145
|
currencyType: 'USD'
|
|
@@ -226,7 +234,6 @@ var filterFloat = function filterFloat(inputValue) {
|
|
|
226
234
|
var previousValue = '' + output.slice(0, -1);
|
|
227
235
|
var lastSym = '' + output.slice(-1);
|
|
228
236
|
if (decimalPlaces && typeof decimalPlaces === 'number' && previousValue.includes('.') && previousValue.indexOf('.') + 1 + decimalPlaces === previousValue.length) return replaser(previousValue);
|
|
229
|
-
console.log(lastSym === '.' && previousValue.includes('.'), 'replacer');
|
|
230
237
|
return replaser(lastSym === '.' && previousValue.includes('.') ? previousValue : output);
|
|
231
238
|
};
|
|
232
239
|
|