sapo-components-ui-rn 1.1.94 → 1.1.96
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 +53 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +53 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -5488,6 +5488,13 @@ var TextInputNumber = function (_a) {
|
|
|
5488
5488
|
var numericValue = Number(inputValue);
|
|
5489
5489
|
return isNaN(numericValue) || numericValue === 0;
|
|
5490
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]);
|
|
5491
5498
|
var handleKeyPress = function (key) {
|
|
5492
5499
|
if (key === "del") {
|
|
5493
5500
|
setInputValue(function (prev) { return prev.slice(0, -1); });
|
|
@@ -5560,8 +5567,8 @@ var TextInputNumber = function (_a) {
|
|
|
5560
5567
|
if (inputValue === "0" || inputValue === "") {
|
|
5561
5568
|
setInputValue("0.");
|
|
5562
5569
|
}
|
|
5563
|
-
else if (inputValue === "-") {
|
|
5564
|
-
// Nếu chỉ có dấu
|
|
5570
|
+
else if (inputValue === "-" || inputValue === "-0") {
|
|
5571
|
+
// Nếu chỉ có dấu trừ hoặc -0, thêm "0."
|
|
5565
5572
|
setInputValue("-0.");
|
|
5566
5573
|
}
|
|
5567
5574
|
else {
|
|
@@ -5572,9 +5579,13 @@ var TextInputNumber = function (_a) {
|
|
|
5572
5579
|
}
|
|
5573
5580
|
}
|
|
5574
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
|
+
}
|
|
5575
5586
|
if (isFirstInput) {
|
|
5576
|
-
//
|
|
5577
|
-
if (type === "float" &&
|
|
5587
|
+
// Float vẫn không dùng phím "000"
|
|
5588
|
+
if (type === "float" && key === "000") {
|
|
5578
5589
|
return;
|
|
5579
5590
|
}
|
|
5580
5591
|
// Kiểm tra xem có thể nhập được không khi là lần đầu
|
|
@@ -5622,13 +5633,14 @@ var TextInputNumber = function (_a) {
|
|
|
5622
5633
|
}
|
|
5623
5634
|
else {
|
|
5624
5635
|
// Kiểm tra nếu input bắt đầu bằng 0 và không có dấu chấm
|
|
5625
|
-
|
|
5636
|
+
// (float: cho phép một số 0, không cho "00" liên tiếp)
|
|
5637
|
+
if (inputValue === "0" || inputValue === "-0") {
|
|
5626
5638
|
if (key === ".") {
|
|
5627
|
-
setInputValue("0.");
|
|
5639
|
+
setInputValue(inputValue === "-0" ? "-0." : "0.");
|
|
5628
5640
|
return;
|
|
5629
5641
|
}
|
|
5630
5642
|
else if (key >= "1" && key <= "9") {
|
|
5631
|
-
setInputValue(key);
|
|
5643
|
+
setInputValue(inputValue.startsWith("-") ? "-".concat(key) : key);
|
|
5632
5644
|
return;
|
|
5633
5645
|
}
|
|
5634
5646
|
else {
|
|
@@ -5862,13 +5874,14 @@ var TextInputNumber = function (_a) {
|
|
|
5862
5874
|
React__default.createElement(Spacer, { width: SPACE_12 }))),
|
|
5863
5875
|
!disabled && textError.length > 0 && (React__default.createElement(View, { paddingHorizontal: SPACE_12, paddingVertical: SPACE_4 },
|
|
5864
5876
|
React__default.createElement(Text$1, { size: 14, numberOfLines: 1, color: theme.colors.textErrorDefault, style: [textErrorStyle] }, textError))),
|
|
5865
|
-
React__default.createElement(Modal, { visible: isShowModalKeyboard, transparent: true, animationType: "fade", onRequestClose: onCloseModalKeyboard },
|
|
5866
|
-
React__default.createElement(
|
|
5867
|
-
React__default.createElement(
|
|
5877
|
+
React__default.createElement(Modal, { visible: isShowModalKeyboard, transparent: true, animationType: "fade", statusBarTranslucent: true, onRequestClose: onCloseModalKeyboard },
|
|
5878
|
+
React__default.createElement(View, { style: styles$c.modalOverlay },
|
|
5879
|
+
React__default.createElement(TouchableOpacity, { style: styles$c.modalBackdrop, activeOpacity: 1, onPress: onCloseModalKeyboard }),
|
|
5880
|
+
React__default.createElement(View, { backgroundColor: colors.surfacePrimaryDefault, style: [styles$c.modalContent, keyboardStyle] },
|
|
5868
5881
|
React__default.createElement(Text$1, { style: [styles$c.modalTitle, styles$c.text18] }, label),
|
|
5869
|
-
React__default.createElement(View, { width: "100%" },
|
|
5870
|
-
React__default.createElement(View, {
|
|
5871
|
-
React__default.createElement(Text$1, { numberOfLines: 1, style: [styles$c.text30, styles$c.valueText] }, formatNumberInput$1(inputValue, formatDecimal) || "")),
|
|
5882
|
+
React__default.createElement(View, { width: "100%", style: styles$c.valueRow },
|
|
5883
|
+
React__default.createElement(View, { style: styles$c.valueTextContainer },
|
|
5884
|
+
React__default.createElement(Text$1, { numberOfLines: 1, style: [styles$c.text30, styles$c.valueText] }, formatNumberInput$1(inputValue, formatDecimal) || "\u00A0")),
|
|
5872
5885
|
React__default.createElement(TouchableOpacity, { onPress: handleClear, style: styles$c.clearButton },
|
|
5873
5886
|
React__default.createElement(SvgIcon, { name: "IconClearText", width: 24, height: 24, color: colors.textSecondary }))),
|
|
5874
5887
|
React__default.createElement(View, { style: styles$c.keyboardGrid }, [
|
|
@@ -5879,16 +5892,21 @@ var TextInputNumber = function (_a) {
|
|
|
5879
5892
|
].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: [
|
|
5880
5893
|
styles$c.keyButton,
|
|
5881
5894
|
key === "000" && is000Disabled && styles$c.disabledKey,
|
|
5895
|
+
key === "0" && is0Disabled && styles$c.disabledKey,
|
|
5882
5896
|
key === "." &&
|
|
5883
5897
|
inputValue.includes(".") &&
|
|
5884
5898
|
styles$c.disabledKey,
|
|
5885
5899
|
], onPress: function () { return handleKeyPress(key); }, disabled: (key === "000" && is000Disabled) ||
|
|
5900
|
+
(key === "0" && is0Disabled) ||
|
|
5886
5901
|
(key === "." && inputValue.includes(".")) }, key === "del" ? (React__default.createElement(SvgIcon, { name: "IconDelNumber", width: 24, height: 24, color: colors.textSecondary })) : (React__default.createElement(Text$1, { style: [
|
|
5887
5902
|
styles$c.keyText,
|
|
5888
5903
|
styles$c.text22,
|
|
5889
5904
|
key === "000" &&
|
|
5890
5905
|
is000Disabled &&
|
|
5891
5906
|
styles$c.disabledKeyText,
|
|
5907
|
+
key === "0" &&
|
|
5908
|
+
is0Disabled &&
|
|
5909
|
+
styles$c.disabledKeyText,
|
|
5892
5910
|
key === "." &&
|
|
5893
5911
|
inputValue.includes(".") &&
|
|
5894
5912
|
styles$c.disabledKeyText,
|
|
@@ -5919,25 +5937,42 @@ var styles$c = StyleSheet.create(__assign(__assign({}, containerStyles), { disab
|
|
|
5919
5937
|
height: BUTTON_HEIGHT_SMALL,
|
|
5920
5938
|
}, modalOverlay: {
|
|
5921
5939
|
flex: 1,
|
|
5922
|
-
|
|
5940
|
+
width: "100%",
|
|
5941
|
+
height: "100%",
|
|
5923
5942
|
justifyContent: "center",
|
|
5924
5943
|
alignItems: "center",
|
|
5925
|
-
}, modalContent: {
|
|
5944
|
+
}, modalBackdrop: __assign(__assign({}, StyleSheet.absoluteFillObject), { backgroundColor: "rgba(0, 0, 0, 0.5)" }), modalContent: {
|
|
5926
5945
|
borderRadius: 20,
|
|
5927
5946
|
width: "90%",
|
|
5928
5947
|
paddingBottom: 20,
|
|
5929
5948
|
alignItems: "center",
|
|
5930
5949
|
overflow: "hidden",
|
|
5950
|
+
zIndex: 1,
|
|
5931
5951
|
}, modalTitle: {
|
|
5932
5952
|
textAlign: "center",
|
|
5933
5953
|
marginTop: 16,
|
|
5934
5954
|
marginBottom: 8,
|
|
5935
|
-
},
|
|
5936
|
-
|
|
5937
|
-
|
|
5955
|
+
}, valueRow: {
|
|
5956
|
+
width: "100%",
|
|
5957
|
+
minHeight: 48,
|
|
5958
|
+
justifyContent: "center",
|
|
5959
|
+
position: "relative",
|
|
5960
|
+
}, valueTextContainer: {
|
|
5961
|
+
width: "100%",
|
|
5962
|
+
paddingHorizontal: SPACE_40,
|
|
5963
|
+
minHeight: 40,
|
|
5964
|
+
justifyContent: "center",
|
|
5965
|
+
alignItems: "center",
|
|
5966
|
+
}, valueText: __assign({ textAlign: "center", width: "100%" }, (Platform.OS === "android" && {
|
|
5967
|
+
includeFontPadding: false,
|
|
5968
|
+
textAlignVertical: "center",
|
|
5969
|
+
})), clearButton: {
|
|
5938
5970
|
padding: 8,
|
|
5939
5971
|
position: "absolute",
|
|
5940
5972
|
right: SPACE_12,
|
|
5973
|
+
top: 0,
|
|
5974
|
+
bottom: 0,
|
|
5975
|
+
justifyContent: "center",
|
|
5941
5976
|
}, keyboardGrid: {
|
|
5942
5977
|
marginVertical: 8,
|
|
5943
5978
|
width: "90%",
|