@blocklet/payment-react 1.14.19 → 1.14.20

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/es/libs/util.js CHANGED
@@ -691,7 +691,10 @@ export function formatQuantityInventory(price, quantity, locale = "en") {
691
691
  return "";
692
692
  }
693
693
  export function formatAmountPrecisionLimit(amount, locale = "en", precision = 6) {
694
- const [, decimal] = amount.split(".");
694
+ if (!amount) {
695
+ return "";
696
+ }
697
+ const [, decimal] = String(amount).split(".");
695
698
  if (decimal && decimal.length > precision) {
696
699
  return t("common.amountPrecisionLimit", locale, { precision });
697
700
  }
@@ -213,7 +213,7 @@ export function PaymentInner({
213
213
  if (Number(amount) < min || Number(amount) > max) {
214
214
  return;
215
215
  }
216
- if (formatAmountPrecisionLimit(amount, locale)) {
216
+ if (amount && formatAmountPrecisionLimit(String(amount), locale)) {
217
217
  return;
218
218
  }
219
219
  try {
package/lib/libs/util.js CHANGED
@@ -827,7 +827,10 @@ function formatQuantityInventory(price, quantity, locale = "en") {
827
827
  return "";
828
828
  }
829
829
  function formatAmountPrecisionLimit(amount, locale = "en", precision = 6) {
830
- const [, decimal] = amount.split(".");
830
+ if (!amount) {
831
+ return "";
832
+ }
833
+ const [, decimal] = String(amount).split(".");
831
834
  if (decimal && decimal.length > precision) {
832
835
  return (0, _locales.t)("common.amountPrecisionLimit", locale, {
833
836
  precision
@@ -265,7 +265,7 @@ function PaymentInner({
265
265
  if (Number(amount) < min || Number(amount) > max) {
266
266
  return;
267
267
  }
268
- if ((0, _util2.formatAmountPrecisionLimit)(amount, locale)) {
268
+ if (amount && (0, _util2.formatAmountPrecisionLimit)(String(amount), locale)) {
269
269
  return;
270
270
  }
271
271
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.14.19",
3
+ "version": "1.14.20",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -91,7 +91,7 @@
91
91
  "@babel/core": "^7.25.2",
92
92
  "@babel/preset-env": "^7.25.2",
93
93
  "@babel/preset-react": "^7.24.7",
94
- "@blocklet/payment-types": "1.14.19",
94
+ "@blocklet/payment-types": "1.14.20",
95
95
  "@storybook/addon-essentials": "^7.6.20",
96
96
  "@storybook/addon-interactions": "^7.6.20",
97
97
  "@storybook/addon-links": "^7.6.20",
@@ -120,5 +120,5 @@
120
120
  "vite-plugin-babel": "^1.2.0",
121
121
  "vite-plugin-node-polyfills": "^0.21.0"
122
122
  },
123
- "gitHead": "5410d16f8fcc5c713ca9ba986af7653e5c54e5c2"
123
+ "gitHead": "c226ecda79fb537b2067c636410e4c7ab0f2723d"
124
124
  }
package/src/libs/util.ts CHANGED
@@ -894,7 +894,10 @@ export function formatQuantityInventory(price: TPrice, quantity: string | number
894
894
  }
895
895
 
896
896
  export function formatAmountPrecisionLimit(amount: string, locale = 'en', precision: number = 6) {
897
- const [, decimal] = amount.split('.');
897
+ if (!amount) {
898
+ return '';
899
+ }
900
+ const [, decimal] = String(amount).split('.');
898
901
  if (decimal && decimal.length > precision) {
899
902
  return t('common.amountPrecisionLimit', locale, { precision });
900
903
  }
@@ -261,7 +261,7 @@ export function PaymentInner({
261
261
  return;
262
262
  }
263
263
 
264
- if (formatAmountPrecisionLimit(amount, locale)) {
264
+ if (amount && formatAmountPrecisionLimit(String(amount), locale)) {
265
265
  return;
266
266
  }
267
267
  try {