@gearbox-protocol/ui-kit 4.1.2 → 4.1.3

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../utils/internal/format-percent.cjs");function r(t){return`${t>0n?"+":""}${e.formatPercentAmount(Number(t)/1e4,2)}%`}exports.priceImpact=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../../utils/internal/format-percent.cjs");function r(t){const e=n.formatPercentAmount(Number(t)/1e4,2);return`${t>0n&&Number(e)!==0?"+":""}${e}%`}exports.priceImpact=r;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=1e3,u=[{div:1e12,suffix:"T"},{div:1e9,suffix:"B"},{div:1e6,suffix:"M"},{div:1e3,suffix:"K"}];function c(t){return t.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")}function r(t,e){for(const{div:i,suffix:n}of u)if(t>=i)return`${c((t/i).toFixed(e))}${n}`;return t.toFixed(e)}function f(t,e=2){return!Number.isFinite(t)||t===0?"0%":`${t<0?"-":""}${r(Math.abs(t),e)}%`}function s(t,e,i=!0){const n=typeof t=="number"?t:Number(t);return Number.isNaN(n)||n===void 0||n===null?"0":n===0?0:i&&Math.abs(n)>=o?`${n<0?"-":""}${r(Math.abs(n),e)}`:n.toFixed(e)}const m={minimumFractionDigits:2,maximumFractionDigits:2,decimalPrecision:4,minDecimalThreshold:1,minExponentialThreshold:1e-4,maxExponentialThreshold:1e6,locale:"en-US"};exports.DEFAULT_FORMAT_MONEY_CONSTANTS=m;exports.formatCompactPercent=f;exports.formatPercentAmount=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=1e3,u=[{div:1e12,suffix:"T"},{div:1e9,suffix:"B"},{div:1e6,suffix:"M"},{div:1e3,suffix:"K"}];function f(t){return t.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")}function o(t,n){for(const{div:i,suffix:e}of u)if(t>=i)return`${f((t/i).toFixed(n))}${e}`;return t.toFixed(n)}function s(t,n=2){return!Number.isFinite(t)||t===0?"0%":`${t<0?"-":""}${o(Math.abs(t),n)}%`}function m(t,n,i=!0){const e=typeof t=="number"?t:Number(t);if(Number.isNaN(e)||e===void 0||e===null)return"0";if(e===0)return 0;if(i&&Math.abs(e)>=c)return`${e<0?"-":""}${o(Math.abs(e),n)}`;const r=e.toFixed(n);return Number(r)===0?r.replace("-",""):r}const a={minimumFractionDigits:2,maximumFractionDigits:2,decimalPrecision:4,minDecimalThreshold:1,minExponentialThreshold:1e-4,maxExponentialThreshold:1e6,locale:"en-US"};exports.DEFAULT_FORMAT_MONEY_CONSTANTS=a;exports.formatCompactPercent=s;exports.formatPercentAmount=m;
@@ -1,6 +1,7 @@
1
1
  import { formatPercentAmount as r } from "../../../utils/internal/format-percent.js";
2
2
  function e(n) {
3
- return `${n > 0n ? "+" : ""}${r(Number(n) / 1e4, 2)}%`;
3
+ const t = r(Number(n) / 1e4, 2);
4
+ return `${n > 0n && Number(t) !== 0 ? "+" : ""}${t}%`;
4
5
  }
5
6
  export {
6
7
  e as priceImpact
@@ -1,26 +1,32 @@
1
- const o = [
1
+ const u = [
2
2
  { div: 1e12, suffix: "T" },
3
3
  { div: 1e9, suffix: "B" },
4
4
  { div: 1e6, suffix: "M" },
5
5
  { div: 1e3, suffix: "K" }
6
6
  ];
7
- function u(i) {
7
+ function c(i) {
8
8
  return i.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
9
9
  }
10
- function r(i, t) {
11
- for (const { div: e, suffix: n } of o)
12
- if (i >= e)
13
- return `${u((i / e).toFixed(t))}${n}`;
14
- return i.toFixed(t);
10
+ function o(i, e) {
11
+ for (const { div: t, suffix: n } of u)
12
+ if (i >= t)
13
+ return `${c((i / t).toFixed(e))}${n}`;
14
+ return i.toFixed(e);
15
15
  }
16
- function s(i, t = 2) {
17
- return !Number.isFinite(i) || i === 0 ? "0%" : `${i < 0 ? "-" : ""}${r(Math.abs(i), t)}%`;
16
+ function s(i, e = 2) {
17
+ return !Number.isFinite(i) || i === 0 ? "0%" : `${i < 0 ? "-" : ""}${o(Math.abs(i), e)}%`;
18
18
  }
19
- function c(i, t, e = !0) {
19
+ function m(i, e, t = !0) {
20
20
  const n = typeof i == "number" ? i : Number(i);
21
- return Number.isNaN(n) || n === void 0 || n === null ? "0" : n === 0 ? 0 : e && Math.abs(n) >= 1e3 ? `${n < 0 ? "-" : ""}${r(Math.abs(n), t)}` : n.toFixed(t);
21
+ if (Number.isNaN(n) || n === void 0 || n === null)
22
+ return "0";
23
+ if (n === 0) return 0;
24
+ if (t && Math.abs(n) >= 1e3)
25
+ return `${n < 0 ? "-" : ""}${o(Math.abs(n), e)}`;
26
+ const r = n.toFixed(e);
27
+ return Number(r) === 0 ? r.replace("-", "") : r;
22
28
  }
23
- const m = {
29
+ const a = {
24
30
  minimumFractionDigits: 2,
25
31
  maximumFractionDigits: 2,
26
32
  decimalPrecision: 4,
@@ -30,7 +36,7 @@ const m = {
30
36
  locale: "en-US"
31
37
  };
32
38
  export {
33
- m as DEFAULT_FORMAT_MONEY_CONSTANTS,
39
+ a as DEFAULT_FORMAT_MONEY_CONSTANTS,
34
40
  s as formatCompactPercent,
35
- c as formatPercentAmount
41
+ m as formatPercentAmount
36
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",