sapo-components-ui-rn 1.1.93 → 1.1.95
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 +141 -109
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +141 -109
- 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,40 @@ 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]);
|
|
5491
|
+
// Float: cho phép nhập "0" khi value rỗng, nhưng không cho "00" liên tiếp ở phần nguyên.
|
|
5492
|
+
var is0Disabled = useMemo(function () {
|
|
5493
|
+
if (type !== "float") {
|
|
5494
|
+
return false;
|
|
5495
|
+
}
|
|
5496
|
+
return inputValue === "0" || inputValue === "-0";
|
|
5497
|
+
}, [type, inputValue]);
|
|
5479
5498
|
var handleKeyPress = function (key) {
|
|
5480
|
-
if (key ===
|
|
5499
|
+
if (key === "del") {
|
|
5481
5500
|
setInputValue(function (prev) { return prev.slice(0, -1); });
|
|
5482
5501
|
}
|
|
5483
|
-
else if (key ===
|
|
5484
|
-
if (type ===
|
|
5502
|
+
else if (key === "000") {
|
|
5503
|
+
if (type === "integer") {
|
|
5504
|
+
if (is000Disabled) {
|
|
5505
|
+
return;
|
|
5506
|
+
}
|
|
5485
5507
|
// Xử lý trường hợp nhập "000" để tạo số lớn hơn
|
|
5486
5508
|
// Ví dụ: "1" + "000" = "1000", "10" + "000" = "10000"
|
|
5487
5509
|
// Nếu vượt quá maxValue, sẽ tự động cắt bớt số 0
|
|
5488
5510
|
// 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
5511
|
// Ví dụ: value=999, người dùng có thể nhập "000" để tạo "999000"
|
|
5490
|
-
var newInputValue = inputValue +
|
|
5512
|
+
var newInputValue = inputValue + "000";
|
|
5491
5513
|
var newValue = Number(newInputValue);
|
|
5492
5514
|
var maxValueNumber = Number(maxValue);
|
|
5493
5515
|
// Kiểm tra nếu giá trị vượt quá maxValue, cắt bớt số 0
|
|
@@ -5496,18 +5518,18 @@ var TextInputNumber = function (_a) {
|
|
|
5496
5518
|
newValue > maxValueNumber) {
|
|
5497
5519
|
// Tìm số 0 tối đa có thể thêm vào mà không vượt quá maxValue
|
|
5498
5520
|
var tempValue = inputValue;
|
|
5499
|
-
var tempNewValue = Number(tempValue +
|
|
5521
|
+
var tempNewValue = Number(tempValue + "000");
|
|
5500
5522
|
// Giảm dần số 0 cho đến khi không vượt quá maxValue
|
|
5501
|
-
while (tempNewValue > maxValueNumber && tempValue.endsWith(
|
|
5523
|
+
while (tempNewValue > maxValueNumber && tempValue.endsWith("0")) {
|
|
5502
5524
|
tempValue = tempValue.slice(0, -1);
|
|
5503
|
-
tempNewValue = Number(tempValue +
|
|
5525
|
+
tempNewValue = Number(tempValue + "000");
|
|
5504
5526
|
}
|
|
5505
5527
|
// Nếu vẫn vượt quá, chỉ thêm số 0 có thể
|
|
5506
5528
|
if (tempNewValue > maxValueNumber) {
|
|
5507
5529
|
// Tìm số 0 tối đa có thể thêm
|
|
5508
5530
|
var maxZeros = 0;
|
|
5509
5531
|
for (var i = 1; i <= 3; i++) {
|
|
5510
|
-
var testValue = Number(inputValue +
|
|
5532
|
+
var testValue = Number(inputValue + "0".repeat(i));
|
|
5511
5533
|
if (testValue <= maxValueNumber) {
|
|
5512
5534
|
maxZeros = i;
|
|
5513
5535
|
}
|
|
@@ -5516,7 +5538,7 @@ var TextInputNumber = function (_a) {
|
|
|
5516
5538
|
}
|
|
5517
5539
|
}
|
|
5518
5540
|
if (maxZeros > 0) {
|
|
5519
|
-
newInputValue = inputValue +
|
|
5541
|
+
newInputValue = inputValue + "0".repeat(maxZeros);
|
|
5520
5542
|
newValue = Number(newInputValue);
|
|
5521
5543
|
}
|
|
5522
5544
|
else {
|
|
@@ -5525,7 +5547,7 @@ var TextInputNumber = function (_a) {
|
|
|
5525
5547
|
}
|
|
5526
5548
|
}
|
|
5527
5549
|
else {
|
|
5528
|
-
newInputValue = tempValue +
|
|
5550
|
+
newInputValue = tempValue + "000";
|
|
5529
5551
|
newValue = Number(newInputValue);
|
|
5530
5552
|
}
|
|
5531
5553
|
}
|
|
@@ -5539,15 +5561,15 @@ var TextInputNumber = function (_a) {
|
|
|
5539
5561
|
}
|
|
5540
5562
|
// Nếu type là float, không cho phép nhập "000" ở đầu
|
|
5541
5563
|
}
|
|
5542
|
-
else if (key ===
|
|
5543
|
-
if (!inputValue.includes(
|
|
5564
|
+
else if (key === ".") {
|
|
5565
|
+
if (!inputValue.includes(".")) {
|
|
5544
5566
|
// Nếu inputValue là "0" hoặc rỗng, giữ lại số 0 và thêm dấu "."
|
|
5545
|
-
if (inputValue ===
|
|
5546
|
-
setInputValue(
|
|
5567
|
+
if (inputValue === "0" || inputValue === "") {
|
|
5568
|
+
setInputValue("0.");
|
|
5547
5569
|
}
|
|
5548
|
-
else if (inputValue ===
|
|
5549
|
-
// Nếu chỉ có dấu
|
|
5550
|
-
setInputValue(
|
|
5570
|
+
else if (inputValue === "-" || inputValue === "-0") {
|
|
5571
|
+
// Nếu chỉ có dấu trừ hoặc -0, thêm "0."
|
|
5572
|
+
setInputValue("-0.");
|
|
5551
5573
|
}
|
|
5552
5574
|
else {
|
|
5553
5575
|
// Nếu đã có giá trị, thêm dấu "." vào cuối
|
|
@@ -5557,9 +5579,13 @@ var TextInputNumber = function (_a) {
|
|
|
5557
5579
|
}
|
|
5558
5580
|
}
|
|
5559
5581
|
else {
|
|
5582
|
+
// Float: chặn nhập "00" liên tiếp ở phần nguyên
|
|
5583
|
+
if (key === "0" && is0Disabled) {
|
|
5584
|
+
return;
|
|
5585
|
+
}
|
|
5560
5586
|
if (isFirstInput) {
|
|
5561
|
-
//
|
|
5562
|
-
if (type ===
|
|
5587
|
+
// Float vẫn không dùng phím "000"
|
|
5588
|
+
if (type === "float" && key === "000") {
|
|
5563
5589
|
return;
|
|
5564
5590
|
}
|
|
5565
5591
|
// Kiểm tra xem có thể nhập được không khi là lần đầu
|
|
@@ -5579,7 +5605,7 @@ var TextInputNumber = function (_a) {
|
|
|
5579
5605
|
}
|
|
5580
5606
|
if (canInput) {
|
|
5581
5607
|
// Nếu inputValue rỗng hoặc chỉ có dấu trừ, thay thế hoàn toàn
|
|
5582
|
-
if (inputValue ===
|
|
5608
|
+
if (inputValue === "" || inputValue === "-") {
|
|
5583
5609
|
setInputValue(key);
|
|
5584
5610
|
}
|
|
5585
5611
|
else {
|
|
@@ -5595,7 +5621,7 @@ var TextInputNumber = function (_a) {
|
|
|
5595
5621
|
}
|
|
5596
5622
|
else {
|
|
5597
5623
|
// Nếu inputValue rỗng hoặc chỉ có dấu trừ, thay thế hoàn toàn
|
|
5598
|
-
if (inputValue ===
|
|
5624
|
+
if (inputValue === "" || inputValue === "-") {
|
|
5599
5625
|
setInputValue(key);
|
|
5600
5626
|
}
|
|
5601
5627
|
else {
|
|
@@ -5607,13 +5633,14 @@ var TextInputNumber = function (_a) {
|
|
|
5607
5633
|
}
|
|
5608
5634
|
else {
|
|
5609
5635
|
// Kiểm tra nếu input bắt đầu bằng 0 và không có dấu chấm
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5636
|
+
// (float: cho phép một số 0, không cho "00" liên tiếp)
|
|
5637
|
+
if (inputValue === "0" || inputValue === "-0") {
|
|
5638
|
+
if (key === ".") {
|
|
5639
|
+
setInputValue(inputValue === "-0" ? "-0." : "0.");
|
|
5613
5640
|
return;
|
|
5614
5641
|
}
|
|
5615
|
-
else if (key >=
|
|
5616
|
-
setInputValue(key);
|
|
5642
|
+
else if (key >= "1" && key <= "9") {
|
|
5643
|
+
setInputValue(inputValue.startsWith("-") ? "-".concat(key) : key);
|
|
5617
5644
|
return;
|
|
5618
5645
|
}
|
|
5619
5646
|
else {
|
|
@@ -5640,7 +5667,7 @@ var TextInputNumber = function (_a) {
|
|
|
5640
5667
|
// nguyên nên phải so độ dài với PHẦN NGUYÊN của maxValue.
|
|
5641
5668
|
// Nếu so với cả chuỗi (vd "999999.999" dài 10 ký tự) thì mốc
|
|
5642
5669
|
// 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(
|
|
5670
|
+
var maxValueStr = newInputValue.includes(".")
|
|
5644
5671
|
? absMaxValue.toString()
|
|
5645
5672
|
: Math.trunc(absMaxValue).toString();
|
|
5646
5673
|
inputValue.length;
|
|
@@ -5668,7 +5695,7 @@ var TextInputNumber = function (_a) {
|
|
|
5668
5695
|
// Nếu vượt quá maxValue, kiểm tra xem có thể nhập được không
|
|
5669
5696
|
// Xem giải thích ở nhánh số âm phía trên. Dùng Math.abs trước
|
|
5670
5697
|
// khi trunc để đối xứng với nhánh đó.
|
|
5671
|
-
var maxValueStr = newInputValue.includes(
|
|
5698
|
+
var maxValueStr = newInputValue.includes(".")
|
|
5672
5699
|
? maxValueNumber.toString()
|
|
5673
5700
|
: Math.trunc(Math.abs(maxValueNumber)).toString();
|
|
5674
5701
|
inputValue.length;
|
|
@@ -5690,9 +5717,9 @@ var TextInputNumber = function (_a) {
|
|
|
5690
5717
|
}
|
|
5691
5718
|
}
|
|
5692
5719
|
if (canInput) {
|
|
5693
|
-
if (inputValue.includes(
|
|
5720
|
+
if (inputValue.includes(".")) {
|
|
5694
5721
|
// Xử lý số thập phân
|
|
5695
|
-
var _a = inputValue.split(
|
|
5722
|
+
var _a = inputValue.split("."); _a[0]; var _b = _a[1], decimalPart = _b === void 0 ? "" : _b;
|
|
5696
5723
|
if (newInputValue.length <= 12 && decimalPart.length === 0) {
|
|
5697
5724
|
setInputValue(function (prev) { return prev + key; });
|
|
5698
5725
|
}
|
|
@@ -5715,16 +5742,16 @@ var TextInputNumber = function (_a) {
|
|
|
5715
5742
|
}
|
|
5716
5743
|
};
|
|
5717
5744
|
var handleClear = function () {
|
|
5718
|
-
setInputValue(
|
|
5745
|
+
setInputValue("");
|
|
5719
5746
|
};
|
|
5720
5747
|
var handleClearInput = function () {
|
|
5721
|
-
setInputValue(
|
|
5722
|
-
setNumberValue(
|
|
5723
|
-
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(
|
|
5748
|
+
setInputValue("");
|
|
5749
|
+
setNumberValue("");
|
|
5750
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText("");
|
|
5724
5751
|
};
|
|
5725
5752
|
var handleSave = function () {
|
|
5726
5753
|
var finalValue = inputValue;
|
|
5727
|
-
if (inputValue.endsWith(
|
|
5754
|
+
if (inputValue.endsWith(".")) {
|
|
5728
5755
|
finalValue = inputValue.slice(0, -1);
|
|
5729
5756
|
}
|
|
5730
5757
|
if (formatDecimal) {
|
|
@@ -5738,13 +5765,13 @@ var TextInputNumber = function (_a) {
|
|
|
5738
5765
|
setIsShowModalKeyboard(false);
|
|
5739
5766
|
};
|
|
5740
5767
|
var checkValueEmpty = function () {
|
|
5741
|
-
if (value === undefined || value === null || value.toString() ===
|
|
5768
|
+
if (value === undefined || value === null || value.toString() === "") {
|
|
5742
5769
|
return true;
|
|
5743
5770
|
}
|
|
5744
5771
|
return false;
|
|
5745
5772
|
};
|
|
5746
5773
|
var checkLabelEmpty = function () {
|
|
5747
|
-
if (label === undefined || label === null || label.toString() ===
|
|
5774
|
+
if (label === undefined || label === null || label.toString() === "") {
|
|
5748
5775
|
return true;
|
|
5749
5776
|
}
|
|
5750
5777
|
return false;
|
|
@@ -5755,7 +5782,7 @@ var TextInputNumber = function (_a) {
|
|
|
5755
5782
|
// Chỉ set isFirstInput = true khi inputValue rỗng hoặc chỉ có dấu trừ
|
|
5756
5783
|
// Đ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
5784
|
// Ví dụ: value=999, người dùng có thể nhập "000" để tạo "999000"
|
|
5758
|
-
if (inputValue ===
|
|
5785
|
+
if (inputValue === "" || inputValue === "-") {
|
|
5759
5786
|
setIsFirstInput(true);
|
|
5760
5787
|
}
|
|
5761
5788
|
else {
|
|
@@ -5766,7 +5793,7 @@ var TextInputNumber = function (_a) {
|
|
|
5766
5793
|
var onCloseModalKeyboard = function () {
|
|
5767
5794
|
setIsShowModalKeyboard(false);
|
|
5768
5795
|
setTimeout(function () {
|
|
5769
|
-
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) ||
|
|
5796
|
+
setInputValue((value === null || value === void 0 ? void 0 : value.toString()) || "");
|
|
5770
5797
|
}, 300);
|
|
5771
5798
|
};
|
|
5772
5799
|
return (React__default.createElement(View, null,
|
|
@@ -5788,7 +5815,7 @@ var TextInputNumber = function (_a) {
|
|
|
5788
5815
|
},
|
|
5789
5816
|
],
|
|
5790
5817
|
checkValueEmpty() && {
|
|
5791
|
-
alignItems:
|
|
5818
|
+
alignItems: "center",
|
|
5792
5819
|
},
|
|
5793
5820
|
textError.length > 0 && [
|
|
5794
5821
|
{
|
|
@@ -5806,7 +5833,7 @@ var TextInputNumber = function (_a) {
|
|
|
5806
5833
|
style,
|
|
5807
5834
|
] },
|
|
5808
5835
|
React__default.createElement(Spacer, { width: SPACE_12 }),
|
|
5809
|
-
left && (React__default.createElement(View, { center: true, paddingRight: SPACE_8, height:
|
|
5836
|
+
left && (React__default.createElement(View, { center: true, paddingRight: SPACE_8, height: "100%" }, left)),
|
|
5810
5837
|
React__default.createElement(View, { full: true, paddingRight: SPACE_4 },
|
|
5811
5838
|
!checkValueEmpty() && !checkLabelEmpty() && (React__default.createElement(View, null,
|
|
5812
5839
|
React__default.createElement(Text$1, { numberOfLines: 1, size: 14, color: colors.textSecondary, style: [
|
|
@@ -5820,10 +5847,10 @@ var TextInputNumber = function (_a) {
|
|
|
5820
5847
|
] },
|
|
5821
5848
|
label,
|
|
5822
5849
|
required && (React__default.createElement(Text$1, { style: [labelStyle], color: colors.textErrorDefault },
|
|
5823
|
-
|
|
5850
|
+
" ",
|
|
5824
5851
|
"*"))))),
|
|
5825
5852
|
React__default.createElement(View, { row: true, alignCenter: true },
|
|
5826
|
-
!checkValueEmpty() && prefix.toString() !==
|
|
5853
|
+
!checkValueEmpty() && prefix.toString() !== "" && (React__default.createElement(Text$1, { numberOfLines: 1, color: colors.textSecondary, style: [contentStyle, , disabled && disabledTextStyle] },
|
|
5827
5854
|
prefix, " ")),
|
|
5828
5855
|
React__default.createElement(View, { full: true },
|
|
5829
5856
|
React__default.createElement(Text$1, { numberOfLines: 1, color: getColorValue, style: [contentStyle, disabled && disabledTextStyle] },
|
|
@@ -5831,19 +5858,19 @@ var TextInputNumber = function (_a) {
|
|
|
5831
5858
|
? label
|
|
5832
5859
|
: formatNumberInput$1(numberValue, formatDecimal),
|
|
5833
5860
|
checkValueEmpty() && required && (React__default.createElement(Text$1, { style: [contentStyle], color: colors.textErrorDefault },
|
|
5834
|
-
|
|
5861
|
+
" ",
|
|
5835
5862
|
"*")))),
|
|
5836
|
-
!checkValueEmpty() && suffix.toString() !==
|
|
5863
|
+
!checkValueEmpty() && suffix.toString() !== "" && (React__default.createElement(Text$1, { numberOfLines: 1, color: colors.textSecondary, style: [contentStyle, disabled && disabledTextStyle] }, " ",
|
|
5837
5864
|
suffix)))),
|
|
5838
5865
|
clearButton && !checkValueEmpty() && (React__default.createElement(TouchableOpacity, { style: {
|
|
5839
|
-
alignContent:
|
|
5840
|
-
paddingTop: Platform.OS ===
|
|
5866
|
+
alignContent: "center",
|
|
5867
|
+
paddingTop: Platform.OS === "ios" ? 4 : 8,
|
|
5841
5868
|
}, activeOpacity: 0.8, onPress: handleClearInput },
|
|
5842
5869
|
React__default.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24 }))),
|
|
5843
5870
|
right && numberValue && (React__default.createElement(Spacer, { width: 1, height: 24, backgroundColor: theme.colors.borderPrimaryDefault, style: {
|
|
5844
5871
|
marginLeft: SPACE_4,
|
|
5845
5872
|
} })),
|
|
5846
|
-
right && (React__default.createElement(View, { center: true, paddingLeft: SPACE_8, height:
|
|
5873
|
+
right && (React__default.createElement(View, { center: true, paddingLeft: SPACE_8, height: "100%" }, right)),
|
|
5847
5874
|
React__default.createElement(Spacer, { width: SPACE_12 }))),
|
|
5848
5875
|
!disabled && textError.length > 0 && (React__default.createElement(View, { paddingHorizontal: SPACE_12, paddingVertical: SPACE_4 },
|
|
5849
5876
|
React__default.createElement(Text$1, { size: 14, numberOfLines: 1, color: theme.colors.textErrorDefault, style: [textErrorStyle] }, textError))),
|
|
@@ -5851,38 +5878,43 @@ var TextInputNumber = function (_a) {
|
|
|
5851
5878
|
React__default.createElement(TouchableOpacity, { style: styles$c.modalOverlay, activeOpacity: 1, onPress: onCloseModalKeyboard },
|
|
5852
5879
|
React__default.createElement(View, { onPress: function () { }, activeOpacity: 1, backgroundColor: colors.surfacePrimaryDefault, style: [styles$c.modalContent, keyboardStyle] },
|
|
5853
5880
|
React__default.createElement(Text$1, { style: [styles$c.modalTitle, styles$c.text18] }, label),
|
|
5854
|
-
React__default.createElement(View, { width:
|
|
5881
|
+
React__default.createElement(View, { width: "100%" },
|
|
5855
5882
|
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) ||
|
|
5883
|
+
React__default.createElement(Text$1, { numberOfLines: 1, style: [styles$c.text30, styles$c.valueText] }, formatNumberInput$1(inputValue, formatDecimal) || "")),
|
|
5857
5884
|
React__default.createElement(TouchableOpacity, { onPress: handleClear, style: styles$c.clearButton },
|
|
5858
5885
|
React__default.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24, color: colors.textSecondary }))),
|
|
5859
5886
|
React__default.createElement(View, { style: styles$c.keyboardGrid }, [
|
|
5860
|
-
[
|
|
5861
|
-
[
|
|
5862
|
-
[
|
|
5863
|
-
[type ===
|
|
5887
|
+
["1", "2", "3"],
|
|
5888
|
+
["4", "5", "6"],
|
|
5889
|
+
["7", "8", "9"],
|
|
5890
|
+
[type === "integer" ? "000" : ".", "0", "del"],
|
|
5864
5891
|
].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
5892
|
styles$c.keyButton,
|
|
5866
|
-
key ===
|
|
5867
|
-
key ===
|
|
5868
|
-
|
|
5893
|
+
key === "000" && is000Disabled && styles$c.disabledKey,
|
|
5894
|
+
key === "0" && is0Disabled && styles$c.disabledKey,
|
|
5895
|
+
key === "." &&
|
|
5896
|
+
inputValue.includes(".") &&
|
|
5869
5897
|
styles$c.disabledKey,
|
|
5870
|
-
], onPress: function () { return handleKeyPress(key); }, disabled: (key ===
|
|
5871
|
-
(key ===
|
|
5898
|
+
], onPress: function () { return handleKeyPress(key); }, disabled: (key === "000" && is000Disabled) ||
|
|
5899
|
+
(key === "0" && is0Disabled) ||
|
|
5900
|
+
(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
5901
|
styles$c.keyText,
|
|
5873
5902
|
styles$c.text22,
|
|
5874
|
-
key ===
|
|
5875
|
-
|
|
5903
|
+
key === "000" &&
|
|
5904
|
+
is000Disabled &&
|
|
5905
|
+
styles$c.disabledKeyText,
|
|
5906
|
+
key === "0" &&
|
|
5907
|
+
is0Disabled &&
|
|
5876
5908
|
styles$c.disabledKeyText,
|
|
5877
|
-
key ===
|
|
5878
|
-
inputValue.includes(
|
|
5909
|
+
key === "." &&
|
|
5910
|
+
inputValue.includes(".") &&
|
|
5879
5911
|
styles$c.disabledKeyText,
|
|
5880
5912
|
] }, key)))); }))); })),
|
|
5881
5913
|
React__default.createElement(View, { style: styles$c.actionRow },
|
|
5882
5914
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: styles$c.actionButton, onPress: onCloseModalKeyboard },
|
|
5883
5915
|
React__default.createElement(Text$1, { style: [styles$c.actionText, styles$c.text16] }, "\u0110\u00F3ng")),
|
|
5884
5916
|
React__default.createElement(Spacer, { style: {
|
|
5885
|
-
height:
|
|
5917
|
+
height: "100%",
|
|
5886
5918
|
}, width: 1, backgroundColor: colors.borderPrimaryDefault }),
|
|
5887
5919
|
React__default.createElement(TouchableOpacity, { activeOpacity: 0.8, style: [styles$c.actionButton, !canSave && { opacity: 0.5 }], onPress: handleSave, disabled: !canSave },
|
|
5888
5920
|
React__default.createElement(Text$1, { style: [
|
|
@@ -5894,9 +5926,9 @@ var TextInputNumber = function (_a) {
|
|
|
5894
5926
|
};
|
|
5895
5927
|
var styles$c = StyleSheet.create(__assign(__assign({}, containerStyles), { disabled: { opacity: 0.6 }, container: {
|
|
5896
5928
|
height: 48,
|
|
5897
|
-
flexDirection:
|
|
5898
|
-
justifyContent:
|
|
5899
|
-
alignItems:
|
|
5929
|
+
flexDirection: "row",
|
|
5930
|
+
justifyContent: "space-between",
|
|
5931
|
+
alignItems: "center",
|
|
5900
5932
|
// paddingVertical: Platform.OS === "android" ? 3 : SPACE_6
|
|
5901
5933
|
}, border: {
|
|
5902
5934
|
borderWidth: BORDER_WIDTH_1,
|
|
@@ -5904,54 +5936,54 @@ var styles$c = StyleSheet.create(__assign(__assign({}, containerStyles), { disab
|
|
|
5904
5936
|
height: BUTTON_HEIGHT_SMALL,
|
|
5905
5937
|
}, modalOverlay: {
|
|
5906
5938
|
flex: 1,
|
|
5907
|
-
backgroundColor:
|
|
5908
|
-
justifyContent:
|
|
5909
|
-
alignItems:
|
|
5939
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
5940
|
+
justifyContent: "center",
|
|
5941
|
+
alignItems: "center",
|
|
5910
5942
|
}, modalContent: {
|
|
5911
5943
|
borderRadius: 20,
|
|
5912
|
-
width:
|
|
5944
|
+
width: "90%",
|
|
5913
5945
|
paddingBottom: 20,
|
|
5914
|
-
alignItems:
|
|
5915
|
-
overflow:
|
|
5946
|
+
alignItems: "center",
|
|
5947
|
+
overflow: "hidden",
|
|
5916
5948
|
}, modalTitle: {
|
|
5917
|
-
textAlign:
|
|
5949
|
+
textAlign: "center",
|
|
5918
5950
|
marginTop: 16,
|
|
5919
5951
|
marginBottom: 8,
|
|
5920
5952
|
}, valueText: {
|
|
5921
|
-
textAlign:
|
|
5953
|
+
textAlign: "center",
|
|
5922
5954
|
}, clearButton: {
|
|
5923
5955
|
padding: 8,
|
|
5924
|
-
position:
|
|
5956
|
+
position: "absolute",
|
|
5925
5957
|
right: SPACE_12,
|
|
5926
5958
|
}, keyboardGrid: {
|
|
5927
5959
|
marginVertical: 8,
|
|
5928
|
-
width:
|
|
5960
|
+
width: "90%",
|
|
5929
5961
|
}, keyboardRow: {
|
|
5930
|
-
flexDirection:
|
|
5931
|
-
justifyContent:
|
|
5962
|
+
flexDirection: "row",
|
|
5963
|
+
justifyContent: "space-between",
|
|
5932
5964
|
marginBottom: 8,
|
|
5933
5965
|
}, keyButton: {
|
|
5934
5966
|
flex: 1,
|
|
5935
5967
|
marginHorizontal: 6,
|
|
5936
|
-
backgroundColor:
|
|
5968
|
+
backgroundColor: "#F5F5F5",
|
|
5937
5969
|
borderRadius: 8,
|
|
5938
|
-
alignItems:
|
|
5939
|
-
justifyContent:
|
|
5970
|
+
alignItems: "center",
|
|
5971
|
+
justifyContent: "center",
|
|
5940
5972
|
height: 48,
|
|
5941
5973
|
}, keyText: {
|
|
5942
|
-
fontWeight:
|
|
5974
|
+
fontWeight: "500",
|
|
5943
5975
|
}, actionRow: {
|
|
5944
|
-
flexDirection:
|
|
5945
|
-
justifyContent:
|
|
5976
|
+
flexDirection: "row",
|
|
5977
|
+
justifyContent: "space-between",
|
|
5946
5978
|
marginTop: 12,
|
|
5947
|
-
width:
|
|
5979
|
+
width: "90%",
|
|
5948
5980
|
paddingHorizontal: 16,
|
|
5949
5981
|
}, actionButton: {
|
|
5950
5982
|
flex: 1,
|
|
5951
|
-
alignItems:
|
|
5983
|
+
alignItems: "center",
|
|
5952
5984
|
paddingVertical: 12,
|
|
5953
5985
|
}, actionText: {
|
|
5954
|
-
fontWeight:
|
|
5986
|
+
fontWeight: "600",
|
|
5955
5987
|
}, disabledKey: {
|
|
5956
5988
|
opacity: 0.5,
|
|
5957
5989
|
}, disabledKeyText: {
|