@tesouro/embedded-components-react 0.5.56 → 0.5.59

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