@axos-web-dev/shared-components 1.0.99-dev.14 → 1.0.99-dev.15

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.
@@ -43,7 +43,7 @@ const MarineLoanMonthlyPaymentCalculator = ({ variant, header, disclosure, bodyC
43
43
  } else {
44
44
  setLoanAmountError(null);
45
45
  }
46
- if (!interestRate || isNaN(parseFloat(interestRate)) || interestRate === "0") {
46
+ if (!interestRate || isNaN(parseFloat(interestRate)) || parseFloat(interestRate) === 0) {
47
47
  setInterestRateError("Please enter an Interest Rate.");
48
48
  isValid = false;
49
49
  } else {
@@ -62,14 +62,14 @@ const MarineLoanMonthlyPaymentCalculator = ({ variant, header, disclosure, bodyC
62
62
  setLoanDuration(Number(event.target.value));
63
63
  };
64
64
  const formatToPercentage = (value) => {
65
- const numericValue = value.replace(/[^0-9.]/g, "");
66
- if (numericValue === "") {
67
- return "";
68
- } else if (numericValue.endsWith("%")) {
69
- return numericValue;
70
- } else {
71
- return numericValue.substring(0, numericValue.length - 2) + numericValue.substring(numericValue.length - 2) + "%";
65
+ let numericValue = value.replace(/[^0-9.]/g, "");
66
+ const parts = numericValue.split(".");
67
+ if (parts.length > 2) {
68
+ numericValue = parts[0] + "." + parts.slice(1).join("");
72
69
  }
70
+ if (numericValue === "") return "";
71
+ const cleaned = numericValue.startsWith("0") && numericValue !== "0" ? String(parseFloat(numericValue)) : numericValue;
72
+ return cleaned + "%";
73
73
  };
74
74
  const handleInterestRateChange = (event) => {
75
75
  let value = event.target.value;
@@ -88,7 +88,8 @@ const MarineLoanMonthlyPaymentCalculator = ({ variant, header, disclosure, bodyC
88
88
  value = formatToPercentage(value);
89
89
  }
90
90
  setInterestRateDisplay(value);
91
- setInterestRate(value.replace(/[^0-9.]/g, ""));
91
+ const numeric = value.replace(/[^0-9.]/g, "");
92
+ setInterestRate(numeric);
92
93
  };
93
94
  const calculateMonthlyPayment = () => {
94
95
  const numericInterestRate = parseFloat(interestRate);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@axos-web-dev/shared-components",
3
3
  "description": "Axos shared components library for web.",
4
- "version": "1.0.99-dev.14",
4
+ "version": "1.0.99-dev.15",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",