sapo-components-ui-rn 1.1.93 → 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/components/TextInput/TextInputNumber.d.ts +4 -4
- package/dist/index.esm.js +121 -106
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +121 -106
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
}
|
|
@@ -5640,7 +5655,7 @@ var TextInputNumber = function (_a) {
|
|
|
5640
5655
|
// nguyên nên phải so độ dài với PHẦN NGUYÊN của maxValue.
|
|
5641
5656
|
// Nếu so với cả chuỗi (vd "999999.999" dài 10 ký tự) thì mốc
|
|
5642
5657
|
// chặn dài hơn số chữ số nguyên thật (6), cho gõ tới 9 chữ số.
|
|
5643
|
-
var maxValueStr = newInputValue.includes(
|
|
5658
|
+
var maxValueStr = newInputValue.includes(".")
|
|
5644
5659
|
? absMaxValue.toString()
|
|
5645
5660
|
: Math.trunc(absMaxValue).toString();
|
|
5646
5661
|
inputValue.length;
|
|
@@ -5668,7 +5683,7 @@ var TextInputNumber = function (_a) {
|
|
|
5668
5683
|
// Nếu vượt quá maxValue, kiểm tra xem có thể nhập được không
|
|
5669
5684
|
// Xem giải thích ở nhánh số âm phía trên. Dùng Math.abs trước
|
|
5670
5685
|
// khi trunc để đối xứng với nhánh đó.
|
|
5671
|
-
var maxValueStr = newInputValue.includes(
|
|
5686
|
+
var maxValueStr = newInputValue.includes(".")
|
|
5672
5687
|
? maxValueNumber.toString()
|
|
5673
5688
|
: Math.trunc(Math.abs(maxValueNumber)).toString();
|
|
5674
5689
|
inputValue.length;
|
|
@@ -5690,9 +5705,9 @@ var TextInputNumber = function (_a) {
|
|
|
5690
5705
|
}
|
|
5691
5706
|
}
|
|
5692
5707
|
if (canInput) {
|
|
5693
|
-
if (inputValue.includes(
|
|
5708
|
+
if (inputValue.includes(".")) {
|
|
5694
5709
|
// Xử lý số thập phân
|
|
5695
|
-
var _a = inputValue.split(
|
|
5710
|
+
var _a = inputValue.split("."); _a[0]; var _b = _a[1], decimalPart = _b === void 0 ? "" : _b;
|
|
5696
5711
|
if (newInputValue.length <= 12 && decimalPart.length === 0) {
|
|
5697
5712
|
setInputValue(function (prev) { return prev + key; });
|
|
5698
5713
|
}
|
|
@@ -5715,16 +5730,16 @@ var TextInputNumber = function (_a) {
|
|
|
5715
5730
|
}
|
|
5716
5731
|
};
|
|
5717
5732
|
var handleClear = function () {
|
|
5718
|
-
setInputValue(
|
|
5733
|
+
setInputValue("");
|
|
5719
5734
|
};
|
|
5720
5735
|
var handleClearInput = function () {
|
|
5721
|
-
setInputValue(
|
|
5722
|
-
setNumberValue(
|
|
5723
|
-
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(
|
|
5736
|
+
setInputValue("");
|
|
5737
|
+
setNumberValue("");
|
|
5738
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("");
|
|
5724
5739
|
};
|
|
5725
5740
|
var handleSave = function () {
|
|
5726
5741
|
var finalValue = inputValue;
|
|
5727
|
-
if (inputValue.endsWith(
|
|
5742
|
+
if (inputValue.endsWith(".")) {
|
|
5728
5743
|
finalValue = inputValue.slice(0, -1);
|
|
5729
5744
|
}
|
|
5730
5745
|
if (formatDecimal) {
|
|
@@ -5738,13 +5753,13 @@ var TextInputNumber = function (_a) {
|
|
|
5738
5753
|
setIsShowModalKeyboard(false);
|
|
5739
5754
|
};
|
|
5740
5755
|
var checkValueEmpty = function () {
|
|
5741
|
-
if (value === undefined || value === null || value.toString() ===
|
|
5756
|
+
if (value === undefined || value === null || value.toString() === "") {
|
|
5742
5757
|
return true;
|
|
5743
5758
|
}
|
|
5744
5759
|
return false;
|
|
5745
5760
|
};
|
|
5746
5761
|
var checkLabelEmpty = function () {
|
|
5747
|
-
if (label === undefined || label === null || label.toString() ===
|
|
5762
|
+
if (label === undefined || label === null || label.toString() === "") {
|
|
5748
5763
|
return true;
|
|
5749
5764
|
}
|
|
5750
5765
|
return false;
|
|
@@ -5755,7 +5770,7 @@ var TextInputNumber = function (_a) {
|
|
|
5755
5770
|
// Chỉ set isFirstInput = true khi inputValue rỗng hoặc chỉ có dấu trừ
|
|
5756
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
|
|
5757
5772
|
// Ví dụ: value=999, người dùng có thể nhập "000" để tạo "999000"
|
|
5758
|
-
if (inputValue ===
|
|
5773
|
+
if (inputValue === "" || inputValue === "-") {
|
|
5759
5774
|
setIsFirstInput(true);
|
|
5760
5775
|
}
|
|
5761
5776
|
else {
|
|
@@ -5766,7 +5781,7 @@ var TextInputNumber = function (_a) {
|
|
|
5766
5781
|
var onCloseModalKeyboard = function () {
|
|
5767
5782
|
setIsShowModalKeyboard(false);
|
|
5768
5783
|
setTimeout(function () {
|
|
5769
|
-
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
5784
|
+
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) || "");
|
|
5770
5785
|
}, 300);
|
|
5771
5786
|
};
|
|
5772
5787
|
return (React__default.createElement(View, null,
|
|
@@ -5788,7 +5803,7 @@ var TextInputNumber = function (_a) {
|
|
|
5788
5803
|
},
|
|
5789
5804
|
],
|
|
5790
5805
|
checkValueEmpty() && {
|
|
5791
|
-
alignItems:
|
|
5806
|
+
alignItems: "center",
|
|
5792
5807
|
},
|
|
5793
5808
|
textError.length > 0 && [
|
|
5794
5809
|
{
|
|
@@ -5806,7 +5821,7 @@ var TextInputNumber = function (_a) {
|
|
|
5806
5821
|
style,
|
|
5807
5822
|
] },
|
|
5808
5823
|
React__default.createElement(Spacer, { width: SPACE_12 }),
|
|
5809
|
-
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)),
|
|
5810
5825
|
React__default.createElement(View, { full: true, paddingRight: SPACE_4 },
|
|
5811
5826
|
!checkValueEmpty() && !checkLabelEmpty() && (React__default.createElement(View, null,
|
|
5812
5827
|
React__default.createElement(Text$1, { numberOfLines: 1, size: 14, color: colors.textSecondary, style: [
|
|
@@ -5820,10 +5835,10 @@ var TextInputNumber = function (_a) {
|
|
|
5820
5835
|
] },
|
|
5821
5836
|
label,
|
|
5822
5837
|
required && (React__default.createElement(Text$1, { style: [labelStyle], color: colors.textErrorDefault },
|
|
5823
|
-
|
|
5838
|
+
" ",
|
|
5824
5839
|
"*"))))),
|
|
5825
5840
|
React__default.createElement(View, { row: true, alignCenter: true },
|
|
5826
|
-
!checkValueEmpty() && prefix.toString() !==
|
|
5841
|
+
!checkValueEmpty() && prefix.toString() !== "" && (React__default.createElement(Text$1, { numberOfLines: 1, color: colors.textSecondary, style: [contentStyle, , disabled && disabledTextStyle] },
|
|
5827
5842
|
prefix, " ")),
|
|
5828
5843
|
React__default.createElement(View, { full: true },
|
|
5829
5844
|
React__default.createElement(Text$1, { numberOfLines: 1, color: getColorValue, style: [contentStyle, disabled && disabledTextStyle] },
|
|
@@ -5831,19 +5846,19 @@ var TextInputNumber = function (_a) {
|
|
|
5831
5846
|
? label
|
|
5832
5847
|
: formatNumberInput$1(numberValue, formatDecimal),
|
|
5833
5848
|
checkValueEmpty() && required && (React__default.createElement(Text$1, { style: [contentStyle], color: colors.textErrorDefault },
|
|
5834
|
-
|
|
5849
|
+
" ",
|
|
5835
5850
|
"*")))),
|
|
5836
|
-
!checkValueEmpty() && suffix.toString() !==
|
|
5851
|
+
!checkValueEmpty() && suffix.toString() !== "" && (React__default.createElement(Text$1, { numberOfLines: 1, color: colors.textSecondary, style: [contentStyle, disabled && disabledTextStyle] }, " ",
|
|
5837
5852
|
suffix)))),
|
|
5838
5853
|
clearButton && !checkValueEmpty() && (React__default.createElement(TouchableOpacity, { style: {
|
|
5839
|
-
alignContent:
|
|
5840
|
-
paddingTop: Platform.OS ===
|
|
5854
|
+
alignContent: "center",
|
|
5855
|
+
paddingTop: Platform.OS === "ios" ? 4 : 8,
|
|
5841
5856
|
}, activeOpacity: 0.8, onPress: handleClearInput },
|
|
5842
5857
|
React__default.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24 }))),
|
|
5843
5858
|
right && numberValue && (React__default.createElement(Spacer, { width: 1, height: 24, backgroundColor: theme.colors.borderPrimaryDefault, style: {
|
|
5844
5859
|
marginLeft: SPACE_4,
|
|
5845
5860
|
} })),
|
|
5846
|
-
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)),
|
|
5847
5862
|
React__default.createElement(Spacer, { width: SPACE_12 }))),
|
|
5848
5863
|
!disabled && textError.length > 0 && (React__default.createElement(View, { paddingHorizontal: SPACE_12, paddingVertical: SPACE_4 },
|
|
5849
5864
|
React__default.createElement(Text$1, { size: 14, numberOfLines: 1, color: theme.colors.textErrorDefault, style: [textErrorStyle] }, textError))),
|
|
@@ -5851,38 +5866,38 @@ var TextInputNumber = function (_a) {
|
|
|
5851
5866
|
React__default.createElement(TouchableOpacity, { style: styles$c.modalOverlay, activeOpacity: 1, onPress: onCloseModalKeyboard },
|
|
5852
5867
|
React__default.createElement(View, { onPress: function () { }, activeOpacity: 1, backgroundColor: colors.surfacePrimaryDefault, style: [styles$c.modalContent, keyboardStyle] },
|
|
5853
5868
|
React__default.createElement(Text$1, { style: [styles$c.modalTitle, styles$c.text18] }, label),
|
|
5854
|
-
React__default.createElement(View, { width:
|
|
5869
|
+
React__default.createElement(View, { width: "100%" },
|
|
5855
5870
|
React__default.createElement(View, { paddingHorizontal: SPACE_40 },
|
|
5856
|
-
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) || "")),
|
|
5857
5872
|
React__default.createElement(TouchableOpacity, { onPress: handleClear, style: styles$c.clearButton },
|
|
5858
5873
|
React__default.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24, color: colors.textSecondary }))),
|
|
5859
5874
|
React__default.createElement(View, { style: styles$c.keyboardGrid }, [
|
|
5860
|
-
[
|
|
5861
|
-
[
|
|
5862
|
-
[
|
|
5863
|
-
[type ===
|
|
5875
|
+
["1", "2", "3"],
|
|
5876
|
+
["4", "5", "6"],
|
|
5877
|
+
["7", "8", "9"],
|
|
5878
|
+
[type === "integer" ? "000" : ".", "0", "del"],
|
|
5864
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: [
|
|
5865
5880
|
styles$c.keyButton,
|
|
5866
|
-
key ===
|
|
5867
|
-
key ===
|
|
5868
|
-
inputValue.includes(
|
|
5881
|
+
key === "000" && is000Disabled && styles$c.disabledKey,
|
|
5882
|
+
key === "." &&
|
|
5883
|
+
inputValue.includes(".") &&
|
|
5869
5884
|
styles$c.disabledKey,
|
|
5870
|
-
], onPress: function () { return handleKeyPress(key); }, disabled: (key ===
|
|
5871
|
-
(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: [
|
|
5872
5887
|
styles$c.keyText,
|
|
5873
5888
|
styles$c.text22,
|
|
5874
|
-
key ===
|
|
5875
|
-
|
|
5889
|
+
key === "000" &&
|
|
5890
|
+
is000Disabled &&
|
|
5876
5891
|
styles$c.disabledKeyText,
|
|
5877
|
-
key ===
|
|
5878
|
-
inputValue.includes(
|
|
5892
|
+
key === "." &&
|
|
5893
|
+
inputValue.includes(".") &&
|
|
5879
5894
|
styles$c.disabledKeyText,
|
|
5880
5895
|
] }, key)))); }))); })),
|
|
5881
5896
|
React__default.createElement(View, { style: styles$c.actionRow },
|
|
5882
5897
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: styles$c.actionButton, onPress: onCloseModalKeyboard },
|
|
5883
5898
|
React__default.createElement(Text$1, { style: [styles$c.actionText, styles$c.text16] }, "\u0110\u00F3ng")),
|
|
5884
5899
|
React__default.createElement(Spacer, { style: {
|
|
5885
|
-
height:
|
|
5900
|
+
height: "100%",
|
|
5886
5901
|
}, width: 1, backgroundColor: colors.borderPrimaryDefault }),
|
|
5887
5902
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: [styles$c.actionButton, !canSave && { opacity: 0.5 }], onPress: handleSave, disabled: !canSave },
|
|
5888
5903
|
React__default.createElement(Text$1, { style: [
|
|
@@ -5894,9 +5909,9 @@ var TextInputNumber = function (_a) {
|
|
|
5894
5909
|
};
|
|
5895
5910
|
var styles$c = StyleSheet.create(__assign(__assign({}, containerStyles), { disabled: { opacity: 0.6 }, container: {
|
|
5896
5911
|
height: 48,
|
|
5897
|
-
flexDirection:
|
|
5898
|
-
justifyContent:
|
|
5899
|
-
alignItems:
|
|
5912
|
+
flexDirection: "row",
|
|
5913
|
+
justifyContent: "space-between",
|
|
5914
|
+
alignItems: "center",
|
|
5900
5915
|
// paddingVertical: Platform.OS === "android" ? 3 : SPACE_6
|
|
5901
5916
|
}, border: {
|
|
5902
5917
|
borderWidth: BORDER_WIDTH_1,
|
|
@@ -5904,54 +5919,54 @@ var styles$c = StyleSheet.create(__assign(__assign({}, containerStyles), { disab
|
|
|
5904
5919
|
height: BUTTON_HEIGHT_SMALL,
|
|
5905
5920
|
}, modalOverlay: {
|
|
5906
5921
|
flex: 1,
|
|
5907
|
-
backgroundColor:
|
|
5908
|
-
justifyContent:
|
|
5909
|
-
alignItems:
|
|
5922
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
5923
|
+
justifyContent: "center",
|
|
5924
|
+
alignItems: "center",
|
|
5910
5925
|
}, modalContent: {
|
|
5911
5926
|
borderRadius: 20,
|
|
5912
|
-
width:
|
|
5927
|
+
width: "90%",
|
|
5913
5928
|
paddingBottom: 20,
|
|
5914
|
-
alignItems:
|
|
5915
|
-
overflow:
|
|
5929
|
+
alignItems: "center",
|
|
5930
|
+
overflow: "hidden",
|
|
5916
5931
|
}, modalTitle: {
|
|
5917
|
-
textAlign:
|
|
5932
|
+
textAlign: "center",
|
|
5918
5933
|
marginTop: 16,
|
|
5919
5934
|
marginBottom: 8,
|
|
5920
5935
|
}, valueText: {
|
|
5921
|
-
textAlign:
|
|
5936
|
+
textAlign: "center",
|
|
5922
5937
|
}, clearButton: {
|
|
5923
5938
|
padding: 8,
|
|
5924
|
-
position:
|
|
5939
|
+
position: "absolute",
|
|
5925
5940
|
right: SPACE_12,
|
|
5926
5941
|
}, keyboardGrid: {
|
|
5927
5942
|
marginVertical: 8,
|
|
5928
|
-
width:
|
|
5943
|
+
width: "90%",
|
|
5929
5944
|
}, keyboardRow: {
|
|
5930
|
-
flexDirection:
|
|
5931
|
-
justifyContent:
|
|
5945
|
+
flexDirection: "row",
|
|
5946
|
+
justifyContent: "space-between",
|
|
5932
5947
|
marginBottom: 8,
|
|
5933
5948
|
}, keyButton: {
|
|
5934
5949
|
flex: 1,
|
|
5935
5950
|
marginHorizontal: 6,
|
|
5936
|
-
backgroundColor:
|
|
5951
|
+
backgroundColor: "#F5F5F5",
|
|
5937
5952
|
borderRadius: 8,
|
|
5938
|
-
alignItems:
|
|
5939
|
-
justifyContent:
|
|
5953
|
+
alignItems: "center",
|
|
5954
|
+
justifyContent: "center",
|
|
5940
5955
|
height: 48,
|
|
5941
5956
|
}, keyText: {
|
|
5942
|
-
fontWeight:
|
|
5957
|
+
fontWeight: "500",
|
|
5943
5958
|
}, actionRow: {
|
|
5944
|
-
flexDirection:
|
|
5945
|
-
justifyContent:
|
|
5959
|
+
flexDirection: "row",
|
|
5960
|
+
justifyContent: "space-between",
|
|
5946
5961
|
marginTop: 12,
|
|
5947
|
-
width:
|
|
5962
|
+
width: "90%",
|
|
5948
5963
|
paddingHorizontal: 16,
|
|
5949
5964
|
}, actionButton: {
|
|
5950
5965
|
flex: 1,
|
|
5951
|
-
alignItems:
|
|
5966
|
+
alignItems: "center",
|
|
5952
5967
|
paddingVertical: 12,
|
|
5953
5968
|
}, actionText: {
|
|
5954
|
-
fontWeight:
|
|
5969
|
+
fontWeight: "600",
|
|
5955
5970
|
}, disabledKey: {
|
|
5956
5971
|
opacity: 0.5,
|
|
5957
5972
|
}, disabledKeyText: {
|