@odynn/awayz-core 0.9.30 → 0.9.31

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.
@@ -27,8 +27,8 @@ const c = (r, t) => {
27
27
  maximumFractionDigits: 0
28
28
  }).replace(/\d/g, "").trim();
29
29
  export {
30
- c as a,
31
- u as b,
30
+ i as a,
31
+ c as b,
32
32
  y as c,
33
- i as g
33
+ u as g
34
34
  };
@@ -1,103 +1,106 @@
1
- import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
- import { useQuery as g } from "@tanstack/react-query";
1
+ import { jsx as r, jsxs as l } from "react/jsx-runtime";
2
+ import { useQuery as E } from "@tanstack/react-query";
3
3
  import "../../arrayExtensions-DlcBOj5a.js";
4
- import { g as E, a as C, b as u } from "../../cashUtils-DJFSvWw5.js";
5
- import { E as R } from "../../noRetryInstance-DKhe8ju0.js";
6
- import { useMemo as _ } from "react";
4
+ import { g as m, a as R, b as C } from "../../cashUtils-DB_r0g-F.js";
5
+ import { E as _ } from "../../noRetryInstance-DKhe8ju0.js";
6
+ import { useMemo as S } from "react";
7
7
  import { a as N } from "../../index-C8p5kinH.js";
8
8
  import "react-i18next";
9
9
  import '../../assets/_styles3.css';import '../../assets/_styles.css';import '../../assets/_styles2.css';/* empty css */
10
10
  import "../../_styles.flight-booking-CaUgKcMC.js";
11
11
  /* empty css */
12
- import { EInvalidAmountDisplayOption as o, EToolTipPosition as S } from "./CashValueTypes.js";
13
- import { useAwayzContext as T } from "../../hooks/useAwayzContext.js";
12
+ import { EInvalidAmountDisplayOption as o, EToolTipPosition as T } from "./CashValueTypes.js";
13
+ import { useAwayzContext as D } from "../../hooks/useAwayzContext.js";
14
14
  import "../../configs/awayzClient.js";
15
15
  /* empty css */
16
16
  import "../../context/AwayzContext.js";
17
- import { CurrencyService as D } from "../../services/currency/CurrencyService.js";
18
- import { Tooltip as I } from "../Tooltip/Tooltip.js";
19
- const M = 1e3 * 60 * 60, z = ({
17
+ import { CurrencyService as I } from "../../services/currency/CurrencyService.js";
18
+ import { Tooltip as M } from "../Tooltip/Tooltip.js";
19
+ const O = 1e3 * 60 * 60, G = ({
20
20
  amount: i,
21
- currency: r,
22
- position: f = S.RIGHT,
23
- zeroDisplayOption: A = o.NA,
24
- customDisplay: v,
21
+ currency: e,
22
+ position: f = T.RIGHT,
23
+ zeroDisplayOption: v = o.NA,
24
+ customDisplay: A,
25
25
  decimalPlaces: p = 2,
26
- showConversion: y = !1
26
+ showConversion: y = !1,
27
+ showOriginal: g = !1
27
28
  }) => {
28
29
  var h;
29
- const { user: t } = T(), n = ((h = t == null ? void 0 : t.preferences) == null ? void 0 : h.currency) ?? r, s = n !== r, { data: c, isPending: m } = g({
30
- queryKey: [R.CONVERT_CURRENCY, r, n],
31
- queryFn: () => D.convertCurrency({
32
- baseCurrency: r,
30
+ const { user: s } = D(), n = ((h = s == null ? void 0 : s.preferences) == null ? void 0 : h.currency) ?? e, t = n !== e, { data: c, isPending: d } = E({
31
+ queryKey: [_.CONVERT_CURRENCY, e, n],
32
+ queryFn: () => I.convertCurrency({
33
+ baseCurrency: e,
33
34
  targetCurrency: n
34
35
  }),
35
- enabled: s && !!r && !!i,
36
- staleTime: M
37
- }), a = _(() => {
38
- if (!t)
36
+ enabled: t && !!e && !!i,
37
+ staleTime: O
38
+ }), a = S(() => {
39
+ if (!s)
39
40
  return null;
40
- let d = typeof i == "string" ? parseFloat(i) : i;
41
- if (s) {
42
- if (m || !c) return null;
43
- d = d * c;
41
+ let u = typeof i == "string" ? parseFloat(i) : i;
42
+ if (t) {
43
+ if (d || !c) return null;
44
+ u = u * c;
44
45
  }
45
- return d;
46
- }, [i, t, m, s, c]);
47
- if (m && s)
48
- return /* @__PURE__ */ e("span", { className: "currency-conversion loading", children: i });
46
+ return u;
47
+ }, [i, s, d, t, c]);
48
+ if (g)
49
+ return /* @__PURE__ */ r("span", { className: "currency-conversion", children: m(i, e, p) });
50
+ if (d && t)
51
+ return /* @__PURE__ */ r("span", { className: "currency-conversion loading", children: i });
49
52
  if (!n || !a || a < 0)
50
- switch (A) {
53
+ switch (v) {
51
54
  case o.NA:
52
- return /* @__PURE__ */ e("span", { children: "N/A" });
55
+ return /* @__PURE__ */ r("span", { children: "N/A" });
53
56
  case o.HIDDEN:
54
- return /* @__PURE__ */ e("span", { className: "hidden", children: "N/A" });
57
+ return /* @__PURE__ */ r("span", { className: "hidden", children: "N/A" });
55
58
  case o.DISPLAY_AS_ZERO:
56
- return /* @__PURE__ */ e("span", { children: "0" });
59
+ return /* @__PURE__ */ r("span", { children: "0" });
57
60
  case o.DISPLAY_AS_ZERO_WITH_CURRENCY:
58
- return /* @__PURE__ */ e("span", { children: C(0, n ?? r) });
61
+ return /* @__PURE__ */ r("span", { children: C(0, n ?? e) });
59
62
  case o.DISPLAY_AS_ZERO_WITH_CURRENCY_NO_DECIMAL:
60
- return /* @__PURE__ */ e("span", { children: E(0, n ?? r) });
63
+ return /* @__PURE__ */ r("span", { children: R(0, n ?? e) });
61
64
  case o.CUSTOM:
62
- return /* @__PURE__ */ e("span", { children: a == 0 ? v : "N/A" });
65
+ return /* @__PURE__ */ r("span", { children: a == 0 ? A : "N/A" });
63
66
  default:
64
- return /* @__PURE__ */ e("span", { children: "N/A" });
67
+ return /* @__PURE__ */ r("span", { children: "N/A" });
65
68
  }
66
69
  return /* @__PURE__ */ l("span", { className: "currency-conversion", children: [
67
- u(
70
+ m(
68
71
  a,
69
72
  n,
70
73
  p
71
74
  ),
72
- s && y && /* @__PURE__ */ e(
73
- I,
75
+ t && y && /* @__PURE__ */ r(
76
+ M,
74
77
  {
75
- trigger: /* @__PURE__ */ e("sup", { children: /* @__PURE__ */ e(N, {}) }),
78
+ trigger: /* @__PURE__ */ r("sup", { children: /* @__PURE__ */ r(N, {}) }),
76
79
  position: f,
77
80
  children: /* @__PURE__ */ l("div", { className: "currency-conversion-container", children: [
78
81
  /* @__PURE__ */ l("p", { children: [
79
82
  "Converted from ",
80
- r,
83
+ e,
81
84
  " to ",
82
85
  n
83
86
  ] }),
84
87
  /* @__PURE__ */ l("div", { className: "currency-conversion-amounts", children: [
85
- /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("p", { children: u(i, r, p) }) }),
86
- /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("p", { children: u(
88
+ /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r("p", { children: m(i, e, p) }) }),
89
+ /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r("p", { children: m(
87
90
  a,
88
91
  n,
89
92
  p
90
93
  ) }) }),
91
- /* @__PURE__ */ e("span", { className: "conversion-icon", children: /* @__PURE__ */ e(N, {}) })
94
+ /* @__PURE__ */ r("span", { className: "conversion-icon", children: /* @__PURE__ */ r(N, {}) })
92
95
  ] }),
93
- /* @__PURE__ */ e("div", { className: "currency-conversion-rate", children: /* @__PURE__ */ l("p", { children: [
96
+ /* @__PURE__ */ r("div", { className: "currency-conversion-rate", children: /* @__PURE__ */ l("p", { children: [
94
97
  "Current Rate:",
95
98
  " ",
96
99
  c ? (
97
100
  // only leaving 2 decimal places for the conversion rate is
98
101
  // not enough, can lead to confusion
99
102
  // use Number constructor to strip unnecessary trailing zeros
100
- `${Number((1 / c).toFixed(5))} ${r}`
103
+ `${Number((1 / c).toFixed(5))} ${e}`
101
104
  ) : "N/A",
102
105
  " ",
103
106
  "≈ ",
@@ -109,6 +112,6 @@ const M = 1e3 * 60 * 60, z = ({
109
112
  ] });
110
113
  };
111
114
  export {
112
- z as CashValue,
113
- M as CurrencyCallStaleTimeMs
115
+ G as CashValue,
116
+ O as CurrencyCallStaleTimeMs
114
117
  };
@@ -1,5 +1,5 @@
1
1
  import "../../arrayExtensions-DlcBOj5a.js";
2
- import { c as M } from "../../cashUtils-DJFSvWw5.js";
2
+ import { c as M } from "../../cashUtils-DB_r0g-F.js";
3
3
  import { e as P, A as l, E as N } from "../../noRetryInstance-DKhe8ju0.js";
4
4
  import { a as o } from "../../_styles.flight-booking-CaUgKcMC.js";
5
5
  import { useState as f, useCallback as I, useEffect as h } from "react";
@@ -38,6 +38,10 @@ export interface ICashValueProps {
38
38
  * Defaults to true, but can be set to false to hide it.
39
39
  */
40
40
  showConversion?: boolean;
41
+ /**
42
+ * Whether to show the original amount and currency
43
+ */
44
+ showOriginal?: boolean;
41
45
  }
42
46
  export declare const CurrencyCallStaleTimeMs: number;
43
47
  /**
@@ -47,4 +51,4 @@ export declare const CurrencyCallStaleTimeMs: number;
47
51
  * If the original currency differs from the user's currency, it shows a conversion
48
52
  * tooltip with details about the conversion rate and original amount.
49
53
  */
50
- export declare const CashValue: ({ amount, currency, position, zeroDisplayOption, customDisplay, decimalPlaces, showConversion }: ICashValueProps) => import("react/jsx-runtime").JSX.Element;
54
+ export declare const CashValue: ({ amount, currency, position, zeroDisplayOption, customDisplay, decimalPlaces, showConversion, showOriginal }: ICashValueProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,7 @@ import { StoryObj } from '@storybook/react';
2
2
  import { EInvalidAmountDisplayOption, EToolTipPosition } from './CashValueTypes';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: ({ amount, currency, position, zeroDisplayOption, customDisplay, decimalPlaces, showConversion }: import('./CashValue').ICashValueProps) => import("react/jsx-runtime").JSX.Element;
5
+ component: ({ amount, currency, position, zeroDisplayOption, customDisplay, decimalPlaces, showConversion, showOriginal }: import('./CashValue').ICashValueProps) => import("react/jsx-runtime").JSX.Element;
6
6
  parameters: {
7
7
  layout: string;
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-core",
3
- "version": "0.9.30",
3
+ "version": "0.9.31",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"