@tesouro/embedded-components-react 0.5.8 → 0.5.11

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 (35) hide show
  1. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +1 -1
  2. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +4 -78
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +84 -3
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +4 -5
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +5 -4
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +3 -32
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +30 -39
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +37 -166
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +164 -39
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +48 -1
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +1 -50
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +45 -11
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +13 -8
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +8 -14
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +7 -59
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +64 -8
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +8 -24
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +18 -139
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +144 -16
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +24 -4
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +2 -2
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +1 -0
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +4 -3
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +26 -4
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +102 -98
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +91 -84
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +1 -1
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +92 -87
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +1 -1
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +133 -129
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index40.js +3 -3
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index61.js +1 -0
  34. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  35. package/package.json +1 -1
@@ -9,27 +9,27 @@ import { useReplacePayableLineItemsMutation as n } from "../../data-access/dist/
9
9
  import { useCreatePayableMutation as r, useDeletePayableFileMutation as i, useSubmitPayableForApprovalMutation as a, useUpdatePayableMutation as o, useValidatePayableMutation as s } from "../../data-access/dist/index13.js";
10
10
  import "../../data-access/dist/index.js";
11
11
  import { BILL_CREATE_MESSAGE_LABELS_EN as c } from "./index47.js";
12
- import { encodeFileToBase64 as ee } from "./index53.js";
13
- import { mapBillFormToPayload as l, mapLineItemsToPayload as u } from "./index54.js";
14
- import { validateBillCompleteness as d, validateBillTotals as f, validateLineItems as p } from "./index55.js";
15
- import { useCallback as m, useRef as h, useState as g } from "react";
12
+ import { encodeFileToBase64 as l } from "./index53.js";
13
+ import { mapBillFormToPayload as u, mapLineItemsToPayload as d } from "./index54.js";
14
+ import { validateBillCompleteness as f, validateBillTotalIsPayable as p, validateBillTotals as m, validateLineItems as h, validateStoredAmountDue as ee } from "./index55.js";
15
+ import { useCallback as g, useRef as _, useState as v } from "react";
16
16
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js
17
- var _ = {
17
+ var y = {
18
18
  document_id: "invoiceNumber",
19
19
  issued_at: "invoiceDate",
20
20
  due_date: "dueDate",
21
21
  counterpart_id: "vendor"
22
- }, v = { tax_amount: "tax" };
23
- function y(e) {
22
+ }, b = { tax_amount: "tax" };
23
+ function x(e) {
24
24
  return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
25
25
  }
26
- function b(e) {
26
+ function S(e) {
27
27
  return !!t(e)?.includes("line_items_enabled");
28
28
  }
29
- function x(e, t = c) {
29
+ function C(e, t = c) {
30
30
  let n = {}, r = {}, i = [];
31
31
  for (let a of e) {
32
- let e = a.loc[0] ?? t.unknownValidationField, o = _[e], s = v[e], c = y(a) ? t.requiredField : a.msg;
32
+ let e = a.loc[0] ?? t.unknownValidationField, o = y[e], s = b[e], c = x(a) ? t.requiredField : a.msg;
33
33
  o ? n[o] = c : s ? r[s] = c : i.push(t.unmappedValidationError(e, c));
34
34
  }
35
35
  return i.length && (n.form = i.join(" ")), {
@@ -37,7 +37,7 @@ function x(e, t = c) {
37
37
  totalsErrors: Object.keys(r).length ? r : void 0
38
38
  };
39
39
  }
40
- function S(e, t) {
40
+ function te(e, t) {
41
41
  if (!e && !t) return;
42
42
  let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
43
43
  for (let i of r) n[i] = {
@@ -46,161 +46,165 @@ function S(e, t) {
46
46
  };
47
47
  return n;
48
48
  }
49
- function C({ payableId: t, form: _, counterpartId: v, clearCounterpart: y, prepareVendorForSave: C, onSaved: w, onPayableCreated: T, readSavedStatus: E, onDraftSaved: D, onFinalized: O, labels: k }) {
50
- let A = {
49
+ function w({ payableId: t, form: y, counterpartId: b, clearCounterpart: x, prepareVendorForSave: w, onSaved: T, onPayableCreated: E, readSavedStatus: D, onDraftSaved: O, onFinalized: k, labels: A }) {
50
+ let j = {
51
51
  ...c,
52
- ...k
53
- }, [j, M] = g(), N = t ?? j, [P, F] = g(), I = m(() => F(void 0), []), [L, R] = g(!1), z = m(() => R(!0), []), [B, V] = g(), H = h(!1), [U, te] = g(0), W = m(() => te((e) => e + 1), []), G = r(), K = i(), q = o(), J = n(), Y = s(), X = a(), Z = m(() => _.isTotalsDirty ? f(_.discount, _.tax, _.totalOverride, A) : void 0, [_, A]), Q = m(() => {
54
- let t = p(_.lineItems, A), n = Z();
55
- return _.setLineItemErrors(t), _.setTotalsErrors(n), !t && !n || (_.setErrors(void 0), t && e.error(A.lineItemsNeedAttention), W(), !1);
52
+ ...A
53
+ }, [M, N] = v(), P = t ?? M, [F, I] = v(), L = g(() => I(void 0), []), [R, z] = v(!1), B = g(() => z(!0), []), [V, H] = v(), U = _(!1), [ne, re] = v(0), W = g(() => re((e) => e + 1), []), G = r(), K = i(), q = o(), J = n(), Y = s(), X = a(), Z = g(() => y.isTotalsDirty ? m(y.discount, y.tax, y.totalOverride, j) : void 0, [y, j]), Q = g(() => {
54
+ let t = h(y.lineItems, j), n = Z();
55
+ return y.setLineItemErrors(t), y.setTotalsErrors(n), !t && !n || (y.setErrors(void 0), t && e.error(j.lineItemsNeedAttention), W(), !1);
56
56
  }, [
57
- _,
58
- A,
57
+ y,
58
+ j,
59
59
  W,
60
60
  Z
61
- ]), $ = m(async (e) => {
62
- let t = !N && P ? {
63
- base64EncodedFile: await ee(P),
64
- fileName: P.name
65
- } : void 0, n = l({
66
- values: _.values,
67
- counterpartId: v,
68
- clearCounterpart: y,
61
+ ]), $ = g(async (e) => {
62
+ let t = !P && F ? {
63
+ base64EncodedFile: await l(F),
64
+ fileName: F.name
65
+ } : void 0, n = u({
66
+ values: y.values,
67
+ counterpartId: b,
68
+ clearCounterpart: x,
69
69
  counterpartBankAccountId: e,
70
- editedTotals: _.isTotalsDirty ? {
71
- discount: _.discount,
72
- tax: _.tax,
73
- total: _.totalOverride
70
+ editedTotals: y.isTotalsDirty ? {
71
+ discount: y.discount,
72
+ tax: y.tax,
73
+ total: y.totalOverride
74
74
  } : void 0,
75
75
  document: t
76
- }), r = N;
76
+ }), r = P;
77
77
  if (r ? await q.mutateAsync({
78
78
  path: { payable_id: r },
79
79
  body: n
80
- }) : (r = (await G.mutateAsync({ body: n }))?.id, r && (M(r), T?.(r), t && F(void 0))), !r) throw Error("Payable was created without an id");
81
- if (L) {
80
+ }) : (r = (await G.mutateAsync({ body: n }))?.id, r && (N(r), E?.(r), t && I(void 0))), !r) throw Error("Payable was created without an id");
81
+ if (R) {
82
82
  try {
83
83
  await K.mutateAsync({ path: { payable_id: r } });
84
84
  } catch {}
85
- R(!1);
85
+ z(!1);
86
86
  }
87
87
  return await J.mutateAsync({
88
88
  path: { payable_id: r },
89
- body: { data: u(_.lineItems) }
89
+ body: { data: d(y.lineItems) }
90
90
  }), r;
91
91
  }, [
92
- v,
93
- y,
92
+ b,
93
+ x,
94
94
  G,
95
95
  K,
96
- L,
97
- _.discount,
98
- _.isTotalsDirty,
99
- _.lineItems,
100
- _.tax,
101
- _.totalOverride,
102
- _.values,
103
- T,
104
- N,
105
- J,
96
+ R,
97
+ y.discount,
98
+ y.isTotalsDirty,
99
+ y.lineItems,
100
+ y.tax,
101
+ y.totalOverride,
102
+ y.values,
103
+ E,
106
104
  P,
105
+ J,
106
+ F,
107
107
  q
108
- ]), ne = m(async () => {
109
- N && (await K.mutateAsync({ path: { payable_id: N } }), R(!1));
110
- }, [K, N]);
108
+ ]), ie = g(async () => {
109
+ P && (await K.mutateAsync({ path: { payable_id: P } }), z(!1));
110
+ }, [K, P]);
111
111
  return {
112
- saveDraft: m(async () => {
113
- if (!H.current && Q()) {
114
- H.current = !0, V("draft");
112
+ saveDraft: g(async () => {
113
+ if (!U.current && Q()) {
114
+ U.current = !0, H("draft");
115
115
  try {
116
- let t = await C?.();
116
+ let t = await w?.();
117
117
  if (t && !t.ok) return;
118
118
  let n = await $(t?.counterpartBankAccountId);
119
- _.setErrors(void 0), w?.(n), D?.(n);
120
- let r = await E?.();
121
- return e.success(r === "draft" ? A.submittedDemoted : A.draftSaved), n;
119
+ y.setErrors(void 0), T?.(n), O?.(n);
120
+ let r = await D?.();
121
+ return e.success(r === "draft" ? j.submittedDemoted : j.draftSaved), n;
122
122
  } catch (e) {
123
- _.setSaveFailureMessage(b(e) ? A.discountTaxBlockedByLineItems : A.saveFailed), W();
123
+ y.setSaveFailureMessage(S(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
124
124
  return;
125
125
  } finally {
126
- V(void 0), H.current = !1;
126
+ H(void 0), U.current = !1;
127
127
  }
128
128
  }
129
129
  }, [
130
- _,
130
+ y,
131
131
  Q,
132
- A.discountTaxBlockedByLineItems,
133
- A.draftSaved,
134
- A.saveFailed,
135
- A.submittedDemoted,
132
+ j.discountTaxBlockedByLineItems,
133
+ j.draftSaved,
134
+ j.saveFailed,
135
+ j.submittedDemoted,
136
+ O,
137
+ T,
136
138
  D,
137
139
  w,
138
- E,
139
- C,
140
140
  $,
141
141
  W
142
142
  ]),
143
- finalize: m(async () => {
144
- if (H.current) return;
145
- let t = p(_.lineItems, A), n = Z(), { formErrors: r, lineItemErrors: i } = d(_.values, v, _.lineItems, A), a = S(i, t);
146
- _.setLineItemErrors(a), _.setTotalsErrors(n);
147
- let o = r ?? {};
148
- if (_.setErrors(Object.keys(o).length ? o : void 0), t && e.error(A.lineItemsNeedAttention), a || n || Object.keys(o).length) {
143
+ finalize: g(async () => {
144
+ if (U.current) return;
145
+ let t = h(y.lineItems, j), n = Z(), r = p(y.total, j), i = y.isTotalsDirty ? ee(y.totalOverride, y.discount, j) : void 0, a = n || r || i ? {
146
+ ...i,
147
+ ...r,
148
+ ...n
149
+ } : void 0, { formErrors: o, lineItemErrors: s } = f(y.values, b, y.lineItems, j), c = te(s, t);
150
+ y.setLineItemErrors(c), y.setTotalsErrors(a);
151
+ let l = o ?? {};
152
+ if (y.setErrors(Object.keys(l).length ? l : void 0), t && e.error(j.lineItemsNeedAttention), c || a || Object.keys(l).length) {
149
153
  W();
150
154
  return;
151
155
  }
152
- H.current = !0, V("finalize");
156
+ U.current = !0, H("finalize");
153
157
  try {
154
158
  let t;
155
159
  try {
156
- let e = await C?.();
160
+ let e = await w?.();
157
161
  if (e && !e.ok) return;
158
162
  t = await $(e?.counterpartBankAccountId);
159
163
  } catch (e) {
160
- _.setSaveFailureMessage(b(e) ? A.discountTaxBlockedByLineItems : A.saveFailed), W();
164
+ y.setSaveFailureMessage(S(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
161
165
  return;
162
166
  }
163
- w?.(t);
167
+ T?.(t);
164
168
  try {
165
169
  let n = await Y.mutateAsync({ path: { payable_id: t } });
166
170
  if (n.validation_errors.length) {
167
- let e = x(n.validation_errors, A);
168
- _.setErrors(e.formErrors), _.setTotalsErrors(e.totalsErrors), W();
171
+ let e = C(n.validation_errors, j);
172
+ y.setErrors(e.formErrors), y.setTotalsErrors(e.totalsErrors), W();
169
173
  return;
170
174
  }
171
- await X.mutateAsync({ path: { payable_id: t } }), _.setErrors(void 0), O?.(t), e.success(A.billFinalized);
175
+ await X.mutateAsync({ path: { payable_id: t } }), y.setErrors(void 0), k?.(t), e.success(j.billFinalized);
172
176
  } catch {
173
- _.setSaveFailureMessage(A.finalizeFailed), W();
177
+ y.setSaveFailureMessage(j.finalizeFailed), W();
174
178
  }
175
179
  } finally {
176
- V(void 0), H.current = !1;
180
+ H(void 0), U.current = !1;
177
181
  }
178
182
  }, [
179
- v,
180
- _,
181
- A,
182
- O,
183
+ b,
184
+ y,
185
+ j,
186
+ k,
187
+ T,
183
188
  w,
184
- C,
185
189
  $,
186
190
  W,
187
191
  X,
188
192
  Z,
189
193
  Y
190
194
  ]),
191
- payableId: N,
192
- isSavingDraft: B === "draft",
193
- isFinalizing: B === "finalize",
194
- stagedFile: P,
195
- stageFile: F,
196
- clearStagedFile: I,
197
- scrollToErrorToken: U,
198
- isFileDeletionPending: L,
199
- requestFileDeletion: z,
200
- detachFileNow: ne,
195
+ payableId: P,
196
+ isSavingDraft: V === "draft",
197
+ isFinalizing: V === "finalize",
198
+ stagedFile: F,
199
+ stageFile: I,
200
+ clearStagedFile: L,
201
+ scrollToErrorToken: ne,
202
+ isFileDeletionPending: R,
203
+ requestFileDeletion: B,
204
+ detachFileNow: ie,
201
205
  isDeletingFile: K.isPending,
202
206
  hasFileDeletionFailed: K.isError
203
207
  };
204
208
  }
205
209
  //#endregion
206
- export { x as mapValidationErrorsToForm, C as useBillCreateController };
210
+ export { C as mapValidationErrorsToForm, w as useBillCreateController };