sapo-components-ui-rn 1.1.92 → 1.1.94
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/.DS_Store +0 -0
- package/dist/components/TextInput/TextInputNumber.d.ts +4 -4
- package/dist/index.esm.js +143 -108
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +143 -108
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/.DS_Store
CHANGED
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { StyleProp, ViewStyle, TouchableOpacityProps, TextStyle } from
|
|
3
|
-
import { ThemeProp } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleProp, ViewStyle, TouchableOpacityProps, TextStyle } from "react-native";
|
|
3
|
+
import { ThemeProp } from "../../types";
|
|
4
4
|
export interface TextInputNumberProps extends TouchableOpacityProps {
|
|
5
5
|
style?: StyleProp<ViewStyle>;
|
|
6
6
|
keyboardStyle?: StyleProp<ViewStyle>;
|
|
@@ -17,7 +17,7 @@ export interface TextInputNumberProps extends TouchableOpacityProps {
|
|
|
17
17
|
theme?: ThemeProp;
|
|
18
18
|
maxValue?: number;
|
|
19
19
|
minValue?: number;
|
|
20
|
-
type?:
|
|
20
|
+
type?: "integer" | "float";
|
|
21
21
|
formatDecimal?: 1 | 2 | 3;
|
|
22
22
|
required?: boolean;
|
|
23
23
|
labelStyle?: StyleProp<TextStyle>;
|
package/dist/index.esm.js
CHANGED
|
@@ -5376,59 +5376,59 @@ var ScaleButton$1 = React__default.memo(ScaleButton);
|
|
|
5376
5376
|
|
|
5377
5377
|
function formatNumberInput$1(value, formatDecimal) {
|
|
5378
5378
|
if (!value)
|
|
5379
|
-
return
|
|
5380
|
-
if (value ===
|
|
5381
|
-
return
|
|
5379
|
+
return "";
|
|
5380
|
+
if (value === "")
|
|
5381
|
+
return "";
|
|
5382
5382
|
// Xử lý số âm
|
|
5383
|
-
var isNegative = value.startsWith(
|
|
5384
|
-
var _a = value.replace(/[^0-9.]/g,
|
|
5383
|
+
var isNegative = value.startsWith("-");
|
|
5384
|
+
var _a = value.replace(/[^0-9.]/g, "").split("."), intPart = _a[0], decimalPart = _a[1];
|
|
5385
5385
|
// Format phần nguyên
|
|
5386
|
-
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g,
|
|
5386
|
+
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
5387
5387
|
// Giới hạn phần thập phân 3 số
|
|
5388
5388
|
if (decimalPart)
|
|
5389
5389
|
decimalPart = decimalPart.slice(0, formatDecimal);
|
|
5390
5390
|
var result = intPart;
|
|
5391
5391
|
if (decimalPart !== undefined)
|
|
5392
|
-
result +=
|
|
5392
|
+
result += "." + decimalPart;
|
|
5393
5393
|
if (isNegative)
|
|
5394
|
-
result =
|
|
5394
|
+
result = "-" + result;
|
|
5395
5395
|
return result;
|
|
5396
5396
|
}
|
|
5397
5397
|
function formatShowInput(value, formatDecimal) {
|
|
5398
5398
|
if (!value)
|
|
5399
|
-
return
|
|
5400
|
-
if (value ===
|
|
5401
|
-
return
|
|
5399
|
+
return "";
|
|
5400
|
+
if (value === "")
|
|
5401
|
+
return "";
|
|
5402
5402
|
// Xử lý số âm
|
|
5403
|
-
var isNegative = value.startsWith(
|
|
5404
|
-
var _a = value.replace(/[^0-9.]/g,
|
|
5403
|
+
var isNegative = value.startsWith("-");
|
|
5404
|
+
var _a = value.replace(/[^0-9.]/g, "").split("."), intPart = _a[0], decimalPart = _a[1];
|
|
5405
5405
|
// Format phần nguyên
|
|
5406
|
-
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g,
|
|
5406
|
+
intPart = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, "");
|
|
5407
5407
|
// Giới hạn phần thập phân 3 số
|
|
5408
5408
|
if (decimalPart)
|
|
5409
5409
|
decimalPart = decimalPart.slice(0, formatDecimal);
|
|
5410
5410
|
var result = intPart;
|
|
5411
5411
|
if (decimalPart !== undefined)
|
|
5412
|
-
result +=
|
|
5412
|
+
result += "." + decimalPart;
|
|
5413
5413
|
if (isNegative)
|
|
5414
|
-
result =
|
|
5414
|
+
result = "-" + result;
|
|
5415
5415
|
return result;
|
|
5416
5416
|
}
|
|
5417
5417
|
var TextInputNumber = function (_a) {
|
|
5418
|
-
var style = _a.style, _b = _a.value, value = _b === void 0 ?
|
|
5418
|
+
var style = _a.style, _b = _a.value, value = _b === void 0 ? "" : _b, _c = _a.label, label = _c === void 0 ? "" : _c, _d = _a.textError, textError = _d === void 0 ? "" : _d, left = _a.left, right = _a.right, onChangeText = _a.onChangeText, _e = _a.disabled, disabled = _e === void 0 ? false : _e; _a.theme; var _f = _a.prefix, prefix = _f === void 0 ? "" : _f, _g = _a.suffix, suffix = _g === void 0 ? "" : _g, _h = _a.clearButton, clearButton = _h === void 0 ? false : _h, _j = _a.maxValue, maxValue = _j === void 0 ? 999999999999 : _j, _k = _a.minValue, minValue = _k === void 0 ? 0 : _k, _l = _a.type, type = _l === void 0 ? "integer" : _l, _m = _a.formatDecimal, formatDecimal = _m === void 0 ? 3 : _m, _o = _a.required, required = _o === void 0 ? false : _o, labelStyle = _a.labelStyle, contentStyle = _a.contentStyle, textErrorStyle = _a.textErrorStyle, height = _a.height, _p = _a.keyboardStyle, keyboardStyle = _p === void 0 ? {} : _p, props = __rest(_a, ["style", "value", "label", "textError", "left", "right", "onChangeText", "disabled", "theme", "prefix", "suffix", "clearButton", "maxValue", "minValue", "type", "formatDecimal", "required", "labelStyle", "contentStyle", "textErrorStyle", "height", "keyboardStyle"]);
|
|
5419
5419
|
var theme = useInternalTheme();
|
|
5420
5420
|
var colors = theme.colors;
|
|
5421
5421
|
var _q = useState(false), isShowModalKeyboard = _q[0], setIsShowModalKeyboard = _q[1];
|
|
5422
|
-
var _r = useState((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
5423
|
-
var _s = useState((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
5422
|
+
var _r = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), inputValue = _r[0], setInputValue = _r[1];
|
|
5423
|
+
var _s = useState((value === null || value === void 0 ? void 0 : value.toString()) || ""), numberValue = _s[0], setNumberValue = _s[1];
|
|
5424
5424
|
var _t = useState(true), canSave = _t[0], setCanSave = _t[1];
|
|
5425
5425
|
var _u = useState(false), isFirstInput = _u[0], setIsFirstInput = _u[1];
|
|
5426
5426
|
var disabledTextStyle = {
|
|
5427
5427
|
color: colors.textSecondary,
|
|
5428
5428
|
};
|
|
5429
5429
|
useEffect(function () {
|
|
5430
|
-
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
5431
|
-
setNumberValue((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
5430
|
+
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) || "");
|
|
5431
|
+
setNumberValue((value === null || value === void 0 ? void 0 : value.toString()) || "");
|
|
5432
5432
|
}, [value]);
|
|
5433
5433
|
useEffect(function () {
|
|
5434
5434
|
var currentValue = Number(inputValue);
|
|
@@ -5476,18 +5476,33 @@ var TextInputNumber = function (_a) {
|
|
|
5476
5476
|
}
|
|
5477
5477
|
return colors.textSecondary;
|
|
5478
5478
|
}, [colors, textError, disabled, numberValue]);
|
|
5479
|
+
// Integer: chỉ cho phép "000" khi value hiện tại khác 0 (vd: 1→1000).
|
|
5480
|
+
// Rỗng / 0 / chỉ dấu "-" → disable nút 000.
|
|
5481
|
+
var is000Disabled = useMemo(function () {
|
|
5482
|
+
if (type !== "integer") {
|
|
5483
|
+
return true;
|
|
5484
|
+
}
|
|
5485
|
+
if (!inputValue || inputValue === "-") {
|
|
5486
|
+
return true;
|
|
5487
|
+
}
|
|
5488
|
+
var numericValue = Number(inputValue);
|
|
5489
|
+
return isNaN(numericValue) || numericValue === 0;
|
|
5490
|
+
}, [type, inputValue]);
|
|
5479
5491
|
var handleKeyPress = function (key) {
|
|
5480
|
-
if (key ===
|
|
5492
|
+
if (key === "del") {
|
|
5481
5493
|
setInputValue(function (prev) { return prev.slice(0, -1); });
|
|
5482
5494
|
}
|
|
5483
|
-
else if (key ===
|
|
5484
|
-
if (type ===
|
|
5495
|
+
else if (key === "000") {
|
|
5496
|
+
if (type === "integer") {
|
|
5497
|
+
if (is000Disabled) {
|
|
5498
|
+
return;
|
|
5499
|
+
}
|
|
5485
5500
|
// Xử lý trường hợp nhập "000" để tạo số lớn hơn
|
|
5486
5501
|
// Ví dụ: "1" + "000" = "1000", "10" + "000" = "10000"
|
|
5487
5502
|
// Nếu vượt quá maxValue, sẽ tự động cắt bớt số 0
|
|
5488
5503
|
// Logic này đảm bảo người dùng có thể tiếp tục nhập số đã được khởi tạo
|
|
5489
5504
|
// Ví dụ: value=999, người dùng có thể nhập "000" để tạo "999000"
|
|
5490
|
-
var newInputValue = inputValue +
|
|
5505
|
+
var newInputValue = inputValue + "000";
|
|
5491
5506
|
var newValue = Number(newInputValue);
|
|
5492
5507
|
var maxValueNumber = Number(maxValue);
|
|
5493
5508
|
// Kiểm tra nếu giá trị vượt quá maxValue, cắt bớt số 0
|
|
@@ -5496,18 +5511,18 @@ var TextInputNumber = function (_a) {
|
|
|
5496
5511
|
newValue > maxValueNumber) {
|
|
5497
5512
|
// Tìm số 0 tối đa có thể thêm vào mà không vượt quá maxValue
|
|
5498
5513
|
var tempValue = inputValue;
|
|
5499
|
-
var tempNewValue = Number(tempValue +
|
|
5514
|
+
var tempNewValue = Number(tempValue + "000");
|
|
5500
5515
|
// Giảm dần số 0 cho đến khi không vượt quá maxValue
|
|
5501
|
-
while (tempNewValue > maxValueNumber && tempValue.endsWith(
|
|
5516
|
+
while (tempNewValue > maxValueNumber && tempValue.endsWith("0")) {
|
|
5502
5517
|
tempValue = tempValue.slice(0, -1);
|
|
5503
|
-
tempNewValue = Number(tempValue +
|
|
5518
|
+
tempNewValue = Number(tempValue + "000");
|
|
5504
5519
|
}
|
|
5505
5520
|
// Nếu vẫn vượt quá, chỉ thêm số 0 có thể
|
|
5506
5521
|
if (tempNewValue > maxValueNumber) {
|
|
5507
5522
|
// Tìm số 0 tối đa có thể thêm
|
|
5508
5523
|
var maxZeros = 0;
|
|
5509
5524
|
for (var i = 1; i <= 3; i++) {
|
|
5510
|
-
var testValue = Number(inputValue +
|
|
5525
|
+
var testValue = Number(inputValue + "0".repeat(i));
|
|
5511
5526
|
if (testValue <= maxValueNumber) {
|
|
5512
5527
|
maxZeros = i;
|
|
5513
5528
|
}
|
|
@@ -5516,7 +5531,7 @@ var TextInputNumber = function (_a) {
|
|
|
5516
5531
|
}
|
|
5517
5532
|
}
|
|
5518
5533
|
if (maxZeros > 0) {
|
|
5519
|
-
newInputValue = inputValue +
|
|
5534
|
+
newInputValue = inputValue + "0".repeat(maxZeros);
|
|
5520
5535
|
newValue = Number(newInputValue);
|
|
5521
5536
|
}
|
|
5522
5537
|
else {
|
|
@@ -5525,7 +5540,7 @@ var TextInputNumber = function (_a) {
|
|
|
5525
5540
|
}
|
|
5526
5541
|
}
|
|
5527
5542
|
else {
|
|
5528
|
-
newInputValue = tempValue +
|
|
5543
|
+
newInputValue = tempValue + "000";
|
|
5529
5544
|
newValue = Number(newInputValue);
|
|
5530
5545
|
}
|
|
5531
5546
|
}
|
|
@@ -5539,15 +5554,15 @@ var TextInputNumber = function (_a) {
|
|
|
5539
5554
|
}
|
|
5540
5555
|
// Nếu type là float, không cho phép nhập "000" ở đầu
|
|
5541
5556
|
}
|
|
5542
|
-
else if (key ===
|
|
5543
|
-
if (!inputValue.includes(
|
|
5557
|
+
else if (key === ".") {
|
|
5558
|
+
if (!inputValue.includes(".")) {
|
|
5544
5559
|
// Nếu inputValue là "0" hoặc rỗng, giữ lại số 0 và thêm dấu "."
|
|
5545
|
-
if (inputValue ===
|
|
5546
|
-
setInputValue(
|
|
5560
|
+
if (inputValue === "0" || inputValue === "") {
|
|
5561
|
+
setInputValue("0.");
|
|
5547
5562
|
}
|
|
5548
|
-
else if (inputValue ===
|
|
5563
|
+
else if (inputValue === "-") {
|
|
5549
5564
|
// Nếu chỉ có dấu trừ, thêm "0."
|
|
5550
|
-
setInputValue(
|
|
5565
|
+
setInputValue("-0.");
|
|
5551
5566
|
}
|
|
5552
5567
|
else {
|
|
5553
5568
|
// Nếu đã có giá trị, thêm dấu "." vào cuối
|
|
@@ -5559,7 +5574,7 @@ var TextInputNumber = function (_a) {
|
|
|
5559
5574
|
else {
|
|
5560
5575
|
if (isFirstInput) {
|
|
5561
5576
|
// Nếu type là float và key là "0", không cho phép nhập số 0 đầu tiên
|
|
5562
|
-
if (type ===
|
|
5577
|
+
if (type === "float" && (key === "0" || key === "000")) {
|
|
5563
5578
|
return;
|
|
5564
5579
|
}
|
|
5565
5580
|
// Kiểm tra xem có thể nhập được không khi là lần đầu
|
|
@@ -5579,7 +5594,7 @@ var TextInputNumber = function (_a) {
|
|
|
5579
5594
|
}
|
|
5580
5595
|
if (canInput) {
|
|
5581
5596
|
// Nếu inputValue rỗng hoặc chỉ có dấu trừ, thay thế hoàn toàn
|
|
5582
|
-
if (inputValue ===
|
|
5597
|
+
if (inputValue === "" || inputValue === "-") {
|
|
5583
5598
|
setInputValue(key);
|
|
5584
5599
|
}
|
|
5585
5600
|
else {
|
|
@@ -5595,7 +5610,7 @@ var TextInputNumber = function (_a) {
|
|
|
5595
5610
|
}
|
|
5596
5611
|
else {
|
|
5597
5612
|
// Nếu inputValue rỗng hoặc chỉ có dấu trừ, thay thế hoàn toàn
|
|
5598
|
-
if (inputValue ===
|
|
5613
|
+
if (inputValue === "" || inputValue === "-") {
|
|
5599
5614
|
setInputValue(key);
|
|
5600
5615
|
}
|
|
5601
5616
|
else {
|
|
@@ -5607,12 +5622,12 @@ var TextInputNumber = function (_a) {
|
|
|
5607
5622
|
}
|
|
5608
5623
|
else {
|
|
5609
5624
|
// Kiểm tra nếu input bắt đầu bằng 0 và không có dấu chấm
|
|
5610
|
-
if (inputValue ===
|
|
5611
|
-
if (key ===
|
|
5612
|
-
setInputValue(
|
|
5625
|
+
if (inputValue === "0") {
|
|
5626
|
+
if (key === ".") {
|
|
5627
|
+
setInputValue("0.");
|
|
5613
5628
|
return;
|
|
5614
5629
|
}
|
|
5615
|
-
else if (key >=
|
|
5630
|
+
else if (key >= "1" && key <= "9") {
|
|
5616
5631
|
setInputValue(key);
|
|
5617
5632
|
return;
|
|
5618
5633
|
}
|
|
@@ -5636,7 +5651,13 @@ var TextInputNumber = function (_a) {
|
|
|
5636
5651
|
}
|
|
5637
5652
|
else {
|
|
5638
5653
|
// Nếu vượt quá maxValue, kiểm tra xem có thể nhập được không
|
|
5639
|
-
|
|
5654
|
+
// Khi chuỗi nhập chưa có dấu ".", người dùng đang gõ phần
|
|
5655
|
+
// nguyên nên phải so độ dài với PHẦN NGUYÊN của maxValue.
|
|
5656
|
+
// Nếu so với cả chuỗi (vd "999999.999" dài 10 ký tự) thì mốc
|
|
5657
|
+
// chặn dài hơn số chữ số nguyên thật (6), cho gõ tới 9 chữ số.
|
|
5658
|
+
var maxValueStr = newInputValue.includes(".")
|
|
5659
|
+
? absMaxValue.toString()
|
|
5660
|
+
: Math.trunc(absMaxValue).toString();
|
|
5640
5661
|
inputValue.length;
|
|
5641
5662
|
var newLength = newInputValue.length;
|
|
5642
5663
|
// Nếu độ dài mới lớn hơn độ dài của maxValue, không cho phép nhập
|
|
@@ -5660,7 +5681,11 @@ var TextInputNumber = function (_a) {
|
|
|
5660
5681
|
}
|
|
5661
5682
|
else {
|
|
5662
5683
|
// Nếu vượt quá maxValue, kiểm tra xem có thể nhập được không
|
|
5663
|
-
|
|
5684
|
+
// Xem giải thích ở nhánh số âm phía trên. Dùng Math.abs trước
|
|
5685
|
+
// khi trunc để đối xứng với nhánh đó.
|
|
5686
|
+
var maxValueStr = newInputValue.includes(".")
|
|
5687
|
+
? maxValueNumber.toString()
|
|
5688
|
+
: Math.trunc(Math.abs(maxValueNumber)).toString();
|
|
5664
5689
|
inputValue.length;
|
|
5665
5690
|
var newLength = newInputValue.length;
|
|
5666
5691
|
// Nếu độ dài mới lớn hơn độ dài của maxValue, không cho phép nhập
|
|
@@ -5680,9 +5705,9 @@ var TextInputNumber = function (_a) {
|
|
|
5680
5705
|
}
|
|
5681
5706
|
}
|
|
5682
5707
|
if (canInput) {
|
|
5683
|
-
if (inputValue.includes(
|
|
5708
|
+
if (inputValue.includes(".")) {
|
|
5684
5709
|
// Xử lý số thập phân
|
|
5685
|
-
var _a = inputValue.split(
|
|
5710
|
+
var _a = inputValue.split("."); _a[0]; var _b = _a[1], decimalPart = _b === void 0 ? "" : _b;
|
|
5686
5711
|
if (newInputValue.length <= 12 && decimalPart.length === 0) {
|
|
5687
5712
|
setInputValue(function (prev) { return prev + key; });
|
|
5688
5713
|
}
|
|
@@ -5705,16 +5730,16 @@ var TextInputNumber = function (_a) {
|
|
|
5705
5730
|
}
|
|
5706
5731
|
};
|
|
5707
5732
|
var handleClear = function () {
|
|
5708
|
-
setInputValue(
|
|
5733
|
+
setInputValue("");
|
|
5709
5734
|
};
|
|
5710
5735
|
var handleClearInput = function () {
|
|
5711
|
-
setInputValue(
|
|
5712
|
-
setNumberValue(
|
|
5713
|
-
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(
|
|
5736
|
+
setInputValue("");
|
|
5737
|
+
setNumberValue("");
|
|
5738
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("");
|
|
5714
5739
|
};
|
|
5715
5740
|
var handleSave = function () {
|
|
5716
5741
|
var finalValue = inputValue;
|
|
5717
|
-
if (inputValue.endsWith(
|
|
5742
|
+
if (inputValue.endsWith(".")) {
|
|
5718
5743
|
finalValue = inputValue.slice(0, -1);
|
|
5719
5744
|
}
|
|
5720
5745
|
if (formatDecimal) {
|
|
@@ -5728,13 +5753,13 @@ var TextInputNumber = function (_a) {
|
|
|
5728
5753
|
setIsShowModalKeyboard(false);
|
|
5729
5754
|
};
|
|
5730
5755
|
var checkValueEmpty = function () {
|
|
5731
|
-
if (value === undefined || value === null || value.toString() ===
|
|
5756
|
+
if (value === undefined || value === null || value.toString() === "") {
|
|
5732
5757
|
return true;
|
|
5733
5758
|
}
|
|
5734
5759
|
return false;
|
|
5735
5760
|
};
|
|
5736
5761
|
var checkLabelEmpty = function () {
|
|
5737
|
-
if (label === undefined || label === null || label.toString() ===
|
|
5762
|
+
if (label === undefined || label === null || label.toString() === "") {
|
|
5738
5763
|
return true;
|
|
5739
5764
|
}
|
|
5740
5765
|
return false;
|
|
@@ -5745,7 +5770,7 @@ var TextInputNumber = function (_a) {
|
|
|
5745
5770
|
// Chỉ set isFirstInput = true khi inputValue rỗng hoặc chỉ có dấu trừ
|
|
5746
5771
|
// Điều này cho phép người dùng tiếp tục nhập từ giá trị hiện tại
|
|
5747
5772
|
// Ví dụ: value=999, người dùng có thể nhập "000" để tạo "999000"
|
|
5748
|
-
if (inputValue ===
|
|
5773
|
+
if (inputValue === "" || inputValue === "-") {
|
|
5749
5774
|
setIsFirstInput(true);
|
|
5750
5775
|
}
|
|
5751
5776
|
else {
|
|
@@ -5756,7 +5781,7 @@ var TextInputNumber = function (_a) {
|
|
|
5756
5781
|
var onCloseModalKeyboard = function () {
|
|
5757
5782
|
setIsShowModalKeyboard(false);
|
|
5758
5783
|
setTimeout(function () {
|
|
5759
|
-
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
5784
|
+
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) || "");
|
|
5760
5785
|
}, 300);
|
|
5761
5786
|
};
|
|
5762
5787
|
return (React__default.createElement(View, null,
|
|
@@ -5778,7 +5803,7 @@ var TextInputNumber = function (_a) {
|
|
|
5778
5803
|
},
|
|
5779
5804
|
],
|
|
5780
5805
|
checkValueEmpty() && {
|
|
5781
|
-
alignItems:
|
|
5806
|
+
alignItems: "center",
|
|
5782
5807
|
},
|
|
5783
5808
|
textError.length > 0 && [
|
|
5784
5809
|
{
|
|
@@ -5796,7 +5821,7 @@ var TextInputNumber = function (_a) {
|
|
|
5796
5821
|
style,
|
|
5797
5822
|
] },
|
|
5798
5823
|
React__default.createElement(Spacer, { width: SPACE_12 }),
|
|
5799
|
-
left && (React__default.createElement(View, { center: true, paddingRight: SPACE_8, height:
|
|
5824
|
+
left && (React__default.createElement(View, { center: true, paddingRight: SPACE_8, height: "100%" }, left)),
|
|
5800
5825
|
React__default.createElement(View, { full: true, paddingRight: SPACE_4 },
|
|
5801
5826
|
!checkValueEmpty() && !checkLabelEmpty() && (React__default.createElement(View, null,
|
|
5802
5827
|
React__default.createElement(Text$1, { numberOfLines: 1, size: 14, color: colors.textSecondary, style: [
|
|
@@ -5810,10 +5835,10 @@ var TextInputNumber = function (_a) {
|
|
|
5810
5835
|
] },
|
|
5811
5836
|
label,
|
|
5812
5837
|
required && (React__default.createElement(Text$1, { style: [labelStyle], color: colors.textErrorDefault },
|
|
5813
|
-
|
|
5838
|
+
" ",
|
|
5814
5839
|
"*"))))),
|
|
5815
5840
|
React__default.createElement(View, { row: true, alignCenter: true },
|
|
5816
|
-
!checkValueEmpty() && prefix.toString() !==
|
|
5841
|
+
!checkValueEmpty() && prefix.toString() !== "" && (React__default.createElement(Text$1, { numberOfLines: 1, color: colors.textSecondary, style: [contentStyle, , disabled && disabledTextStyle] },
|
|
5817
5842
|
prefix, " ")),
|
|
5818
5843
|
React__default.createElement(View, { full: true },
|
|
5819
5844
|
React__default.createElement(Text$1, { numberOfLines: 1, color: getColorValue, style: [contentStyle, disabled && disabledTextStyle] },
|
|
@@ -5821,19 +5846,19 @@ var TextInputNumber = function (_a) {
|
|
|
5821
5846
|
? label
|
|
5822
5847
|
: formatNumberInput$1(numberValue, formatDecimal),
|
|
5823
5848
|
checkValueEmpty() && required && (React__default.createElement(Text$1, { style: [contentStyle], color: colors.textErrorDefault },
|
|
5824
|
-
|
|
5849
|
+
" ",
|
|
5825
5850
|
"*")))),
|
|
5826
|
-
!checkValueEmpty() && suffix.toString() !==
|
|
5851
|
+
!checkValueEmpty() && suffix.toString() !== "" && (React__default.createElement(Text$1, { numberOfLines: 1, color: colors.textSecondary, style: [contentStyle, disabled && disabledTextStyle] }, " ",
|
|
5827
5852
|
suffix)))),
|
|
5828
5853
|
clearButton && !checkValueEmpty() && (React__default.createElement(TouchableOpacity, { style: {
|
|
5829
|
-
alignContent:
|
|
5830
|
-
paddingTop: Platform.OS ===
|
|
5854
|
+
alignContent: "center",
|
|
5855
|
+
paddingTop: Platform.OS === "ios" ? 4 : 8,
|
|
5831
5856
|
}, activeOpacity: 0.8, onPress: handleClearInput },
|
|
5832
5857
|
React__default.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24 }))),
|
|
5833
5858
|
right && numberValue && (React__default.createElement(Spacer, { width: 1, height: 24, backgroundColor: theme.colors.borderPrimaryDefault, style: {
|
|
5834
5859
|
marginLeft: SPACE_4,
|
|
5835
5860
|
} })),
|
|
5836
|
-
right && (React__default.createElement(View, { center: true, paddingLeft: SPACE_8, height:
|
|
5861
|
+
right && (React__default.createElement(View, { center: true, paddingLeft: SPACE_8, height: "100%" }, right)),
|
|
5837
5862
|
React__default.createElement(Spacer, { width: SPACE_12 }))),
|
|
5838
5863
|
!disabled && textError.length > 0 && (React__default.createElement(View, { paddingHorizontal: SPACE_12, paddingVertical: SPACE_4 },
|
|
5839
5864
|
React__default.createElement(Text$1, { size: 14, numberOfLines: 1, color: theme.colors.textErrorDefault, style: [textErrorStyle] }, textError))),
|
|
@@ -5841,38 +5866,38 @@ var TextInputNumber = function (_a) {
|
|
|
5841
5866
|
React__default.createElement(TouchableOpacity, { style: styles$c.modalOverlay, activeOpacity: 1, onPress: onCloseModalKeyboard },
|
|
5842
5867
|
React__default.createElement(View, { onPress: function () { }, activeOpacity: 1, backgroundColor: colors.surfacePrimaryDefault, style: [styles$c.modalContent, keyboardStyle] },
|
|
5843
5868
|
React__default.createElement(Text$1, { style: [styles$c.modalTitle, styles$c.text18] }, label),
|
|
5844
|
-
React__default.createElement(View, { width:
|
|
5869
|
+
React__default.createElement(View, { width: "100%" },
|
|
5845
5870
|
React__default.createElement(View, { paddingHorizontal: SPACE_40 },
|
|
5846
|
-
React__default.createElement(Text$1, { numberOfLines: 1, style: [styles$c.text30, styles$c.valueText] }, formatNumberInput$1(inputValue, formatDecimal) ||
|
|
5871
|
+
React__default.createElement(Text$1, { numberOfLines: 1, style: [styles$c.text30, styles$c.valueText] }, formatNumberInput$1(inputValue, formatDecimal) || "")),
|
|
5847
5872
|
React__default.createElement(TouchableOpacity, { onPress: handleClear, style: styles$c.clearButton },
|
|
5848
5873
|
React__default.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24, color: colors.textSecondary }))),
|
|
5849
5874
|
React__default.createElement(View, { style: styles$c.keyboardGrid }, [
|
|
5850
|
-
[
|
|
5851
|
-
[
|
|
5852
|
-
[
|
|
5853
|
-
[type ===
|
|
5875
|
+
["1", "2", "3"],
|
|
5876
|
+
["4", "5", "6"],
|
|
5877
|
+
["7", "8", "9"],
|
|
5878
|
+
[type === "integer" ? "000" : ".", "0", "del"],
|
|
5854
5879
|
].map(function (row, rowIndex) { return (React__default.createElement(View, { key: rowIndex, style: styles$c.keyboardRow }, row.map(function (key) { return (React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, key: key, style: [
|
|
5855
5880
|
styles$c.keyButton,
|
|
5856
|
-
key ===
|
|
5857
|
-
key ===
|
|
5858
|
-
inputValue.includes(
|
|
5881
|
+
key === "000" && is000Disabled && styles$c.disabledKey,
|
|
5882
|
+
key === "." &&
|
|
5883
|
+
inputValue.includes(".") &&
|
|
5859
5884
|
styles$c.disabledKey,
|
|
5860
|
-
], onPress: function () { return handleKeyPress(key); }, disabled: (key ===
|
|
5861
|
-
(key ===
|
|
5885
|
+
], onPress: function () { return handleKeyPress(key); }, disabled: (key === "000" && is000Disabled) ||
|
|
5886
|
+
(key === "." && inputValue.includes(".")) }, key === "del" ? (React__default.createElement(SvgIcon, { name: "IconDelNumber", width: 24, height: 24, color: colors.textSecondary })) : (React__default.createElement(Text$1, { style: [
|
|
5862
5887
|
styles$c.keyText,
|
|
5863
5888
|
styles$c.text22,
|
|
5864
|
-
key ===
|
|
5865
|
-
|
|
5889
|
+
key === "000" &&
|
|
5890
|
+
is000Disabled &&
|
|
5866
5891
|
styles$c.disabledKeyText,
|
|
5867
|
-
key ===
|
|
5868
|
-
inputValue.includes(
|
|
5892
|
+
key === "." &&
|
|
5893
|
+
inputValue.includes(".") &&
|
|
5869
5894
|
styles$c.disabledKeyText,
|
|
5870
5895
|
] }, key)))); }))); })),
|
|
5871
5896
|
React__default.createElement(View, { style: styles$c.actionRow },
|
|
5872
5897
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: styles$c.actionButton, onPress: onCloseModalKeyboard },
|
|
5873
5898
|
React__default.createElement(Text$1, { style: [styles$c.actionText, styles$c.text16] }, "\u0110\u00F3ng")),
|
|
5874
5899
|
React__default.createElement(Spacer, { style: {
|
|
5875
|
-
height:
|
|
5900
|
+
height: "100%",
|
|
5876
5901
|
}, width: 1, backgroundColor: colors.borderPrimaryDefault }),
|
|
5877
5902
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: [styles$c.actionButton, !canSave && { opacity: 0.5 }], onPress: handleSave, disabled: !canSave },
|
|
5878
5903
|
React__default.createElement(Text$1, { style: [
|
|
@@ -5884,9 +5909,9 @@ var TextInputNumber = function (_a) {
|
|
|
5884
5909
|
};
|
|
5885
5910
|
var styles$c = StyleSheet.create(__assign(__assign({}, containerStyles), { disabled: { opacity: 0.6 }, container: {
|
|
5886
5911
|
height: 48,
|
|
5887
|
-
flexDirection:
|
|
5888
|
-
justifyContent:
|
|
5889
|
-
alignItems:
|
|
5912
|
+
flexDirection: "row",
|
|
5913
|
+
justifyContent: "space-between",
|
|
5914
|
+
alignItems: "center",
|
|
5890
5915
|
// paddingVertical: Platform.OS === "android" ? 3 : SPACE_6
|
|
5891
5916
|
}, border: {
|
|
5892
5917
|
borderWidth: BORDER_WIDTH_1,
|
|
@@ -5894,54 +5919,54 @@ var styles$c = StyleSheet.create(__assign(__assign({}, containerStyles), { disab
|
|
|
5894
5919
|
height: BUTTON_HEIGHT_SMALL,
|
|
5895
5920
|
}, modalOverlay: {
|
|
5896
5921
|
flex: 1,
|
|
5897
|
-
backgroundColor:
|
|
5898
|
-
justifyContent:
|
|
5899
|
-
alignItems:
|
|
5922
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
5923
|
+
justifyContent: "center",
|
|
5924
|
+
alignItems: "center",
|
|
5900
5925
|
}, modalContent: {
|
|
5901
5926
|
borderRadius: 20,
|
|
5902
|
-
width:
|
|
5927
|
+
width: "90%",
|
|
5903
5928
|
paddingBottom: 20,
|
|
5904
|
-
alignItems:
|
|
5905
|
-
overflow:
|
|
5929
|
+
alignItems: "center",
|
|
5930
|
+
overflow: "hidden",
|
|
5906
5931
|
}, modalTitle: {
|
|
5907
|
-
textAlign:
|
|
5932
|
+
textAlign: "center",
|
|
5908
5933
|
marginTop: 16,
|
|
5909
5934
|
marginBottom: 8,
|
|
5910
5935
|
}, valueText: {
|
|
5911
|
-
textAlign:
|
|
5936
|
+
textAlign: "center",
|
|
5912
5937
|
}, clearButton: {
|
|
5913
5938
|
padding: 8,
|
|
5914
|
-
position:
|
|
5939
|
+
position: "absolute",
|
|
5915
5940
|
right: SPACE_12,
|
|
5916
5941
|
}, keyboardGrid: {
|
|
5917
5942
|
marginVertical: 8,
|
|
5918
|
-
width:
|
|
5943
|
+
width: "90%",
|
|
5919
5944
|
}, keyboardRow: {
|
|
5920
|
-
flexDirection:
|
|
5921
|
-
justifyContent:
|
|
5945
|
+
flexDirection: "row",
|
|
5946
|
+
justifyContent: "space-between",
|
|
5922
5947
|
marginBottom: 8,
|
|
5923
5948
|
}, keyButton: {
|
|
5924
5949
|
flex: 1,
|
|
5925
5950
|
marginHorizontal: 6,
|
|
5926
|
-
backgroundColor:
|
|
5951
|
+
backgroundColor: "#F5F5F5",
|
|
5927
5952
|
borderRadius: 8,
|
|
5928
|
-
alignItems:
|
|
5929
|
-
justifyContent:
|
|
5953
|
+
alignItems: "center",
|
|
5954
|
+
justifyContent: "center",
|
|
5930
5955
|
height: 48,
|
|
5931
5956
|
}, keyText: {
|
|
5932
|
-
fontWeight:
|
|
5957
|
+
fontWeight: "500",
|
|
5933
5958
|
}, actionRow: {
|
|
5934
|
-
flexDirection:
|
|
5935
|
-
justifyContent:
|
|
5959
|
+
flexDirection: "row",
|
|
5960
|
+
justifyContent: "space-between",
|
|
5936
5961
|
marginTop: 12,
|
|
5937
|
-
width:
|
|
5962
|
+
width: "90%",
|
|
5938
5963
|
paddingHorizontal: 16,
|
|
5939
5964
|
}, actionButton: {
|
|
5940
5965
|
flex: 1,
|
|
5941
|
-
alignItems:
|
|
5966
|
+
alignItems: "center",
|
|
5942
5967
|
paddingVertical: 12,
|
|
5943
5968
|
}, actionText: {
|
|
5944
|
-
fontWeight:
|
|
5969
|
+
fontWeight: "600",
|
|
5945
5970
|
}, disabledKey: {
|
|
5946
5971
|
opacity: 0.5,
|
|
5947
5972
|
}, disabledKeyText: {
|
|
@@ -7512,7 +7537,13 @@ var NumberKeyboard = function (_a) {
|
|
|
7512
7537
|
}
|
|
7513
7538
|
else {
|
|
7514
7539
|
// Nếu vượt quá maxValue, kiểm tra xem có thể nhập được không
|
|
7515
|
-
|
|
7540
|
+
// Khi chuỗi nhập chưa có dấu ".", người dùng đang gõ phần
|
|
7541
|
+
// nguyên nên phải so độ dài với PHẦN NGUYÊN của maxValue.
|
|
7542
|
+
// Nếu so với cả chuỗi (vd "999999.999" dài 10 ký tự) thì mốc
|
|
7543
|
+
// chặn dài hơn số chữ số nguyên thật (6), cho gõ tới 9 chữ số.
|
|
7544
|
+
var maxValueStr = newInputValue.includes('.')
|
|
7545
|
+
? absMaxValue.toString()
|
|
7546
|
+
: Math.trunc(absMaxValue).toString();
|
|
7516
7547
|
inputValue.length;
|
|
7517
7548
|
var newLength = newInputValue.length;
|
|
7518
7549
|
// Nếu độ dài mới lớn hơn độ dài của maxValue, không cho phép nhập
|
|
@@ -7536,7 +7567,11 @@ var NumberKeyboard = function (_a) {
|
|
|
7536
7567
|
}
|
|
7537
7568
|
else {
|
|
7538
7569
|
// Nếu vượt quá maxValue, kiểm tra xem có thể nhập được không
|
|
7539
|
-
|
|
7570
|
+
// Xem giải thích ở nhánh số âm phía trên. Dùng Math.abs trước
|
|
7571
|
+
// khi trunc để đối xứng với nhánh đó.
|
|
7572
|
+
var maxValueStr = newInputValue.includes('.')
|
|
7573
|
+
? maxValueNumber.toString()
|
|
7574
|
+
: Math.trunc(Math.abs(maxValueNumber)).toString();
|
|
7540
7575
|
inputValue.length;
|
|
7541
7576
|
var newLength = newInputValue.length;
|
|
7542
7577
|
// Nếu độ dài mới lớn hơn độ dài của maxValue, không cho phép nhập
|