sapo-components-ui-rn 1.0.65 → 1.0.67
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/index.esm.js +20 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/NumberKeyboard/index.tsx +21 -3
package/dist/index.esm.js
CHANGED
|
@@ -7319,15 +7319,32 @@ var NumberKeyboard = function (_a) {
|
|
|
7319
7319
|
}, [inputValue, maxValue, type, formatDecimal]);
|
|
7320
7320
|
var handleClear = useCallback(function () {
|
|
7321
7321
|
setInputValue("");
|
|
7322
|
-
|
|
7322
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("0");
|
|
7323
|
+
}, [onChangeText]);
|
|
7323
7324
|
var handleSave = useCallback(function () {
|
|
7324
7325
|
var finalValue = inputValue;
|
|
7325
7326
|
if (inputValue.endsWith(".")) {
|
|
7326
7327
|
finalValue = inputValue.slice(0, -1);
|
|
7327
7328
|
}
|
|
7328
|
-
|
|
7329
|
+
// Nếu giá trị rỗng hoặc chỉ có dấu chấm, trả về "0"
|
|
7330
|
+
if (!finalValue || finalValue === ".") {
|
|
7331
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("0");
|
|
7332
|
+
onClose();
|
|
7333
|
+
return;
|
|
7334
|
+
}
|
|
7335
|
+
// Ép kiểu kết quả thành số theo type
|
|
7336
|
+
if (type === "integer") {
|
|
7337
|
+
var intValue = parseInt(finalValue, 10);
|
|
7338
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(intValue.toString());
|
|
7339
|
+
}
|
|
7340
|
+
else {
|
|
7341
|
+
var floatValue = parseFloat(finalValue);
|
|
7342
|
+
// Giới hạn số chữ số thập phân theo formatDecimal
|
|
7343
|
+
var formattedFloat = floatValue.toFixed(formatDecimal);
|
|
7344
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(formattedFloat);
|
|
7345
|
+
}
|
|
7329
7346
|
onClose();
|
|
7330
|
-
}, [inputValue, onChangeText, onClose]);
|
|
7347
|
+
}, [inputValue, onChangeText, onClose, type, formatDecimal]);
|
|
7331
7348
|
var handleClose = useCallback(function () {
|
|
7332
7349
|
onClose();
|
|
7333
7350
|
setTimeout(function () {
|