@odynn/awayz-core 0.10.25 → 0.10.27

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.
@@ -0,0 +1,41 @@
1
+ import { jsxs as i, Fragment as m, jsx as c } from "react/jsx-runtime";
2
+ const a = "USD", l = (r, t) => {
3
+ const n = t || a, e = new Intl.NumberFormat("en-US");
4
+ if (!r) return `${e.format(0)}${n}`;
5
+ const o = parseFloat(r.toString());
6
+ return /* @__PURE__ */ i(m, { children: [
7
+ e.format(isNaN(o) ? 0 : o),
8
+ " ",
9
+ /* @__PURE__ */ c("sub", { children: n })
10
+ ] });
11
+ }, F = (r, t) => {
12
+ const n = t || a, e = new Intl.NumberFormat("en-US", {
13
+ maximumFractionDigits: 0
14
+ });
15
+ return /* @__PURE__ */ i(m, { children: [
16
+ e.format(isNaN(r) ? 0 : r),
17
+ " ",
18
+ /* @__PURE__ */ c("sub", { children: n })
19
+ ] });
20
+ }, y = (r, t, n = 0, e = n) => {
21
+ const o = parseFloat((r == null ? void 0 : r.toString()) || "0"), s = t || a, u = new Intl.NumberFormat("en-US", {
22
+ minimumFractionDigits: e,
23
+ maximumFractionDigits: n
24
+ });
25
+ return /* @__PURE__ */ i(m, { children: [
26
+ u.format(isNaN(o) ? 0 : o),
27
+ " ",
28
+ /* @__PURE__ */ c("sub", { children: s })
29
+ ] });
30
+ }, N = (r, t = "en") => 0 .toLocaleString(t, {
31
+ style: "currency",
32
+ currency: r,
33
+ minimumFractionDigits: 0,
34
+ maximumFractionDigits: 0
35
+ }).replace(/\d/g, "").trim();
36
+ export {
37
+ F as a,
38
+ l as b,
39
+ N as c,
40
+ y as g
41
+ };
@@ -1,56 +1,62 @@
1
1
  import { jsx as r, jsxs as l } from "react/jsx-runtime";
2
- import { useQuery as R } from "@tanstack/react-query";
3
- import { g as m, a as _, b as N } from "../../cashUtils-Dlce3Uj_.js";
2
+ import { useQuery as _ } from "@tanstack/react-query";
3
+ import { g as u, a as S, b as f } from "../../cashUtils-DyxlHnod.js";
4
4
  import "../../arrayExtensions-DlcBOj5a.js";
5
- import { E as S } from "../../noRetryInstance-DNLgOg0E.js";
6
- import { useMemo as T } from "react";
7
- import { a as f } from "../../index-C8p5kinH.js";
5
+ import { E as T } from "../../noRetryInstance-DNLgOg0E.js";
6
+ import { useMemo as I } from "react";
7
+ import { a as v } from "../../index-C8p5kinH.js";
8
8
  import "react-i18next";
9
9
  import '../../assets/_styles4.css';import '../../assets/_styles2.css';import '../../assets/_styles.css';import '../../assets/_styles3.css';/* empty css */
10
10
  /* empty css */
11
11
  /* empty css */
12
- import { EInvalidAmountDisplayOption as t, EToolTipPosition as D } from "./CashValueTypes.js";
13
- import { useAwayzContext as I } from "../../hooks/useAwayzContext.js";
12
+ import { EInvalidAmountDisplayOption as t, EToolTipPosition as M } from "./CashValueTypes.js";
13
+ import { useAwayzContext as O } from "../../hooks/useAwayzContext.js";
14
14
  import "../../configs/awayzClient.js";
15
15
  /* empty css */
16
16
  import "../../context/AwayzContext.js";
17
- import { CurrencyService as M } from "../../services/currency/CurrencyService.js";
18
- import { Tooltip as O } from "../Tooltip/Tooltip.js";
19
- const x = 1e3 * 60 * 60, k = ({
17
+ import { CurrencyService as x } from "../../services/currency/CurrencyService.js";
18
+ import { Tooltip as D } from "../Tooltip/Tooltip.js";
19
+ const Y = 1e3 * 60 * 60, J = ({
20
20
  amount: i,
21
21
  currency: e,
22
- position: v = D.RIGHT,
23
- zeroDisplayOption: A = t.NA,
24
- customDisplay: y,
25
- decimalPlaces: p = 2,
26
- showConversion: g = !1,
27
- showOriginal: E = !0
22
+ position: A = M.RIGHT,
23
+ zeroDisplayOption: y = t.NA,
24
+ customDisplay: g,
25
+ decimalPlaces: s = 2,
26
+ minDecimalPlaces: d = s,
27
+ showConversion: E = !1,
28
+ showOriginal: R = !0
28
29
  }) => {
29
- var h, C;
30
- const { user: o } = I(), n = ((h = o == null ? void 0 : o.preferences) == null ? void 0 : h.currency) ?? ((C = o == null ? void 0 : o.userRegion) == null ? void 0 : C.currency), s = n !== e, { data: c, isPending: d } = R({
31
- queryKey: [S.CONVERT_CURRENCY, e, n],
32
- queryFn: () => M.convertCurrency({
30
+ var C, N;
31
+ const { user: o } = O(), n = ((C = o == null ? void 0 : o.preferences) == null ? void 0 : C.currency) ?? ((N = o == null ? void 0 : o.userRegion) == null ? void 0 : N.currency), c = n !== e, { data: a, isPending: m } = _({
32
+ queryKey: [T.CONVERT_CURRENCY, e, n],
33
+ queryFn: () => x.convertCurrency({
33
34
  baseCurrency: e,
34
35
  targetCurrency: n
35
36
  }),
36
- enabled: s && !!e && !!i,
37
- staleTime: x
38
- }), a = T(() => {
37
+ enabled: c && !!e && !!i,
38
+ staleTime: Y
39
+ }), p = I(() => {
39
40
  if (!o)
40
41
  return null;
41
- let u = typeof i == "string" ? parseFloat(i) : i;
42
- if (s) {
43
- if (d || !c) return null;
44
- u = u * c;
42
+ let h = typeof i == "string" ? parseFloat(i) : i;
43
+ if (c) {
44
+ if (m || !a) return null;
45
+ h = h * a;
45
46
  }
46
- return u;
47
- }, [i, o, d, s, c]);
48
- if (E)
49
- return /* @__PURE__ */ r("span", { className: "currency-conversion", children: m(i, e, p) });
50
- if (d && s)
47
+ return h;
48
+ }, [i, o, m, c, a]);
49
+ if (R)
50
+ return /* @__PURE__ */ r("span", { className: "currency-conversion", children: u(
51
+ i,
52
+ e,
53
+ s,
54
+ d
55
+ ) });
56
+ if (m && c)
51
57
  return /* @__PURE__ */ r("span", { className: "currency-conversion loading", children: i });
52
- if (!n || !a || a < 0)
53
- switch (A) {
58
+ if (!n || !p || p < 0)
59
+ switch (y) {
54
60
  case t.NA:
55
61
  return /* @__PURE__ */ r("span", { children: "N/A" });
56
62
  case t.HIDDEN:
@@ -58,25 +64,26 @@ const x = 1e3 * 60 * 60, k = ({
58
64
  case t.DISPLAY_AS_ZERO:
59
65
  return /* @__PURE__ */ r("span", { children: "0" });
60
66
  case t.DISPLAY_AS_ZERO_WITH_CURRENCY:
61
- return /* @__PURE__ */ r("span", { children: N(0, n ?? e) });
67
+ return /* @__PURE__ */ r("span", { children: f(0, n ?? e) });
62
68
  case t.DISPLAY_AS_ZERO_WITH_CURRENCY_NO_DECIMAL:
63
- return /* @__PURE__ */ r("span", { children: _(0, n ?? e) });
69
+ return /* @__PURE__ */ r("span", { children: S(0, n ?? e) });
64
70
  case t.CUSTOM:
65
- return /* @__PURE__ */ r("span", { children: a == 0 ? y : "N/A" });
71
+ return /* @__PURE__ */ r("span", { children: p == 0 ? g : "N/A" });
66
72
  default:
67
73
  return /* @__PURE__ */ r("span", { children: "N/A" });
68
74
  }
69
75
  return /* @__PURE__ */ l("span", { className: "currency-conversion", children: [
70
- m(
71
- a,
76
+ u(
77
+ p,
72
78
  n,
73
- p
79
+ s,
80
+ d
74
81
  ),
75
- s && g && /* @__PURE__ */ r(
76
- O,
82
+ c && E && /* @__PURE__ */ r(
83
+ D,
77
84
  {
78
- trigger: /* @__PURE__ */ r("sup", { children: /* @__PURE__ */ r(f, {}) }),
79
- position: v,
85
+ trigger: /* @__PURE__ */ r("sup", { children: /* @__PURE__ */ r(v, {}) }),
86
+ position: A,
80
87
  children: /* @__PURE__ */ l("div", { className: "currency-conversion-container", children: [
81
88
  /* @__PURE__ */ l("p", { children: [
82
89
  "Converted from ",
@@ -85,26 +92,32 @@ const x = 1e3 * 60 * 60, k = ({
85
92
  n
86
93
  ] }),
87
94
  /* @__PURE__ */ l("div", { className: "currency-conversion-amounts", children: [
88
- /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r("p", { children: m(i, e, p) }) }),
89
- /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r("p", { children: m(
90
- a,
95
+ /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r("p", { children: u(
96
+ i,
97
+ e,
98
+ s,
99
+ d
100
+ ) }) }),
101
+ /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r("p", { children: u(
102
+ p,
91
103
  n,
92
- p
104
+ s,
105
+ d
93
106
  ) }) }),
94
- /* @__PURE__ */ r("span", { className: "conversion-icon", children: /* @__PURE__ */ r(f, {}) })
107
+ /* @__PURE__ */ r("span", { className: "conversion-icon", children: /* @__PURE__ */ r(v, {}) })
95
108
  ] }),
96
109
  /* @__PURE__ */ r("div", { className: "currency-conversion-rate", children: /* @__PURE__ */ l("p", { children: [
97
110
  "Current Rate:",
98
111
  " ",
99
- c ? (
112
+ a ? (
100
113
  // only leaving 2 decimal places for the conversion rate is
101
114
  // not enough, can lead to confusion
102
115
  // use Number constructor to strip unnecessary trailing zeros
103
- `${Number((1 / c).toFixed(5))} ${e}`
116
+ `${Number((1 / a).toFixed(5))} ${e}`
104
117
  ) : "N/A",
105
118
  " ",
106
119
  "≈ ",
107
- N(1, n)
120
+ f(1, n)
108
121
  ] }) })
109
122
  ] })
110
123
  }
@@ -112,6 +125,6 @@ const x = 1e3 * 60 * 60, k = ({
112
125
  ] });
113
126
  };
114
127
  export {
115
- k as CashValue,
116
- x as CurrencyCallStaleTimeMs
128
+ J as CashValue,
129
+ Y as CurrencyCallStaleTimeMs
117
130
  };
@@ -1,4 +1,4 @@
1
- import { c as P } from "../../cashUtils-Dlce3Uj_.js";
1
+ import { c as P } from "../../cashUtils-DyxlHnod.js";
2
2
  import "../../arrayExtensions-DlcBOj5a.js";
3
3
  import { e as M, A as m, E as N } from "../../noRetryInstance-DNLgOg0E.js";
4
4
  import { a as i } from "../../keys-BcBfU51M.js";
@@ -30,9 +30,15 @@ export interface ICashValueProps {
30
30
  */
31
31
  customDisplay?: string;
32
32
  /**
33
- * Number of decimal places to display. Defaults to 0.
33
+ * Maximum number of decimal places to display. Defaults to 0.
34
34
  */
35
35
  decimalPlaces?: number;
36
+ /**
37
+ * Minimum number of decimal places to display. Defaults to `decimalPlaces`.
38
+ * Useful when you want to pad small values (e.g. 0 → "0.00") while still
39
+ * allowing more precision when the value has it (e.g. 0.1245 → "0.1245").
40
+ */
41
+ minDecimalPlaces?: number;
36
42
  /**
37
43
  * Whether to show the conversion tooltip.
38
44
  * Defaults to true, but can be set to false to hide it.
@@ -51,4 +57,4 @@ export declare const CurrencyCallStaleTimeMs: number;
51
57
  * If the original currency differs from the user's currency, it shows a conversion
52
58
  * tooltip with details about the conversion rate and original amount.
53
59
  */
54
- export declare const CashValue: ({ amount, currency, position, zeroDisplayOption, customDisplay, decimalPlaces, showConversion, showOriginal }: ICashValueProps) => import("react/jsx-runtime").JSX.Element;
60
+ export declare const CashValue: ({ amount, currency, position, zeroDisplayOption, customDisplay, decimalPlaces, minDecimalPlaces, showConversion, showOriginal }: ICashValueProps) => import("react/jsx-runtime").JSX.Element;
@@ -75,6 +75,7 @@ export interface IPointsAsCash {
75
75
  message?: string;
76
76
  }[];
77
77
  exchangeRateAtAuthorisation: number;
78
+ last4Digits?: string;
78
79
  }
79
80
  export interface ICancellationTimeline {
80
81
  refundAmount: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.10.25",
3
+ "version": "0.10.27",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -1,40 +0,0 @@
1
- import { jsxs as i, Fragment as c, jsx as m } from "react/jsx-runtime";
2
- const a = "USD", g = (r, t) => {
3
- const e = t || a, n = new Intl.NumberFormat("en-US");
4
- if (!r) return `${n.format(0)}${e}`;
5
- const o = parseFloat(r.toString());
6
- return /* @__PURE__ */ i(c, { children: [
7
- n.format(isNaN(o) ? 0 : o),
8
- " ",
9
- /* @__PURE__ */ m("sub", { children: e })
10
- ] });
11
- }, l = (r, t) => {
12
- const e = t || a, n = new Intl.NumberFormat("en-US", {
13
- maximumFractionDigits: 0
14
- });
15
- return /* @__PURE__ */ i(c, { children: [
16
- n.format(isNaN(r) ? 0 : r),
17
- " ",
18
- /* @__PURE__ */ m("sub", { children: e })
19
- ] });
20
- }, y = (r, t, e = 0) => {
21
- const n = parseFloat((r == null ? void 0 : r.toString()) || "0"), o = t || a, s = new Intl.NumberFormat("en-US", {
22
- maximumFractionDigits: e
23
- });
24
- return /* @__PURE__ */ i(c, { children: [
25
- s.format(isNaN(n) ? 0 : n),
26
- " ",
27
- /* @__PURE__ */ m("sub", { children: o })
28
- ] });
29
- }, F = (r, t = "en") => 0 .toLocaleString(t, {
30
- style: "currency",
31
- currency: r,
32
- minimumFractionDigits: 0,
33
- maximumFractionDigits: 0
34
- }).replace(/\d/g, "").trim();
35
- export {
36
- l as a,
37
- g as b,
38
- F as c,
39
- y as g
40
- };