sapo-components-ui-rn 1.1.94 → 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/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 trừ, thêm "0."
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
- // Nếu type float key là "0", không cho phép nhập số 0 đầu tiên
5577
- if (type === "float" && (key === "0" || key === "000")) {
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
- if (inputValue === "0") {
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 {
@@ -5879,16 +5891,21 @@ var TextInputNumber = function (_a) {
5879
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: [
5880
5892
  styles$c.keyButton,
5881
5893
  key === "000" && is000Disabled && styles$c.disabledKey,
5894
+ key === "0" && is0Disabled && styles$c.disabledKey,
5882
5895
  key === "." &&
5883
5896
  inputValue.includes(".") &&
5884
5897
  styles$c.disabledKey,
5885
5898
  ], onPress: function () { return handleKeyPress(key); }, disabled: (key === "000" && is000Disabled) ||
5899
+ (key === "0" && is0Disabled) ||
5886
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: [
5887
5901
  styles$c.keyText,
5888
5902
  styles$c.text22,
5889
5903
  key === "000" &&
5890
5904
  is000Disabled &&
5891
5905
  styles$c.disabledKeyText,
5906
+ key === "0" &&
5907
+ is0Disabled &&
5908
+ styles$c.disabledKeyText,
5892
5909
  key === "." &&
5893
5910
  inputValue.includes(".") &&
5894
5911
  styles$c.disabledKeyText,