@afosto/checkout-ui 0.0.18 → 0.0.19

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
- {"version":3,"file":"CheckoutAgreementOptionCondition.d.ts","sourceRoot":"","sources":["../../src/CheckoutAgreementOptionCondition/CheckoutAgreementOptionCondition.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oCAAoC,EACpC,WAAW,EACZ,MAAM,UAAU,CAAC;AAOlB,QAAA,MAAM,mBAAmB;;;;CAIxB,CAAC;AAEF,MAAM,WAAW,qCAAqC;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,oCAAoC,CAAC;IAChD,YAAY,CAAC,EAAE,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;CACxD;AAED,eAAO,MAAM,gCAAgC,GAC3C,OAAO,qCAAqC,qDA2E7C,CAAC"}
1
+ {"version":3,"file":"CheckoutAgreementOptionCondition.d.ts","sourceRoot":"","sources":["../../src/CheckoutAgreementOptionCondition/CheckoutAgreementOptionCondition.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oCAAoC,EACpC,WAAW,EACZ,MAAM,UAAU,CAAC;AAOlB,QAAA,MAAM,mBAAmB;;;;CAIxB,CAAC;AAEF,MAAM,WAAW,qCAAqC;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,oCAAoC,CAAC;IAChD,YAAY,CAAC,EAAE,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;CACxD;AAED,eAAO,MAAM,gCAAgC,GAC3C,OAAO,qCAAqC,qDA+E7C,CAAC"}
@@ -1,28 +1,32 @@
1
1
  import { jsxs as s, jsx as i } from "react/jsx-runtime";
2
2
  import { Box as m, Typography as c } from "@afosto/components";
3
- import { TurnDownRightSolid as g } from "../icons/TurnDownRightSolid.js";
4
- import { CheckoutCurrency as C } from "../CheckoutCurrency/CheckoutCurrency.js";
5
- import { camelize as D } from "@afosto/utils";
6
- import { useCheckout as x } from "../CheckoutStateProvider/CheckoutStateProvider.js";
7
- import { formatCurrency as v } from "../utils/formatCurrency.js";
8
- const w = {
3
+ import { TurnDownRightSolid as C } from "../icons/TurnDownRightSolid.js";
4
+ import { CheckoutCurrency as D } from "../CheckoutCurrency/CheckoutCurrency.js";
5
+ import { camelize as x } from "@afosto/utils";
6
+ import { useCheckout as v } from "../CheckoutStateProvider/CheckoutStateProvider.js";
7
+ import { formatCurrency as w } from "../utils/formatCurrency.js";
8
+ const I = {
9
9
  payImmediately: "Pay immediately",
10
10
  remainingAmountDueBeforeDelivery: "Remaining amount due before delivery",
11
11
  withinDaysOfTheInvoiceDate: "Within {days} days of the invoice date"
12
- }, b = (l) => {
12
+ }, j = (l) => {
13
13
  const {
14
14
  condition: e,
15
- currency: a,
16
- locale: r,
15
+ currency: r,
16
+ locale: a,
17
17
  translations: y = {}
18
- } = l, { settings: u, translations: p } = x(), { currency: d } = u || {}, n = {
19
- ...w,
20
- ...p.agreementOptionConditions || {},
18
+ } = l, {
19
+ settings: u,
20
+ summary: p,
21
+ translations: d
22
+ } = v(), f = p?.currency || u?.currency, n = {
23
+ ...I,
24
+ ...d.agreementOptionConditions || {},
21
25
  ...y || {}
22
- }, o = D(e.type?.toLowerCase() || ""), f = e.outcome?.amount || 0;
26
+ }, o = x(e.type?.toLowerCase() || ""), h = e.outcome?.amount || 0;
23
27
  let t = e.type;
24
- return o === "downPayment" && e.isPercentage && (t = `${n.payImmediately}${e.amount > 0 && e.amount < 100 ? ` (${e.amount}%)` : ""}`), o === "downPayment" && !e.isPercentage && (t = `${n.payImmediately}${e.amount > 0 ? ` (${v(e.amount / 100, r, {
25
- currency: a || d
28
+ return o === "downPayment" && e.isPercentage && (t = `${n.payImmediately}${e.amount > 0 && e.amount < 100 ? ` (${e.amount}%)` : ""}`), o === "downPayment" && !e.isPercentage && (t = `${n.payImmediately}${e.amount > 0 ? ` (${w(e.amount / 100, a, {
29
+ currency: r || f
26
30
  })})` : ""}`), o === "postPaid" && (t = n.withinDaysOfTheInvoiceDate.replace(
27
31
  "{days}",
28
32
  e.pastDueAfter.toString()
@@ -38,19 +42,19 @@ const w = {
38
42
  children: [
39
43
  /* @__PURE__ */ s(m, { sx: { display: "flex", alignItems: "center", gap: 2.5 }, children: [
40
44
  /* @__PURE__ */ i(
41
- g,
45
+ C,
42
46
  {
43
- sx: { color: (h) => h.palette.gray[400], fontSize: 16 }
47
+ sx: { color: (g) => g.palette.gray[400], fontSize: 16 }
44
48
  }
45
49
  ),
46
50
  /* @__PURE__ */ i(c, { children: t })
47
51
  ] }),
48
52
  /* @__PURE__ */ i(c, { fontWeight: 500, children: /* @__PURE__ */ i(
49
- C,
53
+ D,
50
54
  {
51
- currency: a,
52
- locale: r,
53
- value: f / 100
55
+ currency: r,
56
+ locale: a,
57
+ value: h / 100
54
58
  }
55
59
  ) })
56
60
  ]
@@ -58,5 +62,5 @@ const w = {
58
62
  );
59
63
  };
60
64
  export {
61
- b as CheckoutAgreementOptionCondition
65
+ j as CheckoutAgreementOptionCondition
62
66
  };
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutCurrency.d.ts","sourceRoot":"","sources":["../../src/CheckoutCurrency/CheckoutCurrency.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;CACpC;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,WAoB5D,CAAC"}
1
+ {"version":3,"file":"CheckoutCurrency.d.ts","sourceRoot":"","sources":["../../src/CheckoutCurrency/CheckoutCurrency.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;CACpC;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,WAqB5D,CAAC"}
@@ -1,18 +1,18 @@
1
- import { useCheckout as y } from "../CheckoutStateProvider/CheckoutStateProvider.js";
2
- const m = (c) => {
1
+ import { useCheckout as m } from "../CheckoutStateProvider/CheckoutStateProvider.js";
2
+ const p = (e) => {
3
3
  const {
4
- currency: e,
5
- value: o,
6
- locale: r,
4
+ currency: c,
5
+ value: r,
6
+ locale: o,
7
7
  options: t
8
- } = c, { locale: n, settings: u } = y(), { currency: l } = u || {}, s = {
8
+ } = e, { locale: n, settings: u, summary: s } = m(), { currency: l } = u || {}, a = {
9
9
  style: "currency",
10
- currency: e || l || "EUR"
11
- }, a = r || n;
12
- return new Intl.NumberFormat(a, t || s).format(
13
- o
10
+ currency: c || s?.currency || l || "EUR"
11
+ }, y = o || n;
12
+ return new Intl.NumberFormat(y, t || a).format(
13
+ r
14
14
  );
15
15
  };
16
16
  export {
17
- m as CheckoutCurrency
17
+ p as CheckoutCurrency
18
18
  };
@@ -9,22 +9,22 @@ const P = {
9
9
  const {
10
10
  agreementTemplate: n,
11
11
  agreements: s,
12
- currency: t,
12
+ currency: r,
13
13
  disablePadding: u = !0,
14
14
  divider: c = !1,
15
15
  hideDefaultAgreementOption: i = !0,
16
- locale: r,
16
+ locale: o,
17
17
  translations: l = {},
18
18
  ...p
19
19
  } = m, {
20
- settings: d,
21
- summary: o,
22
- translations: y
23
- } = v(), { currency: f } = d || {}, h = {
20
+ settings: y,
21
+ summary: t,
22
+ translations: d
23
+ } = v(), f = t?.currency || y?.currency, h = {
24
24
  ...P,
25
- ...y?.summary || {},
25
+ ...d?.summary || {},
26
26
  ...l || {}
27
- }, g = n ?? o?.agreementTemplate, k = s || o?.agreements || [];
27
+ }, g = n ?? t?.agreementTemplate, k = s || t?.agreements || [];
28
28
  return i && g?.type?.toLowerCase() === "default" ? null : /* @__PURE__ */ a(
29
29
  C,
30
30
  {
@@ -34,10 +34,10 @@ const P = {
34
34
  children: k.map((e) => /* @__PURE__ */ a(
35
35
  T,
36
36
  {
37
- currency: t,
38
- locale: r,
39
- description: `${h.payImmediately} (${e.isPercentage ? `${e.amount}%` : A(e.amount / 100, r, {
40
- currency: t || f
37
+ currency: r,
38
+ locale: o,
39
+ description: `${h.payImmediately} (${e.isPercentage ? `${e.amount}%` : A(e.amount / 100, o, {
40
+ currency: r || f
41
41
  })})`,
42
42
  value: e.outcome?.amount || 0
43
43
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afosto/checkout-ui",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Afosto react checkout ui components",
5
5
  "author": "Afosto",
6
6
  "license": "MIT",