@unifold/ui-react 0.1.12 → 0.1.14

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.js CHANGED
@@ -494,9 +494,24 @@ function DepositDetailContent({ execution }) {
494
494
  }
495
495
  };
496
496
  const formatAmount = (baseUnitAmount, decimals = 6) => {
497
+ if (!baseUnitAmount) return "\u2014";
497
498
  try {
498
- const amount = Number(baseUnitAmount) / Math.pow(10, decimals);
499
- return amount.toFixed(2);
499
+ const value = Number(baseUnitAmount) / Math.pow(10, decimals);
500
+ if (value === 0) {
501
+ return "0.00";
502
+ }
503
+ if (value >= 1) {
504
+ return value.toLocaleString("en-US", {
505
+ minimumFractionDigits: 2,
506
+ maximumFractionDigits: 2
507
+ });
508
+ }
509
+ return value.toLocaleString("en-US", {
510
+ minimumFractionDigits: 2,
511
+ maximumFractionDigits: 8,
512
+ minimumSignificantDigits: 2,
513
+ maximumSignificantDigits: 6
514
+ });
500
515
  } catch {
501
516
  return "0.00";
502
517
  }
@@ -602,7 +617,7 @@ function DepositDetailContent({ execution }) {
602
617
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "uf-flex uf-justify-between uf-items-center uf-px-4 uf-py-3 uf-border-b uf-border-border/50", children: [
603
618
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uf-text-muted-foreground uf-text-sm", children: "Amount Sent" }),
604
619
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "uf-text-foreground uf-font-medium", children: [
605
- formatAmount(execution.source_amount_base_unit),
620
+ formatAmount(execution.source_amount_base_unit, execution.source_token_metadata?.decimals),
606
621
  " ",
607
622
  formatCurrency(execution.source_currency)
608
623
  ] })
@@ -610,7 +625,7 @@ function DepositDetailContent({ execution }) {
610
625
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "uf-flex uf-justify-between uf-items-center uf-px-4 uf-py-3 uf-border-b uf-border-border/50", children: [
611
626
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uf-text-muted-foreground uf-text-sm", children: "Amount Received" }),
612
627
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "uf-text-foreground uf-font-medium", children: [
613
- formatAmount(execution.destination_amount_base_unit),
628
+ formatAmount(execution.destination_amount_base_unit, execution.destination_token_metadata?.decimals),
614
629
  " ",
615
630
  formatCurrency(execution.destination_currency)
616
631
  ] })
package/dist/index.mjs CHANGED
@@ -428,9 +428,24 @@ function DepositDetailContent({ execution }) {
428
428
  }
429
429
  };
430
430
  const formatAmount = (baseUnitAmount, decimals = 6) => {
431
+ if (!baseUnitAmount) return "\u2014";
431
432
  try {
432
- const amount = Number(baseUnitAmount) / Math.pow(10, decimals);
433
- return amount.toFixed(2);
433
+ const value = Number(baseUnitAmount) / Math.pow(10, decimals);
434
+ if (value === 0) {
435
+ return "0.00";
436
+ }
437
+ if (value >= 1) {
438
+ return value.toLocaleString("en-US", {
439
+ minimumFractionDigits: 2,
440
+ maximumFractionDigits: 2
441
+ });
442
+ }
443
+ return value.toLocaleString("en-US", {
444
+ minimumFractionDigits: 2,
445
+ maximumFractionDigits: 8,
446
+ minimumSignificantDigits: 2,
447
+ maximumSignificantDigits: 6
448
+ });
434
449
  } catch {
435
450
  return "0.00";
436
451
  }
@@ -536,7 +551,7 @@ function DepositDetailContent({ execution }) {
536
551
  /* @__PURE__ */ jsxs4("div", { className: "uf-flex uf-justify-between uf-items-center uf-px-4 uf-py-3 uf-border-b uf-border-border/50", children: [
537
552
  /* @__PURE__ */ jsx6("span", { className: "uf-text-muted-foreground uf-text-sm", children: "Amount Sent" }),
538
553
  /* @__PURE__ */ jsxs4("span", { className: "uf-text-foreground uf-font-medium", children: [
539
- formatAmount(execution.source_amount_base_unit),
554
+ formatAmount(execution.source_amount_base_unit, execution.source_token_metadata?.decimals),
540
555
  " ",
541
556
  formatCurrency(execution.source_currency)
542
557
  ] })
@@ -544,7 +559,7 @@ function DepositDetailContent({ execution }) {
544
559
  /* @__PURE__ */ jsxs4("div", { className: "uf-flex uf-justify-between uf-items-center uf-px-4 uf-py-3 uf-border-b uf-border-border/50", children: [
545
560
  /* @__PURE__ */ jsx6("span", { className: "uf-text-muted-foreground uf-text-sm", children: "Amount Received" }),
546
561
  /* @__PURE__ */ jsxs4("span", { className: "uf-text-foreground uf-font-medium", children: [
547
- formatAmount(execution.destination_amount_base_unit),
562
+ formatAmount(execution.destination_amount_base_unit, execution.destination_token_metadata?.decimals),
548
563
  " ",
549
564
  formatCurrency(execution.destination_currency)
550
565
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/ui-react",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Unifold UI React - Deposit and onramp components for React applications",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -17,8 +17,8 @@
17
17
  "dist"
18
18
  ],
19
19
  "peerDependencies": {
20
- "react": "^18.2.0",
21
- "react-dom": "^18.2.0"
20
+ "react": "^18.2.0 || ^19.0.0",
21
+ "react-dom": "^18.2.0 || ^19.0.0"
22
22
  },
23
23
  "dependencies": {
24
24
  "@radix-ui/react-dialog": "^1.0.5",
@@ -28,14 +28,14 @@
28
28
  "@tanstack/react-query": "^5.90.11",
29
29
  "class-variance-authority": "^0.7.0",
30
30
  "clsx": "^2.0.0",
31
- "lucide-react": "^0.294.0",
31
+ "lucide-react": "^0.454.0",
32
32
  "qr-code-styling": "^1.6.0-rc.1",
33
33
  "tailwind-merge": "^2.0.0",
34
- "@unifold/core": "0.1.12"
34
+ "@unifold/core": "0.1.14"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/react": "^18.2.0",
38
- "@types/react-dom": "^18.2.0",
37
+ "@types/react": "^19.0.0",
38
+ "@types/react-dom": "^19.0.0",
39
39
  "autoprefixer": "^10.4.16",
40
40
  "postcss": "^8.4.31",
41
41
  "prettier": "^3.1.1",