@tesouro/embedded-components-react 0.4.18 → 0.4.20

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.
Files changed (29) hide show
  1. package/dist/index.css +11 -0
  2. package/dist/index.d.ts +4 -1
  3. package/dist/lib/ReceivablesWidget.d.ts +4 -1
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +23 -14
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +49 -50
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +0 -1
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +254 -250
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +71 -65
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +5 -9
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +3 -4
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +11 -11
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +4 -4
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +1 -2
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +1 -6
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +3 -4
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index17.js +3 -2
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index29.js +1 -0
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index30.js +142 -137
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index47.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index49.js +2 -2
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index60.js +1 -0
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index61.js +52 -47
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +89 -86
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +59 -57
  25. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/index.js +1 -0
  26. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/user/useOrganizationUserNames.js +6 -0
  28. package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/amountOutputToMajorUnits.js +14 -6
  29. package/package.json +1 -1
@@ -5,74 +5,76 @@
5
5
  import { extractApiErrorMessage as e } from "../../../shared/util/dist/lib/apiErrors.js";
6
6
  import { defaultPaymentValues as t, defaultSendValues as n, fromMajorUnits as r, hasPaymentErrors as i, hasSendErrors as a, splitEmailList as o, validatePaymentValues as s, validateSendValues as c } from "./index5.js";
7
7
  import { useSendReceivableEmailMutation as l } from "../../data-access/dist/index3.js";
8
- import { useAcceptReceivableMutation as ee, useCancelReceivableMutation as u, useCloneReceivableMutation as d, useDeclineReceivableMutation as f, useDeleteReceivableMutation as p, useIssueReceivableMutation as m } from "../../data-access/dist/index4.js";
9
- import { useMarkReceivablePaidMutation as h, useMarkReceivablePartiallyPaidMutation as g, useMarkReceivableUncollectibleMutation as _ } from "../../data-access/dist/index5.js";
8
+ import { useAcceptReceivableMutation as ee, useCancelReceivableMutation as te, useCloneReceivableMutation as u, useDeclineReceivableMutation as d, useDeleteReceivableMutation as f, useIssueReceivableMutation as p } from "../../data-access/dist/index4.js";
9
+ import { useMarkReceivablePaidMutation as m, useMarkReceivablePartiallyPaidMutation as h, useMarkReceivableUncollectibleMutation as g } from "../../data-access/dist/index5.js";
10
10
  import "../../data-access/dist/index.js";
11
- import { useCallback as v, useState as y } from "react";
11
+ import { useCallback as _, useState as v } from "react";
12
12
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js
13
- function b({ selectedReceivable: b, messages: S, onCreated: C, onDeleted: w }) {
14
- let T = m(), E = u(), D = d(), O = ee(), k = f(), A = p(), j = l(), M = h(), N = g(), P = _(), [F, I] = y(), [te, L] = y(), [R, z] = y(), [B, V] = y(() => n(void 0, S)), [H, U] = y({}), [W, G] = y(), [K, q] = y(() => t()), [J, Y] = y({}), X = v((e, r, i) => {
13
+ function y({ selectedReceivable: y, messages: x, onCreated: S, onDeleted: C }) {
14
+ let w = p(), T = te(), E = u(), D = ee(), O = d(), k = f(), A = l(), j = m(), M = h(), N = g(), [P, F] = v(), [I, L] = v(), [R, z] = v(), [B, V] = v(() => n(void 0, x)), [H, U] = v({}), [W, G] = v(), [K, q] = v(() => t()), [J, Y] = v({}), X = _((e, r, i) => {
15
15
  let a = "documentLabel" in r ? r.documentLabel : r.title, o = {
16
16
  id: r.id,
17
17
  type: r.type,
18
18
  title: a,
19
19
  action: e
20
- };
20
+ }, s = i === void 0 ? y : i ?? void 0;
21
21
  if (e === "send") {
22
- let e = i === void 0 ? b : i ?? void 0;
23
- z(o), V(n(e, S)), U({});
22
+ z(o), V(n(s, x)), U({});
24
23
  return;
25
24
  }
26
25
  if (e === "recordPayment") {
27
- G(o), q(t()), Y({});
26
+ G({
27
+ ...o,
28
+ currency: s?.currency
29
+ }), q(t()), Y({});
28
30
  return;
29
31
  }
30
- L(void 0), I(o);
31
- }, [S, b]), Z = v(() => {
32
- I(void 0), L(void 0);
33
- }, []), Q = v(() => {
32
+ L(void 0), F(o);
33
+ }, [x, y]), Z = _(() => {
34
+ F(void 0), L(void 0);
35
+ }, []), Q = _(() => {
34
36
  z(void 0), U({});
35
- }, []), $ = v(() => {
37
+ }, []), $ = _(() => {
36
38
  G(void 0), Y({});
37
- }, []), ne = v(async () => {
38
- if (!F) return;
39
- let t = { receivable_id: F.id };
39
+ }, []), ne = _(async () => {
40
+ if (!P) return;
41
+ let t = { receivable_id: P.id };
40
42
  try {
41
- if (F.action === "issue") await T.mutateAsync({ path: t });
42
- else if (F.action === "cancel") await E.mutateAsync({ path: t });
43
- else if (F.action === "clone") {
44
- let e = await D.mutateAsync({ path: t });
45
- e?.id && C?.(e.id, e.type);
46
- } else F.action === "accept" ? await O.mutateAsync({ path: t }) : F.action === "decline" ? await k.mutateAsync({ path: t }) : F.action === "delete" ? (await A.mutateAsync({ path: t }), w?.(F.id)) : F.action === "markPaid" ? await M.mutateAsync({
43
+ if (P.action === "issue") await w.mutateAsync({ path: t });
44
+ else if (P.action === "cancel") await T.mutateAsync({ path: t });
45
+ else if (P.action === "clone") {
46
+ let e = await E.mutateAsync({ path: t });
47
+ e?.id && S?.(e.id, e.type);
48
+ } else P.action === "accept" ? await D.mutateAsync({ path: t }) : P.action === "decline" ? await O.mutateAsync({ path: t }) : P.action === "delete" ? (await k.mutateAsync({ path: t }), C?.(P.id)) : P.action === "markPaid" ? await j.mutateAsync({
47
49
  path: t,
48
50
  body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
49
- }) : F.action === "markUncollectible" && await P.mutateAsync({ path: t });
50
- I(void 0), L(void 0);
51
+ }) : P.action === "markUncollectible" && await N.mutateAsync({ path: t });
52
+ F(void 0), L(void 0);
51
53
  } catch (t) {
52
- L(e(t) ?? S.genericError);
54
+ L(e(t) ?? x.genericError);
53
55
  }
54
56
  }, [
55
- O,
56
- F,
57
- E,
58
57
  D,
59
- k,
60
- A,
58
+ P,
61
59
  T,
62
- M,
63
- S.genericError,
64
- C,
60
+ E,
61
+ O,
62
+ k,
65
63
  w,
66
- P
67
- ]), re = v(async () => {
64
+ j,
65
+ x.genericError,
66
+ S,
67
+ C,
68
+ N
69
+ ]), re = _(async () => {
68
70
  if (!R) return;
69
- let t = c(B, S);
71
+ let t = c(B, x);
70
72
  if (a(t)) {
71
73
  U(t);
72
74
  return;
73
75
  }
74
76
  try {
75
- await j.mutateAsync({
77
+ await A.mutateAsync({
76
78
  path: { receivable_id: R.id },
77
79
  body: {
78
80
  body_text: B.body,
@@ -85,72 +87,72 @@ function b({ selectedReceivable: b, messages: S, onCreated: C, onDeleted: w }) {
85
87
  }
86
88
  }), Q();
87
89
  } catch (t) {
88
- U({ form: e(t) ?? S.genericError });
90
+ U({ form: e(t) ?? x.genericError });
89
91
  }
90
92
  }, [
91
93
  Q,
92
- S,
93
- j,
94
+ x,
95
+ A,
94
96
  R,
95
97
  B
96
- ]), ie = v(async () => {
98
+ ]), ie = _(async () => {
97
99
  if (!W) return;
98
- let t = s(K, S);
100
+ let t = s(K, x, W.currency);
99
101
  if (i(t)) {
100
102
  Y(t);
101
103
  return;
102
104
  }
103
105
  try {
104
106
  let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
105
- K.mode === "full" ? await M.mutateAsync({
107
+ K.mode === "full" ? await j.mutateAsync({
106
108
  path: e,
107
109
  body: {
108
110
  comment: K.comment || void 0,
109
111
  paid_at: t
110
112
  }
111
- }) : await N.mutateAsync({
113
+ }) : await M.mutateAsync({
112
114
  path: e,
113
115
  body: {
114
- amount_paid: r(K.amountPaid) ?? 0,
116
+ amount_paid: r(K.amountPaid, W.currency) ?? 0,
115
117
  comment: K.comment || void 0
116
118
  }
117
119
  }), $();
118
120
  } catch (t) {
119
- Y({ form: e(t) ?? S.genericError });
121
+ Y({ form: e(t) ?? x.genericError });
120
122
  }
121
123
  }, [
122
124
  $,
125
+ j,
126
+ x,
123
127
  M,
124
- S,
125
- N,
126
128
  W,
127
129
  K
128
130
  ]);
129
131
  return {
130
- actionTarget: F,
131
- actionDialog: F ? x(F.action, S) : void 0,
132
- actionError: te,
133
- actionInProgress: T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || A.isPending || M.isPending || P.isPending,
132
+ actionTarget: P,
133
+ actionDialog: P ? b(P.action, x) : void 0,
134
+ actionError: I,
135
+ actionInProgress: w.isPending || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || j.isPending || N.isPending,
134
136
  openAction: X,
135
137
  closeAction: Z,
136
138
  confirmAction: ne,
137
139
  sendOpen: !!R,
138
140
  sendValues: B,
139
141
  sendErrors: H,
140
- sendInProgress: j.isPending,
142
+ sendInProgress: A.isPending,
141
143
  setSendValues: V,
142
144
  closeSend: Q,
143
145
  submitSend: re,
144
146
  paymentOpen: !!W,
145
147
  paymentValues: K,
146
148
  paymentErrors: J,
147
- paymentInProgress: M.isPending || N.isPending,
149
+ paymentInProgress: j.isPending || M.isPending,
148
150
  setPaymentValues: q,
149
151
  closePayment: $,
150
152
  submitPayment: ie
151
153
  };
152
154
  }
153
- function x(e, t) {
155
+ function b(e, t) {
154
156
  return e === "issue" ? {
155
157
  title: t.issueTitle,
156
158
  description: t.issueDescription,
@@ -190,4 +192,4 @@ function x(e, t) {
190
192
  };
191
193
  }
192
194
  //#endregion
193
- export { b as useReceivableActions };
195
+ export { y as useReceivableActions };
@@ -14,6 +14,7 @@ import { RefreshingRootWidgetProvider as m } from "./lib/WidgetProvider/Refreshi
14
14
  import { useDisclosuresAcceptanceSurface as h, useOwnWidgetConfig as g, useRefetchWidget as _, useWidgetConfig as v, useWidgetError as y, useWidgetInitStaleForToken as b, useWidgetLoading as x } from "./lib/WidgetProvider/hooks.js";
15
15
  import "./lib/WidgetProvider/index.js";
16
16
  import { getNaicsOptions as S } from "./lib/naicsCodeMap.js";
17
+ import "./lib/user/useOrganizationUserNames.js";
17
18
  import { CardProgram as C } from "./lib/card/cardProgram.js";
18
19
  import { CARD_STATUS_LABELS_EN as w, CARD_STATUS_TONE as T, CARD_TYPE_LABELS_EN as E } from "./lib/card/cardPresentation.js";
19
20
  import "./lib/analytics/index.js";
@@ -1,5 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.4.18", n = "b01c006f303ce2012b566b3a60e1072eaabfcb51", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.4.20", n = "e680bd5b652b943a74f77e84710ec84dda3c4568", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import "../../../../data-access/dist/index.js";
6
+ import "react";
@@ -20,15 +20,23 @@ var e = [
20
20
  function t(t) {
21
21
  return e.includes(t);
22
22
  }
23
- function n(e) {
24
- return t(e) ? 0 : 2;
25
- }
23
+ var n = /* @__PURE__ */ new Map();
26
24
  function r(e) {
27
- return n(e);
25
+ let r = e.toUpperCase(), i = n.get(r);
26
+ if (i !== void 0) return i;
27
+ let a = 2;
28
+ if (t(r)) a = 0;
29
+ else try {
30
+ a = new Intl.NumberFormat("en-US", {
31
+ style: "currency",
32
+ currency: r
33
+ }).resolvedOptions().maximumFractionDigits ?? 2;
34
+ } catch {}
35
+ return n.set(r, a), a;
28
36
  }
29
37
  function i(e) {
30
- let t = n(e.currencyCode || "USD");
31
- return Number(e.value) / 10 ** t;
38
+ let t = e.currencyCode || "USD";
39
+ return Number(e.value) / 10 ** r(t);
32
40
  }
33
41
  //#endregion
34
42
  export { e as ZERO_DECIMAL_CURRENCY_CODES, i as amountOutputToMajorUnits, t as isZeroDecimalCurrencyCode, r as minorExponentForCurrency };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.4.18",
3
+ "version": "0.4.20",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {