@alphakits/ui 2.6.3 → 2.7.0

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,16 +1,19 @@
1
1
  import { currency as R } from "../data/currency-codes.js";
2
- import { getCurrencySymbol as _ } from "../get-currency-symbol/util.js";
3
- import { splitAmount as C } from "../split-amount/util.js";
4
- const O = 3, S = 4, T = "−", a = " ", e = ",", l = (t) => t === "USD" || t === "CHF" || t === "GBP" || t === "CAD" || t === "AUD" || t === "NZD" || t === "ARS" || t === "BRL" || t === "TWD" || t === "MXN" || t === "JPY" || t === "SGD" || t === "TRY" || t === "GEL" || t === "ILS" || t === "UAH", N = (t, o, i) => o ? t ? l(i) ? `${o}${a}${t}` : `${t}${a}${o}` : "" : t, U = (t) => t ? t.length > 2 ? t.slice(0, 2) : t.length < 2 ? `${t}0` : t : "00", h = (t, o, i) => {
5
- const r = U(t);
2
+ import { getCurrencySymbol as S } from "../get-currency-symbol/util.js";
3
+ import { splitAmount as _ } from "../split-amount/util.js";
4
+ const C = 3, O = 4, T = "−", f = " ", e = ",", l = (t) => t === "USD" || t === "CHF" || t === "GBP" || t === "CAD" || t === "AUD" || t === "NZD" || t === "ARS" || t === "BRL" || t === "TWD" || t === "MXN" || t === "JPY" || t === "SGD" || t === "TRY" || t === "GEL" || t === "ILS" || t === "UAH", h = (t, o, i) => o ? t ? l(i) ? `${o}${f}${t}` : `${t}${f}${o}` : "" : t, N = (t) => t ? t.length > 2 ? t.slice(0, 2) : t.length < 2 ? `${t}0` : t : "00", U = (t, o, i) => {
5
+ const r = N(t);
6
6
  return !i && r === "00" ? null : !i && r[1] === "0" ? r.slice(0, 1) : r === "00" && !o ? null : r;
7
+ }, p = (t) => {
8
+ const o = Math.abs(Math.round(t));
9
+ return [`${Math.floor(o / 100)}`, `${o % 100}`.padStart(2, "0")];
7
10
  }, $ = ({
8
11
  value: t,
9
12
  currency: o,
10
13
  showMinorPart: i,
11
14
  type: r
12
15
  }) => {
13
- const m = !!o && !!R.CURRENCY_SYMBOLS[o], n = m ? _(o) : o;
16
+ const m = !!o && !!R.CURRENCY_SYMBOLS[o], n = m ? S(o) : o;
14
17
  if (t === null)
15
18
  return {
16
19
  majorPart: "",
@@ -19,19 +22,19 @@ const O = 3, S = 4, T = "−", a = " ", e = ",", l = (t) => t === "USD" || t =
19
22
  currencySymbol: n,
20
23
  formattedWithCurrency: ""
21
24
  };
22
- const [M, s] = r === "default" ? `${t}`.split(".") : [`${t}`.slice(0, -2), `${t}`.slice(-2)], A = C(
23
- `${Math.abs(+M || 0)}`,
24
- O,
25
- a,
26
- S
27
- ), f = t < 0 ? T + A : A, P = s ? f + e + s : f;
25
+ const [P, s] = r === "default" ? `${t}`.split(".") : p(t), M = _(
26
+ `${Math.abs(+P || 0)}`,
27
+ C,
28
+ f,
29
+ O
30
+ ), a = t < 0 ? T + M : M, A = s ? a + e + s : a;
28
31
  return {
29
- majorPart: f,
30
- minorPart: h(s, i, m),
32
+ majorPart: a,
33
+ minorPart: U(s, i, m),
31
34
  currencySymbol: n,
32
- formatted: P,
33
- formattedWithCurrency: N(
34
- P,
35
+ formatted: A,
36
+ formattedWithCurrency: h(
37
+ A,
35
38
  n || "",
36
39
  o
37
40
  )
@@ -39,7 +42,7 @@ const O = 3, S = 4, T = "−", a = " ", e = ",", l = (t) => t === "USD" || t =
39
42
  };
40
43
  export {
41
44
  e as AMOUNT_MAJOR_MINOR_PARTS_SEPARATOR,
42
- a as THINSP,
45
+ f as THINSP,
43
46
  $ as formatAmount,
44
47
  l as isCurrencyFirst
45
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alphakits/ui",
3
- "version": "2.6.3",
3
+ "version": "2.7.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],