@tesouro/embedded-components-react 0.5.2 → 0.5.4

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 (113) hide show
  1. package/README.md +15 -2
  2. package/dist/index.d.ts +120 -100
  3. package/dist/index.js +7 -4
  4. package/dist/lib/BankAccountOnboardingWidget.d.ts +214 -246
  5. package/dist/lib/BillPayWidget.js +1 -1
  6. package/dist/lib/MarketingWidget.d.ts +684 -0
  7. package/dist/lib/MarketingWidget.js +4 -0
  8. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/data-access/dist/index.js +9 -8
  9. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index16.js +0 -2
  10. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index18.js +183 -205
  11. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index.js +1 -4
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +13 -13
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +70 -5
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +37 -64
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +110 -38
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +73 -104
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +7 -87
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +21 -7
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +22 -17
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +63 -23
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +2 -66
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +81 -2
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +3 -78
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +5 -4
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +4 -5
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +32 -3
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +39 -30
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +166 -37
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +39 -164
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +1 -48
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +50 -1
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +11 -45
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +8 -13
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +14 -8
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +59 -7
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +8 -64
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +24 -8
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +139 -18
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +16 -139
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +4 -24
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +41 -4
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +14 -39
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +8 -16
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +91 -8
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +86 -80
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +3 -97
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +49 -3
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +135 -47
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +33 -135
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +186 -33
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +75 -186
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +21 -75
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +25 -14
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +232 -22
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +210 -223
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +103 -202
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +13 -121
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +47 -12
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +31 -47
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +198 -27
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +31 -198
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +234 -31
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +19 -240
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +24 -25
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +427 -19
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +4 -433
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +38 -4
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +220 -35
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +3 -224
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +4 -3
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +44 -2
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +1 -46
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -1
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +10 -6
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +57 -21
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +110 -10
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -112
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +127 -3
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +8 -124
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +7 -8
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +46 -8
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +18 -43
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +28 -20
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +82 -27
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +47 -83
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +5 -58
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +250 -47
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +101 -239
  89. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +202 -107
  90. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +3 -209
  91. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +8 -4
  92. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +113 -6
  93. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +1 -115
  94. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +24 -0
  95. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +4 -5
  96. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index.js +3 -0
  97. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index2.js +8 -0
  98. package/dist/libs/tesouro-embedded-components-react/{bank-account-onboarding-widget/ui/dist/index26.js → marketing-widget/feature/dist/index3.js} +1 -1
  99. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index4.js +81 -0
  100. package/dist/libs/tesouro-embedded-components-react/marketing-widget/ui/dist/index.js +4 -0
  101. package/dist/libs/tesouro-embedded-components-react/{bank-account-onboarding-widget/ui/dist/index24.js → marketing-widget/ui/dist/index2.js} +1 -1
  102. package/dist/libs/tesouro-embedded-components-react/{bank-account-onboarding-widget/ui/dist/index25.js → marketing-widget/ui/dist/index3.js} +1 -1
  103. package/dist/libs/tesouro-embedded-components-react/{bank-account-onboarding-widget/ui/dist/index27.js → marketing-widget/ui/dist/index4.js} +36 -37
  104. package/dist/libs/tesouro-embedded-components-react/marketing-widget/ui/dist/index5.js +75 -0
  105. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +24 -22
  106. package/dist/libs/tesouro-embedded-components-react/{bank-account-onboarding-widget/data-access/dist/index9.js → shared/data-access/dist/lib/onboardingSuppressionReason.js} +1 -1
  107. package/dist/libs/tesouro-embedded-components-react/{bank-account-onboarding-widget/data-access/dist/index10.js → shared/data-access/dist/lib/useOrganizationOnboardingSuppression.js} +5 -6
  108. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/isDisclosuresAcceptanceRequired.js +1 -0
  109. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  110. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  111. package/package.json +1 -1
  112. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index28.js +0 -75
  113. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +0 -25
@@ -1,39 +1,242 @@
1
- import { resolveLineItemAmountMinorUnits as e } from "./index41.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index47.js";
6
+ import { calculateTotal as t, displayLineAmount as n, parseMoneyToMinorUnits as r, parseQuantity as i } from "./index54.js";
7
+ import { validateBillTotals as a } from "./index55.js";
8
+ import { emptyLineItem as o, mapPayableToBillForm as s } from "./index57.js";
9
+ import { useCallback as c, useEffect as l, useMemo as u, useRef as ee, useState as d } from "react";
2
10
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js
3
- function t() {
4
- return {
5
- id: crypto.randomUUID(),
6
- description: "",
7
- glCode: "",
8
- quantity: "1",
9
- price: "",
10
- amount: ""
11
+ var f = /^[0-9.,-]+$/;
12
+ function p(e) {
13
+ let t = e.trim().replace(/^\$\s*/, "");
14
+ return t ? f.test(t) ? t : null : "";
15
+ }
16
+ var m = [
17
+ "quantity",
18
+ "price",
19
+ "amount"
20
+ ];
21
+ function h(e) {
22
+ let t = e.trim(), n = /[.,]$/.test(t) ? t.slice(0, -1) : t;
23
+ return t && !n ? null : n;
24
+ }
25
+ function g(e, t, n) {
26
+ if (t === void 0) return;
27
+ let r = h(t);
28
+ if (r !== null) return a(e === "discount" ? r : "", e === "tax" ? r : "", e === "total" ? r : void 0, n)?.[e];
29
+ }
30
+ function _(e, t) {
31
+ let n = {}, a = {
32
+ price: null,
33
+ amount: null
11
34
  };
35
+ for (let i of ["price", "amount"]) {
36
+ let o = h(e[i]);
37
+ o !== null && (a[i] = r(o), o && a[i] === null && (n[i] = t.unreadableMoney));
38
+ }
39
+ let o = h(e.quantity);
40
+ if (o !== null) {
41
+ let e = a.price !== null || a.amount !== null;
42
+ i(o) === null && (o || e) && (n.quantity = t.unusableQuantity);
43
+ }
44
+ return n;
12
45
  }
13
- function n(e) {
14
- return typeof e == "number" ? (e / 100).toFixed(2) : "";
46
+ function v(e, t, i) {
47
+ return r(t) === null ? i : n(e, t);
15
48
  }
16
- function r({ payable: r, lineItems: i }) {
17
- let a = {
18
- invoiceNumber: r.document_id ?? "",
19
- invoiceDate: r.issued_at ?? "",
20
- dueDate: r.due_date ?? "",
21
- poNumber: ""
22
- }, o = i.map((t) => ({
23
- id: t.id,
24
- description: t.name ?? "",
25
- glCode: t.ledger_account_id ?? "",
26
- quantity: t.quantity == null ? "" : String(t.quantity),
27
- price: n(t.unit_price),
28
- amount: n(e(t))
29
- })), s = r.amount_due ?? (r.total_amount == null ? void 0 : r.total_amount - (r.discount ?? 0));
49
+ function y({ payable: n, lineItems: r, labels: i = e } = {}) {
50
+ let a = u(() => s({
51
+ payable: n ?? {},
52
+ lineItems: r ?? []
53
+ }), [n, r]), [f, h] = d(a.values), [y, b] = d(a.lineItems), [x, S] = d(a.discount), [C, w] = d(a.tax), [T, E] = d(a.total || void 0), [te, D] = d(), O = ee(void 0), k = c((e) => {
54
+ D((t) => {
55
+ let n = typeof e == "function" ? e(t) : e;
56
+ return n?.form !== O.current && (O.current = void 0), n;
57
+ });
58
+ }, []), A = c((e) => {
59
+ O.current = e, D((t) => ({
60
+ ...t,
61
+ form: e
62
+ }));
63
+ }, []), j = c(() => {
64
+ D((e) => {
65
+ if (!e?.form || e.form !== O.current) return e;
66
+ O.current = void 0;
67
+ let { form: t, ...n } = e;
68
+ return Object.keys(n).length ? n : void 0;
69
+ });
70
+ }, []), [M, N] = d(), [P, F] = d(), [I, L] = d(!1), [R, z] = d(!1), [B, V] = d(!1);
71
+ l(() => {
72
+ I || h(a.values);
73
+ }, [a]), l(() => {
74
+ R || b(a.lineItems);
75
+ }, [a]), l(() => {
76
+ B || (S(a.discount), w(a.tax), E(a.total || void 0));
77
+ }, [a]);
78
+ let H = c((e) => {
79
+ h((t) => ({
80
+ ...t,
81
+ ...e
82
+ })), L(!0), D((t) => {
83
+ if (!t) return t;
84
+ let n = { ...t };
85
+ for (let t of Object.keys(e)) delete n[t];
86
+ return Object.keys(n).length ? n : void 0;
87
+ }), j();
88
+ }, [j]), U = c((e, t) => {
89
+ N((n) => {
90
+ if (!n?.[e] && !t) return n;
91
+ let r = {
92
+ ...n,
93
+ [e]: t
94
+ };
95
+ return t || delete r[e], Object.keys(r).length ? r : void 0;
96
+ });
97
+ }, []), W = c((e, t) => {
98
+ U(e, g(e, t, i));
99
+ }, [i, U]), G = c(() => {
100
+ E(void 0), W("total", void 0), j();
101
+ }, [W, j]), K = c((e, t = []) => {
102
+ let n = _(e, i);
103
+ F((r) => {
104
+ let i = r?.[e.id], a = { ...i };
105
+ for (let e of [
106
+ "price",
107
+ "amount",
108
+ "quantity"
109
+ ]) n[e] ? a[e] = n[e] : delete a[e];
110
+ t.includes("description") && delete a.description;
111
+ let o = Object.keys(a).length > 0;
112
+ if (!i && !o) return r;
113
+ let s = { ...r };
114
+ return o ? s[e.id] = a : delete s[e.id], Object.keys(s).length ? s : void 0;
115
+ });
116
+ }, [i]), q = c((e, t, n) => {
117
+ F((r) => ({
118
+ ...r,
119
+ [e]: {
120
+ ...r?.[e],
121
+ [t]: n
122
+ }
123
+ }));
124
+ }, []), J = c((e, t, n = []) => {
125
+ let r = y.find((t) => t.id === e);
126
+ if (!r) return;
127
+ let i = t(r);
128
+ b(y.map((t) => t.id === e ? i : t)), K(i, n), z(!0), G();
129
+ }, [
130
+ G,
131
+ y,
132
+ K
133
+ ]), Y = c((e, t) => {
134
+ let n = { ...t };
135
+ for (let r of m) {
136
+ let a = t[r];
137
+ if (a === void 0) continue;
138
+ let o = p(a);
139
+ if (o === null) {
140
+ q(e, r, i.numbersOnly);
141
+ return;
142
+ }
143
+ n[r] = o;
144
+ }
145
+ J(e, (e) => {
146
+ let t = {
147
+ ...e,
148
+ ...n
149
+ };
150
+ return "amount" in n ? t : {
151
+ ...t,
152
+ amount: v(t.quantity, t.price, t.amount)
153
+ };
154
+ }, Object.keys(n));
155
+ }, [
156
+ J,
157
+ i,
158
+ q
159
+ ]), X = c((e, t) => {
160
+ J(e, (e) => {
161
+ let n = Number.parseFloat(e.quantity), r = String(Math.max(1, (Number.isFinite(n) ? n : 1) + t));
162
+ return {
163
+ ...e,
164
+ quantity: r,
165
+ amount: v(r, e.price, e.amount)
166
+ };
167
+ });
168
+ }, [J]), Z = c((e) => {
169
+ F((t) => {
170
+ if (!t?.[e]) return t;
171
+ let n = { ...t };
172
+ return delete n[e], Object.keys(n).length ? n : void 0;
173
+ });
174
+ }, []), Q = c((e) => {
175
+ Z(e), b((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), z(!0), G();
176
+ }, [Z, G]), ne = c(() => {
177
+ b((e) => [...e, o()]), z(!0), G();
178
+ }, [G]), $ = c((e, t, n) => {
179
+ let r = p(t);
180
+ if (r === null) {
181
+ U(e, i.numbersOnly);
182
+ return;
183
+ }
184
+ n(r), V(!0), G(), W(e, r);
185
+ }, [
186
+ G,
187
+ i,
188
+ W,
189
+ U
190
+ ]), re = c((e) => $("discount", e, S), [$]), ie = c((e) => $("tax", e, w), [$]), ae = c((e) => {
191
+ let t = p(e);
192
+ if (t === null) {
193
+ U("total", i.numbersOnly);
194
+ return;
195
+ }
196
+ E(t), V(!0), W("total", t), j();
197
+ }, [
198
+ j,
199
+ i,
200
+ W,
201
+ U
202
+ ]), oe = u(() => y.map((e) => ({
203
+ ...e,
204
+ onChange: (t) => Y(e.id, t),
205
+ onQuantityStep: (t) => X(e.id, t),
206
+ onRemove: () => Q(e.id)
207
+ })), [
208
+ y,
209
+ Y,
210
+ Q,
211
+ X
212
+ ]), se = u(() => t(y, C, x), [
213
+ y,
214
+ C,
215
+ x
216
+ ]);
30
217
  return {
31
- values: a,
32
- lineItems: o.length ? o : [t()],
33
- discount: n(r.discount),
34
- tax: n(r.tax_amount),
35
- total: s ? n(s) : ""
218
+ values: f,
219
+ errors: te,
220
+ setErrors: k,
221
+ setSaveFailureMessage: A,
222
+ lineItemErrors: P,
223
+ setLineItemErrors: F,
224
+ totalsErrors: M,
225
+ setTotalsErrors: N,
226
+ onChange: H,
227
+ lineItems: y,
228
+ lineItemRows: oe,
229
+ discount: x,
230
+ onDiscountChange: re,
231
+ tax: C,
232
+ onTaxChange: ie,
233
+ total: T ?? se,
234
+ totalOverride: T,
235
+ onTotalChange: ae,
236
+ onAddLineItem: ne,
237
+ isTotalsDirty: B,
238
+ isDirty: I || R || B
36
239
  };
37
240
  }
38
241
  //#endregion
39
- export { t as emptyLineItem, r as mapPayableToBillForm };
242
+ export { y as useBillForm };
@@ -1,242 +1,21 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index48.js";
6
- import { calculateTotal as t, displayLineAmount as n, parseMoneyToMinorUnits as r, parseQuantity as i } from "./index55.js";
7
- import { validateBillTotals as a } from "./index56.js";
8
- import { emptyLineItem as o, mapPayableToBillForm as s } from "./index58.js";
9
- import { useCallback as c, useEffect as l, useMemo as u, useRef as ee, useState as d } from "react";
10
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js
11
- var f = /^[0-9.,-]+$/;
12
- function p(e) {
13
- let t = e.trim().replace(/^\$\s*/, "");
14
- return t ? f.test(t) ? t : null : "";
15
- }
16
- var m = [
17
- "quantity",
18
- "price",
19
- "amount"
20
- ];
21
- function h(e) {
22
- let t = e.trim(), n = /[.,]$/.test(t) ? t.slice(0, -1) : t;
23
- return t && !n ? null : n;
24
- }
25
- function g(e, t, n) {
26
- if (t === void 0) return;
27
- let r = h(t);
28
- if (r !== null) return a(e === "discount" ? r : "", e === "tax" ? r : "", e === "total" ? r : void 0, n)?.[e];
29
- }
30
- function _(e, t) {
31
- let n = {}, a = {
32
- price: null,
33
- amount: null
34
- };
35
- for (let i of ["price", "amount"]) {
36
- let o = h(e[i]);
37
- o !== null && (a[i] = r(o), o && a[i] === null && (n[i] = t.unreadableMoney));
38
- }
39
- let o = h(e.quantity);
40
- if (o !== null) {
41
- let e = a.price !== null || a.amount !== null;
42
- i(o) === null && (o || e) && (n.quantity = t.unusableQuantity);
43
- }
44
- return n;
45
- }
46
- function v(e, t, i) {
47
- return r(t) === null ? i : n(e, t);
48
- }
49
- function y({ payable: n, lineItems: r, labels: i = e } = {}) {
50
- let a = u(() => s({
51
- payable: n ?? {},
52
- lineItems: r ?? []
53
- }), [n, r]), [f, h] = d(a.values), [y, b] = d(a.lineItems), [x, S] = d(a.discount), [C, w] = d(a.tax), [T, E] = d(a.total || void 0), [te, D] = d(), O = ee(void 0), k = c((e) => {
54
- D((t) => {
55
- let n = typeof e == "function" ? e(t) : e;
56
- return n?.form !== O.current && (O.current = void 0), n;
57
- });
58
- }, []), A = c((e) => {
59
- O.current = e, D((t) => ({
60
- ...t,
61
- form: e
62
- }));
63
- }, []), j = c(() => {
64
- D((e) => {
65
- if (!e?.form || e.form !== O.current) return e;
66
- O.current = void 0;
67
- let { form: t, ...n } = e;
68
- return Object.keys(n).length ? n : void 0;
69
- });
70
- }, []), [M, N] = d(), [P, F] = d(), [I, L] = d(!1), [R, z] = d(!1), [B, V] = d(!1);
71
- l(() => {
72
- I || h(a.values);
73
- }, [a]), l(() => {
74
- R || b(a.lineItems);
75
- }, [a]), l(() => {
76
- B || (S(a.discount), w(a.tax), E(a.total || void 0));
77
- }, [a]);
78
- let H = c((e) => {
79
- h((t) => ({
80
- ...t,
81
- ...e
82
- })), L(!0), D((t) => {
83
- if (!t) return t;
84
- let n = { ...t };
85
- for (let t of Object.keys(e)) delete n[t];
86
- return Object.keys(n).length ? n : void 0;
87
- }), j();
88
- }, [j]), U = c((e, t) => {
89
- N((n) => {
90
- if (!n?.[e] && !t) return n;
91
- let r = {
92
- ...n,
93
- [e]: t
94
- };
95
- return t || delete r[e], Object.keys(r).length ? r : void 0;
96
- });
97
- }, []), W = c((e, t) => {
98
- U(e, g(e, t, i));
99
- }, [i, U]), G = c(() => {
100
- E(void 0), W("total", void 0), j();
101
- }, [W, j]), K = c((e, t = []) => {
102
- let n = _(e, i);
103
- F((r) => {
104
- let i = r?.[e.id], a = { ...i };
105
- for (let e of [
106
- "price",
107
- "amount",
108
- "quantity"
109
- ]) n[e] ? a[e] = n[e] : delete a[e];
110
- t.includes("description") && delete a.description;
111
- let o = Object.keys(a).length > 0;
112
- if (!i && !o) return r;
113
- let s = { ...r };
114
- return o ? s[e.id] = a : delete s[e.id], Object.keys(s).length ? s : void 0;
115
- });
116
- }, [i]), q = c((e, t, n) => {
117
- F((r) => ({
118
- ...r,
119
- [e]: {
120
- ...r?.[e],
121
- [t]: n
122
- }
123
- }));
124
- }, []), J = c((e, t, n = []) => {
125
- let r = y.find((t) => t.id === e);
126
- if (!r) return;
127
- let i = t(r);
128
- b(y.map((t) => t.id === e ? i : t)), K(i, n), z(!0), G();
129
- }, [
130
- G,
131
- y,
132
- K
133
- ]), Y = c((e, t) => {
134
- let n = { ...t };
135
- for (let r of m) {
136
- let a = t[r];
137
- if (a === void 0) continue;
138
- let o = p(a);
139
- if (o === null) {
140
- q(e, r, i.numbersOnly);
141
- return;
142
- }
143
- n[r] = o;
144
- }
145
- J(e, (e) => {
146
- let t = {
147
- ...e,
148
- ...n
149
- };
150
- return "amount" in n ? t : {
151
- ...t,
152
- amount: v(t.quantity, t.price, t.amount)
153
- };
154
- }, Object.keys(n));
155
- }, [
156
- J,
157
- i,
158
- q
159
- ]), X = c((e, t) => {
160
- J(e, (e) => {
161
- let n = Number.parseFloat(e.quantity), r = String(Math.max(1, (Number.isFinite(n) ? n : 1) + t));
162
- return {
163
- ...e,
164
- quantity: r,
165
- amount: v(r, e.price, e.amount)
166
- };
167
- });
168
- }, [J]), Z = c((e) => {
169
- F((t) => {
170
- if (!t?.[e]) return t;
171
- let n = { ...t };
172
- return delete n[e], Object.keys(n).length ? n : void 0;
173
- });
174
- }, []), Q = c((e) => {
175
- Z(e), b((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), z(!0), G();
176
- }, [Z, G]), ne = c(() => {
177
- b((e) => [...e, o()]), z(!0), G();
178
- }, [G]), $ = c((e, t, n) => {
179
- let r = p(t);
180
- if (r === null) {
181
- U(e, i.numbersOnly);
182
- return;
183
- }
184
- n(r), V(!0), G(), W(e, r);
185
- }, [
186
- G,
187
- i,
188
- W,
189
- U
190
- ]), re = c((e) => $("discount", e, S), [$]), ie = c((e) => $("tax", e, w), [$]), ae = c((e) => {
191
- let t = p(e);
192
- if (t === null) {
193
- U("total", i.numbersOnly);
194
- return;
195
- }
196
- E(t), V(!0), W("total", t), j();
197
- }, [
198
- j,
199
- i,
200
- W,
201
- U
202
- ]), oe = u(() => y.map((e) => ({
203
- ...e,
204
- onChange: (t) => Y(e.id, t),
205
- onQuantityStep: (t) => X(e.id, t),
206
- onRemove: () => Q(e.id)
207
- })), [
208
- y,
209
- Y,
210
- Q,
211
- X
212
- ]), se = u(() => t(y, C, x), [
213
- y,
214
- C,
215
- x
216
- ]);
217
- return {
218
- values: f,
219
- errors: te,
220
- setErrors: k,
221
- setSaveFailureMessage: A,
222
- lineItemErrors: P,
223
- setLineItemErrors: F,
224
- totalsErrors: M,
225
- setTotalsErrors: N,
226
- onChange: H,
227
- lineItems: y,
228
- lineItemRows: oe,
229
- discount: x,
230
- onDiscountChange: re,
231
- tax: C,
232
- onTaxChange: ie,
233
- total: T ?? se,
234
- totalOverride: T,
235
- onTotalChange: ae,
236
- onAddLineItem: ne,
237
- isTotalsDirty: B,
238
- isDirty: I || R || B
239
- };
240
- }
2
+ var e = {
3
+ dialog: "bill-pay-bill-create-dialog",
4
+ vendorSection: "bill-pay-bill-create-vendor",
5
+ lineItems: "bill-pay-bill-create-line-items",
6
+ documentPanel: "bill-pay-bill-create-document",
7
+ duplicateNotice: "bill-pay-bill-create-duplicate-notice",
8
+ duplicateRemoveDialog: "bill-pay-bill-create-duplicate-remove-dialog",
9
+ duplicateRemoveConfirm: "bill-pay-bill-create-duplicate-remove-confirm",
10
+ decisionDialog: "bill-pay-bill-decision-dialog",
11
+ decisionConfirm: "bill-pay-bill-decision-confirm",
12
+ decisionReason: "bill-pay-bill-decision-reason",
13
+ deleteDraftDialog: "bill-pay-bill-delete-draft-dialog",
14
+ deleteDraftConfirm: "bill-pay-bill-delete-draft-confirm",
15
+ unsavedDialog: "bill-pay-bill-unsaved-dialog",
16
+ unsavedSaveDraft: "bill-pay-bill-unsaved-save-draft",
17
+ unsavedDiscard: "bill-pay-bill-unsaved-discard",
18
+ unsavedClose: "bill-pay-bill-unsaved-close"
19
+ };
241
20
  //#endregion
242
- export { y as useBillForm };
21
+ export { e as billCreateTestIds };
@@ -1,27 +1,26 @@
1
+ import { suspectedPayableDuplicates as e } from "../../data-access/dist/index7.js";
2
+ import "../../data-access/dist/index.js";
1
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js
2
- var e = {
3
- selectRow: ({ vendorLabel: e, invoiceNumberLabel: t, addedOnLabel: n }) => `Select bill — ${e}, invoice ${t}, added ${n}`,
4
- openRow: ({ vendorLabel: e, invoiceNumberLabel: t, addedOnLabel: n }) => `View bill — ${e}, invoice ${t}, added ${n}`,
5
- reviewGroup: ({ vendorLabel: e, count: t }) => `${e} — ${t} possible duplicate bills`,
6
- selectGroup: ({ vendorLabel: e }) => `Select every bill from ${e}`,
7
- deleteBillButton: "Remove this bill",
8
- deleteConfirmTitle: "Remove duplicate bill?",
9
- deleteConfirmDescription: "You can't undo this action.",
10
- deleteConfirmButton: "Remove duplicate bill",
11
- deleteConfirmBackButton: "Cancel",
12
- cancelBillButton: "Cancel this bill",
13
- confirmBillButton: "Confirm duplicate",
14
- cancelConfirmTitle: "Cancel duplicate bill?",
15
- cancelConfirmDescription: "You can't undo this action.",
16
- cancelConfirmButton: "Cancel this bill",
17
- cancelConfirmBackButton: "Back",
18
- deletedToast: "Duplicate removed",
19
- cancelledToast: "Duplicate cancelled",
20
- confirmedToast: "Duplicate confirmed",
21
- dismissedToast: "Marked as “not a duplicate”.",
22
- removedToast: "Duplicate removed",
23
- verdictFailedToast: "Couldn't update this duplicate. Try again.",
24
- allResolvedToast: "All possible duplicates resolved"
25
- };
4
+ function t(t) {
5
+ let n = new Map(t.map((e) => [e.id, e])), r = /* @__PURE__ */ new Map(), i = (e) => {
6
+ let t = r.get(e);
7
+ if (t === void 0 || t === e) return e;
8
+ let n = i(t);
9
+ return r.set(e, n), n;
10
+ }, a = (e, t) => {
11
+ let n = i(e), a = i(t);
12
+ n !== a && r.set(n, a);
13
+ };
14
+ t.forEach((t) => {
15
+ r.set(t.id, r.get(t.id) ?? t.id), e(t).forEach((e) => {
16
+ n.has(e.matched_payable_id) && a(t.id, e.matched_payable_id);
17
+ });
18
+ });
19
+ let o = /* @__PURE__ */ new Map();
20
+ return t.forEach((e) => {
21
+ let t = i(e.id);
22
+ o.set(t, [...o.get(t) ?? [], e]);
23
+ }), [...o.values()].map((e) => ({ members: [...e].sort((e, t) => (e.created_at ?? "").localeCompare(t.created_at ?? "")) }));
24
+ }
26
25
  //#endregion
27
- export { e as DUPLICATE_BILLS_LABELS_EN };
26
+ export { t as groupSuspectedDuplicates };