@tesouro/embedded-components-react 0.5.38 → 0.5.40

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.
package/dist/index.css CHANGED
@@ -377,9 +377,6 @@
377
377
  .ttw\:col-span-1 {
378
378
  grid-column: span 1 / span 1;
379
379
  }
380
- .ttw\:col-span-3 {
381
- grid-column: span 3 / span 3;
382
- }
383
380
  .ttw\:col-start-2 {
384
381
  grid-column-start: 2;
385
382
  }
@@ -5848,6 +5845,14 @@
5848
5845
  max-width: var(--ttw-container-4xl);
5849
5846
  }
5850
5847
  }
5848
+ @container line-item (width >= 24rem) {
5849
+ .ttw\:\@sm\/line-item\:col-span-3 {
5850
+ grid-column: span 3 / span 3;
5851
+ }
5852
+ .ttw\:\@sm\/line-item\:grid-cols-3 {
5853
+ grid-template-columns: repeat(3, minmax(0, 1fr));
5854
+ }
5855
+ }
5851
5856
  @container field-group (width >= 28rem) {
5852
5857
  .ttw\:\@md\/field-group\:flex-row {
5853
5858
  flex-direction: row;
@@ -5859,9 +5864,18 @@
5859
5864
  align-items: flex-start;
5860
5865
  }
5861
5866
  }
5862
- @container line-item (width >= 32rem) {
5863
- .ttw\:\@lg\/line-item\:grid-cols-6 {
5864
- grid-template-columns: repeat(6, minmax(0, 1fr));
5867
+ @container line-item (width >= 56rem) {
5868
+ .ttw\:\@4xl\/line-item\:col-span-2 {
5869
+ grid-column: span 2 / span 2;
5870
+ }
5871
+ .ttw\:\@4xl\/line-item\:col-span-3 {
5872
+ grid-column: span 3 / span 3;
5873
+ }
5874
+ .ttw\:\@4xl\/line-item\:col-span-5 {
5875
+ grid-column: span 5 / span 5;
5876
+ }
5877
+ .ttw\:\@4xl\/line-item\:grid-cols-12 {
5878
+ grid-template-columns: repeat(12, minmax(0, 1fr));
5865
5879
  }
5866
5880
  }
5867
5881
  .ttw\:dark\:border-input:is(.dark *) {
@@ -5,91 +5,94 @@ import { formatBillMoney as i } from "./index2.js";
5
5
  import { resolveLineItemAmountMinorUnits as a } from "./index40.js";
6
6
  import { resolveLineItemQuantity as o } from "./index41.js";
7
7
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js
8
- function s({ payable: s, lineItems: l, ledgerAccounts: u, labels: d, hasScheduledPayment: f, now: p, rejection: m, achInstructions: h, achInstructionsReadable: g = !1 }) {
9
- let _ = s.currency, v = (e) => i(e, _), y = t({
10
- apiStatus: s.status,
11
- dueDate: s.due_date,
12
- scheduledPaymentDate: s.scheduled_payment_date,
13
- hasScheduledPayment: f,
14
- now: p
15
- }), b = n(s), x = r(s), S = e(s.issued_at) || d.notProvided, C = e(s.due_date) || d.notProvided, w = [{
16
- label: d.vendorRow,
17
- value: x || d.notProvided,
18
- secondaryValue: b?.email ?? void 0
19
- }], T = g ? h?.account_number : void 0;
20
- T && w.push({
21
- label: d.bankAccountRow,
22
- value: d.bankAccountValue(T.slice(-4))
8
+ function s(e) {
9
+ return typeof e == "string" ? e : "";
10
+ }
11
+ function c({ payable: c, lineItems: u, ledgerAccounts: d, labels: f, hasScheduledPayment: p, now: m, rejection: h, achInstructions: g, achInstructionsReadable: _ = !1 }) {
12
+ let v = c.currency, y = (e) => i(e, v), b = t({
13
+ apiStatus: c.status,
14
+ dueDate: c.due_date,
15
+ scheduledPaymentDate: c.scheduled_payment_date,
16
+ hasScheduledPayment: p,
17
+ now: m
18
+ }), x = n(c), S = r(c), C = e(c.issued_at) || f.notProvided, w = e(c.due_date) || f.notProvided, T = [{
19
+ label: f.vendorRow,
20
+ value: S || f.notProvided,
21
+ secondaryValue: x?.email ?? void 0
22
+ }], E = _ ? g?.account_number : void 0;
23
+ E && T.push({
24
+ label: f.bankAccountRow,
25
+ value: f.bankAccountValue(E.slice(-4))
23
26
  });
24
- let E = [
27
+ let D = [
25
28
  {
26
- label: d.invoiceNumberRow,
27
- value: s.document_id || d.notProvided
29
+ label: f.invoiceNumberRow,
30
+ value: c.document_id || f.notProvided
28
31
  },
29
32
  {
30
- label: d.issueDateRow,
31
- value: S
33
+ label: f.issueDateRow,
34
+ value: C
32
35
  },
33
36
  {
34
- label: d.dueDateRow,
35
- value: C
37
+ label: f.dueDateRow,
38
+ value: w
36
39
  },
37
40
  {
38
- label: d.poNumberRow,
39
- value: d.notProvided
41
+ label: f.poNumberRow,
42
+ value: s(c.purchase_order_number) || f.notProvided
40
43
  }
41
- ], D = new Map(u.map((e) => [e.id, [e.nominal_code, e.name].filter(Boolean).join(" — ")])), O = l.map((e) => {
42
- let t = v(e.unit_price), n = String(o(e));
44
+ ], O = new Map(d.map((e) => [e.id, [e.nominal_code, e.name].filter(Boolean).join(" — ")])), k = u.map((e) => {
45
+ let t = y(e.unit_price), n = String(o(e));
43
46
  return {
44
47
  id: e.id,
45
48
  description: e.name ?? e.description ?? "",
46
- glCodeLabel: (e.ledger_account_id ? D.get(e.ledger_account_id) : void 0) || d.glCodeMissing,
47
- quantityLabel: t ? d.quantityValue(n, t) : d.quantityOnlyValue(n),
48
- amountLabel: v(a(e)) ?? ""
49
+ glCodeLabel: (e.ledger_account_id ? O.get(e.ledger_account_id) : void 0) || f.glCodeMissing,
50
+ quantityLabel: t ? f.quantityValue(n, t) : f.quantityOnlyValue(n),
51
+ amountLabel: y(a(e)) ?? ""
49
52
  };
50
- }), k = [
53
+ }), A = [
51
54
  {
52
- label: d.subtotalRow,
53
- value: s.subtotal
55
+ label: f.subtotalRow,
56
+ value: c.subtotal
54
57
  },
55
58
  {
56
- label: d.discountsRow,
57
- value: s.discount
59
+ label: f.discountsRow,
60
+ value: c.discount
58
61
  },
59
62
  {
60
- label: d.taxRow,
61
- value: s.tax_amount
63
+ label: f.taxRow,
64
+ value: c.tax_amount
62
65
  }
63
66
  ].map(({ label: e, value: t }) => ({
64
67
  label: e,
65
- value: v(t)
66
- })).filter((e) => !!e.value), A = v(s.total_amount);
67
- A && k.push({
68
- label: d.totalRow,
69
- value: A,
68
+ value: y(t)
69
+ })).filter((e) => !!e.value), j = y(c.total_amount);
70
+ j && A.push({
71
+ label: f.totalRow,
72
+ value: j,
70
73
  emphasis: !0
71
74
  });
72
- let j = c(s);
75
+ let M = l(c);
73
76
  return {
74
- title: x,
75
- subtitle: d.subtitle,
76
- status: y.status,
77
- statusTone: y.tone,
78
- amountDueLabel: v(s.amount_due) ?? v(s.total_amount) ?? "",
79
- amountPaidLabel: j ? v(s.amount_paid) : void 0,
80
- paidOnLabel: j ? d.paidOnLabel(j) : void 0,
81
- invoiceDateLabel: S,
82
- dueDateLabel: C,
83
- dueDateTone: y.isOverdue ? "danger" : "default",
84
- payToItems: w,
85
- invoiceItems: E,
86
- lineItems: O,
87
- totals: k,
88
- rejection: m
77
+ title: S,
78
+ subtitle: f.subtitle,
79
+ status: b.status,
80
+ statusTone: b.tone,
81
+ amountDueLabel: y(c.amount_due) ?? y(c.total_amount) ?? "",
82
+ amountPaidLabel: M ? y(c.amount_paid) : void 0,
83
+ paidOnLabel: M ? f.paidOnLabel(M) : void 0,
84
+ invoiceDateLabel: C,
85
+ dueDateLabel: w,
86
+ dueDateTone: b.isOverdue ? "danger" : "default",
87
+ payToItems: T,
88
+ invoiceItems: D,
89
+ lineItems: k,
90
+ totals: A,
91
+ rejection: h
89
92
  };
90
93
  }
91
- function c(t) {
94
+ function l(t) {
92
95
  return t.status === "paid" && t.paid_at ? e(t.paid_at.slice(0, 10)) : void 0;
93
96
  }
94
97
  //#endregion
95
- export { c as getPaidAtLabel, s as mapPayableToBillDetails };
98
+ export { l as getPaidAtLabel, c as mapPayableToBillDetails };
@@ -29,7 +29,8 @@ var v = {
29
29
  unreadableDiscount: "Enter a valid discount amount.",
30
30
  unreadableTax: "Enter a valid tax amount.",
31
31
  unreadableTotal: "Enter a valid total amount.",
32
- totalNotGreaterThanZero: "Total amount must be greater than $0."
32
+ totalNotGreaterThanZero: "Total amount must be greater than $0.",
33
+ poNumberTooLong: "PO number must be 255 characters or fewer."
33
34
  }, y = {
34
35
  paymentInstructionsValue: (e) => `Account ending in ${e}`,
35
36
  noMethod: "No payment method on file",
@@ -1,12 +1,16 @@
1
1
  import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index48.js";
2
2
  import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index54.js";
3
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js
4
- var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
5
- function a(e) {
4
+ var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/, a = 255;
5
+ function o(t, n = e) {
6
+ let r = {};
7
+ return t.poNumber.length > a && (r.poNumber = n.poNumberTooLong), Object.keys(r).length ? r : void 0;
8
+ }
9
+ function s(e) {
6
10
  let t = e.trim();
7
11
  return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
8
12
  }
9
- function o(t, i = e) {
13
+ function c(t, i = e) {
10
14
  let a = {};
11
15
  for (let e of t) {
12
16
  let t = n(e.price), o = n(e.amount), s = {};
@@ -14,7 +18,7 @@ function o(t, i = e) {
14
18
  }
15
19
  return Object.keys(a).length ? a : void 0;
16
20
  }
17
- function s(i, a, o, s = e) {
21
+ function l(i, a, o, s = e) {
18
22
  let c = {};
19
23
  a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField), i.invoiceDate.trim() || (c.invoiceDate = s.requiredField), i.dueDate.trim() || (c.dueDate = s.requiredField);
20
24
  let l = {};
@@ -27,31 +31,31 @@ function s(i, a, o, s = e) {
27
31
  lineItemErrors: Object.keys(l).length ? l : void 0
28
32
  };
29
33
  }
30
- function c(e) {
34
+ function u(e) {
31
35
  let t = e.trim();
32
36
  if (!t) return !0;
33
37
  let n = t.startsWith("-") ? t.slice(1) : t;
34
38
  return i.test(n) ? Number(t.replaceAll(",", "")) <= 0 : !1;
35
39
  }
36
- function l(e, t) {
37
- if (n(e) === null) return c(e) ? t.totalNotGreaterThanZero : t.unreadableTotal;
40
+ function d(e, t) {
41
+ if (n(e) === null) return u(e) ? t.totalNotGreaterThanZero : t.unreadableTotal;
38
42
  }
39
- function u(t, n = e) {
40
- let r = l(t, n);
43
+ function f(t, n = e) {
44
+ let r = d(t, n);
41
45
  return r ? { total: r } : void 0;
42
46
  }
43
- function d(t, r, i = e) {
47
+ function p(t, r, i = e) {
44
48
  if (t === void 0) return;
45
49
  let a = n(t);
46
50
  if (a !== null) return a - (n(r) ?? 0) > 0 ? void 0 : { total: i.totalNotGreaterThanZero };
47
51
  }
48
- function f(t, n, r, i = e) {
49
- let o = {};
50
- if (a(t) || (o.discount = i.unreadableDiscount), a(n) || (o.tax = i.unreadableTax), r !== void 0) {
51
- let e = l(r, i);
52
- e && (o.total = e);
52
+ function m(t, n, r, i = e) {
53
+ let a = {};
54
+ if (s(t) || (a.discount = i.unreadableDiscount), s(n) || (a.tax = i.unreadableTax), r !== void 0) {
55
+ let e = d(r, i);
56
+ e && (a.total = e);
53
57
  }
54
- return Object.keys(o).length ? o : void 0;
58
+ return Object.keys(a).length ? a : void 0;
55
59
  }
56
60
  //#endregion
57
- export { a as isReadableMoneyOrZero, s as validateBillCompleteness, u as validateBillTotalIsPayable, f as validateBillTotals, o as validateLineItems, d as validateStoredAmountDue };
61
+ export { s as isReadableMoneyOrZero, l as validateBillCompleteness, f as validateBillTotalIsPayable, m as validateBillTotals, o as validateBillValues, c as validateLineItems, p as validateStoredAmountDue };
@@ -10,27 +10,28 @@ 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 "./index48.js";
12
12
  import { encodeFileToBase64 as l } from "./index53.js";
13
- import { mapBillFormToPayload as ee, mapLineItemsToPayload as te } from "./index54.js";
14
- import { validateBillCompleteness as u, validateBillTotalIsPayable as d, validateBillTotals as ne, validateLineItems as f, validateStoredAmountDue as p } from "./index55.js";
15
- import { useCallback as m, useRef as h, useState as g } from "react";
13
+ import { mapBillFormToPayload as u, mapLineItemsToPayload as ee } from "./index54.js";
14
+ import { validateBillCompleteness as te, validateBillTotalIsPayable as ne, validateBillTotals as d, validateBillValues as f, validateLineItems as p, validateStoredAmountDue as m } from "./index55.js";
15
+ import { useCallback as h, useRef as g, useState as _ } from "react";
16
16
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js
17
- var _ = {
17
+ var v = {
18
18
  document_id: "invoiceNumber",
19
19
  issued_at: "invoiceDate",
20
20
  due_date: "dueDate",
21
- counterpart_id: "vendor"
22
- }, v = { tax_amount: "tax" };
23
- function y(e) {
21
+ counterpart_id: "vendor",
22
+ purchase_order_number: "poNumber"
23
+ }, y = { tax_amount: "tax" };
24
+ function b(e) {
24
25
  return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
25
26
  }
26
- var b = "pending-vendor";
27
+ var re = "pending-vendor";
27
28
  function x(e) {
28
29
  return !!t(e)?.includes("line_items_enabled");
29
30
  }
30
31
  function S(e, t = c) {
31
32
  let n = {}, r = {}, i = [];
32
33
  for (let a of e) {
33
- let e = a.loc[0] ?? t.unknownValidationField, o = _[e], s = v[e], c = y(a) ? t.requiredField : a.msg;
34
+ let e = a.loc[0] ?? t.unknownValidationField, o = v[e], s = y[e], c = b(a) ? t.requiredField : a.msg;
34
35
  o ? n[o] = c : s ? r[s] = c : i.push(t.unmappedValidationError(e, c));
35
36
  }
36
37
  return i.length && (n.form = i.join(" ")), {
@@ -38,7 +39,7 @@ function S(e, t = c) {
38
39
  totalsErrors: Object.keys(r).length ? r : void 0
39
40
  };
40
41
  }
41
- function re(e, t) {
42
+ function C(e, t) {
42
43
  if (!e && !t) return;
43
44
  let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
44
45
  for (let i of r) n[i] = {
@@ -47,167 +48,170 @@ function re(e, t) {
47
48
  };
48
49
  return n;
49
50
  }
50
- function C({ payableId: t, form: _, counterpartId: v, isVendorPending: y, clearCounterpart: C, prepareVendorForSave: w, onSaved: T, onPayableCreated: E, readSavedStatus: D, onDraftSaved: O, onFinalized: k, labels: A }) {
51
- let j = {
51
+ function w({ payableId: t, form: v, counterpartId: y, isVendorPending: b, clearCounterpart: w, prepareVendorForSave: T, onSaved: E, onPayableCreated: D, readSavedStatus: O, onDraftSaved: k, onFinalized: A, labels: j }) {
52
+ let M = {
52
53
  ...c,
53
- ...A
54
- }, [M, N] = g(), P = t ?? M, [F, I] = g(), ie = m(() => I(void 0), []), [L, R] = g(!1), ae = m(() => R(!0), []), [z, B] = g(), V = h(!1), [H, U] = g(0), W = m(() => U((e) => e + 1), []), G = r(), K = i(), q = o(), J = n(), Y = s(), X = a(), Z = m(() => _.isTotalsDirty ? ne(_.discount, _.tax, _.totalOverride, j) : void 0, [_, j]), Q = m(() => {
55
- let t = f(_.lineItems, j), n = Z();
56
- return _.setLineItemErrors(t), _.setTotalsErrors(n), !t && !n || (_.setErrors(void 0), t && e.error(j.lineItemsNeedAttention), W(), !1);
54
+ ...j
55
+ }, [N, P] = _(), F = t ?? N, [I, L] = _(), R = h(() => L(void 0), []), [z, B] = _(!1), ie = h(() => B(!0), []), [V, H] = _(), U = g(!1), [ae, oe] = _(0), W = h(() => oe((e) => e + 1), []), G = r(), K = i(), q = o(), J = n(), Y = s(), X = a(), Z = h(() => v.isTotalsDirty ? d(v.discount, v.tax, v.totalOverride, M) : void 0, [v, M]), Q = h(() => {
56
+ let t = f(v.values, M), n = p(v.lineItems, M), r = Z();
57
+ return v.setErrors(t), v.setLineItemErrors(n), v.setTotalsErrors(r), !t && !n && !r || (n && e.error(M.lineItemsNeedAttention), W(), !1);
57
58
  }, [
58
- _,
59
- j,
59
+ v,
60
+ M,
60
61
  W,
61
62
  Z
62
- ]), $ = m(async (e, t) => {
63
- let n = !P && F ? {
64
- base64EncodedFile: await l(F),
65
- fileName: F.name
66
- } : void 0, r = ee({
67
- values: _.values,
68
- initialLineItems: P ? void 0 : _.lineItems,
69
- counterpartId: t ?? v,
70
- clearCounterpart: C,
63
+ ]), $ = h(async (e, t) => {
64
+ let n = !F && I ? {
65
+ base64EncodedFile: await l(I),
66
+ fileName: I.name
67
+ } : void 0, r = u({
68
+ values: v.values,
69
+ initialLineItems: F ? void 0 : v.lineItems,
70
+ counterpartId: t ?? y,
71
+ clearCounterpart: w,
71
72
  counterpartBankAccountId: e,
72
- editedTotals: _.isTotalsDirty ? {
73
- discount: _.discount,
74
- tax: _.tax,
75
- total: _.totalOverride
73
+ editedTotals: v.isTotalsDirty ? {
74
+ discount: v.discount,
75
+ tax: v.tax,
76
+ total: v.totalOverride
76
77
  } : void 0,
77
78
  document: n
78
- }), i = P;
79
+ }), i = F;
79
80
  if (i ? await q.mutateAsync({
80
81
  path: { payable_id: i },
81
82
  body: r
82
- }) : (i = (await G.mutateAsync({ body: r }))?.id, i && (N(i), E?.(i), n && I(void 0))), !i) throw Error("Payable was created without an id");
83
- if (L) {
83
+ }) : (i = (await G.mutateAsync({ body: r }))?.id, i && (P(i), D?.(i), n && L(void 0))), !i) throw Error("Payable was created without an id");
84
+ if (z) {
84
85
  try {
85
86
  await K.mutateAsync({ path: { payable_id: i } });
86
87
  } catch {}
87
- R(!1);
88
+ B(!1);
88
89
  }
89
90
  return await J.mutateAsync({
90
91
  path: { payable_id: i },
91
- body: { data: te(_.lineItems) }
92
+ body: { data: ee(v.lineItems) }
92
93
  }), i;
93
94
  }, [
94
- v,
95
- C,
95
+ y,
96
+ w,
96
97
  G,
97
98
  K,
98
- L,
99
- _.discount,
100
- _.isTotalsDirty,
101
- _.lineItems,
102
- _.tax,
103
- _.totalOverride,
104
- _.values,
105
- E,
106
- P,
107
- J,
99
+ z,
100
+ v.discount,
101
+ v.isTotalsDirty,
102
+ v.lineItems,
103
+ v.tax,
104
+ v.totalOverride,
105
+ v.values,
106
+ D,
108
107
  F,
108
+ J,
109
+ I,
109
110
  q
110
- ]), oe = m(async () => {
111
- P && (await K.mutateAsync({ path: { payable_id: P } }), R(!1));
112
- }, [K, P]);
111
+ ]), se = h(async () => {
112
+ F && (await K.mutateAsync({ path: { payable_id: F } }), B(!1));
113
+ }, [K, F]);
113
114
  return {
114
- saveDraft: m(async () => {
115
- if (!V.current && Q()) {
116
- V.current = !0, B("draft");
115
+ saveDraft: h(async () => {
116
+ if (!U.current && Q()) {
117
+ U.current = !0, H("draft");
117
118
  try {
118
- let t = await w?.();
119
+ let t = await T?.();
119
120
  if (t && !t.ok) return;
120
121
  let n = await $(t?.counterpartBankAccountId, t?.counterpartId);
121
- _.setErrors(void 0), T?.(n), O?.(n);
122
- let r = await D?.();
123
- return e.success(r === "draft" ? j.submittedDemoted : j.draftSaved), n;
122
+ v.setErrors(void 0), E?.(n), k?.(n);
123
+ let r = await O?.();
124
+ return e.success(r === "draft" ? M.submittedDemoted : M.draftSaved), n;
124
125
  } catch (e) {
125
- _.setSaveFailureMessage(x(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
126
+ v.setSaveFailureMessage(x(e) ? M.discountTaxBlockedByLineItems : M.saveFailed), W();
126
127
  return;
127
128
  } finally {
128
- B(void 0), V.current = !1;
129
+ H(void 0), U.current = !1;
129
130
  }
130
131
  }
131
132
  }, [
132
- _,
133
+ v,
133
134
  Q,
134
- j.discountTaxBlockedByLineItems,
135
- j.draftSaved,
136
- j.saveFailed,
137
- j.submittedDemoted,
135
+ M.discountTaxBlockedByLineItems,
136
+ M.draftSaved,
137
+ M.saveFailed,
138
+ M.submittedDemoted,
139
+ k,
140
+ E,
138
141
  O,
139
142
  T,
140
- D,
141
- w,
142
143
  $,
143
144
  W
144
145
  ]),
145
- finalize: m(async () => {
146
- if (V.current) return;
147
- let t = f(_.lineItems, j), n = Z(), r = d(_.total, j), i = _.isTotalsDirty ? p(_.totalOverride, _.discount, j) : void 0, a = n || r || i ? {
146
+ finalize: h(async () => {
147
+ if (U.current) return;
148
+ let t = p(v.lineItems, M), n = f(v.values, M), r = Z(), i = ne(v.total, M), a = v.isTotalsDirty ? m(v.totalOverride, v.discount, M) : void 0, o = r || i || a ? {
149
+ ...a,
148
150
  ...i,
149
- ...r,
151
+ ...r
152
+ } : void 0, { formErrors: s, lineItemErrors: c } = te(v.values, y ?? (b ? re : void 0), v.lineItems, M), l = C(c, t);
153
+ v.setLineItemErrors(l), v.setTotalsErrors(o);
154
+ let u = {
155
+ ...s,
150
156
  ...n
151
- } : void 0, { formErrors: o, lineItemErrors: s } = u(_.values, v ?? (y ? b : void 0), _.lineItems, j), c = re(s, t);
152
- _.setLineItemErrors(c), _.setTotalsErrors(a);
153
- let l = o ?? {};
154
- if (_.setErrors(Object.keys(l).length ? l : void 0), t && e.error(j.lineItemsNeedAttention), c || a || Object.keys(l).length) {
157
+ };
158
+ if (v.setErrors(Object.keys(u).length ? u : void 0), t && e.error(M.lineItemsNeedAttention), l || o || Object.keys(u).length) {
155
159
  W();
156
160
  return;
157
161
  }
158
- V.current = !0, B("finalize");
162
+ U.current = !0, H("finalize");
159
163
  try {
160
164
  let t;
161
165
  try {
162
- let e = await w?.();
166
+ let e = await T?.();
163
167
  if (e && !e.ok) return;
164
168
  t = await $(e?.counterpartBankAccountId, e?.counterpartId);
165
169
  } catch (e) {
166
- _.setSaveFailureMessage(x(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
170
+ v.setSaveFailureMessage(x(e) ? M.discountTaxBlockedByLineItems : M.saveFailed), W();
167
171
  return;
168
172
  }
169
- T?.(t);
173
+ E?.(t);
170
174
  try {
171
175
  let n = await Y.mutateAsync({ path: { payable_id: t } });
172
176
  if (n.validation_errors.length) {
173
- let e = S(n.validation_errors, j);
174
- _.setErrors(e.formErrors), _.setTotalsErrors(e.totalsErrors), W();
177
+ let e = S(n.validation_errors, M);
178
+ v.setErrors(e.formErrors), v.setTotalsErrors(e.totalsErrors), W();
175
179
  return;
176
180
  }
177
- await X.mutateAsync({ path: { payable_id: t } }), _.setErrors(void 0), k?.(t), e.success(j.billFinalized);
181
+ await X.mutateAsync({ path: { payable_id: t } }), v.setErrors(void 0), A?.(t), e.success(M.billFinalized);
178
182
  } catch {
179
- _.setSaveFailureMessage(j.finalizeFailed), W();
183
+ v.setSaveFailureMessage(M.finalizeFailed), W();
180
184
  }
181
185
  } finally {
182
- B(void 0), V.current = !1;
186
+ H(void 0), U.current = !1;
183
187
  }
184
188
  }, [
185
- v,
186
189
  y,
187
- _,
188
- j,
189
- k,
190
+ b,
191
+ v,
192
+ M,
193
+ A,
194
+ E,
190
195
  T,
191
- w,
192
196
  $,
193
197
  W,
194
198
  X,
195
199
  Z,
196
200
  Y
197
201
  ]),
198
- payableId: P,
199
- isSavingDraft: z === "draft",
200
- isFinalizing: z === "finalize",
201
- stagedFile: F,
202
- stageFile: I,
203
- clearStagedFile: ie,
204
- scrollToErrorToken: H,
205
- isFileDeletionPending: L,
206
- requestFileDeletion: ae,
207
- detachFileNow: oe,
202
+ payableId: F,
203
+ isSavingDraft: V === "draft",
204
+ isFinalizing: V === "finalize",
205
+ stagedFile: I,
206
+ stageFile: L,
207
+ clearStagedFile: R,
208
+ scrollToErrorToken: ae,
209
+ isFileDeletionPending: z,
210
+ requestFileDeletion: ie,
211
+ detachFileNow: se,
208
212
  isDeletingFile: K.isPending,
209
213
  hasFileDeletionFailed: K.isError
210
214
  };
211
215
  }
212
216
  //#endregion
213
- export { S as mapValidationErrorsToForm, C as useBillCreateController };
217
+ export { S as mapValidationErrorsToForm, w as useBillCreateController };
@@ -14,27 +14,30 @@ function n() {
14
14
  function r(e) {
15
15
  return typeof e == "number" ? (e / 100).toFixed(2) : "";
16
16
  }
17
- function i({ payable: i, lineItems: a }) {
18
- let o = {
19
- invoiceNumber: i.document_id ?? "",
20
- invoiceDate: i.issued_at ?? "",
21
- dueDate: i.due_date ?? "",
22
- poNumber: ""
23
- }, s = a.map((n) => ({
17
+ function i(e) {
18
+ return typeof e == "string" ? e : "";
19
+ }
20
+ function a({ payable: a, lineItems: o }) {
21
+ let s = {
22
+ invoiceNumber: a.document_id ?? "",
23
+ invoiceDate: a.issued_at ?? "",
24
+ dueDate: a.due_date ?? "",
25
+ poNumber: i(a.purchase_order_number)
26
+ }, c = o.map((n) => ({
24
27
  id: n.id,
25
28
  description: n.name ?? "",
26
29
  glCode: n.ledger_account_id ?? "",
27
30
  quantity: String(t(n)),
28
31
  price: r(n.unit_price),
29
32
  amount: r(e(n))
30
- })), c = i.amount_due ?? (i.total_amount == null ? void 0 : i.total_amount - (i.discount ?? 0));
33
+ })), l = a.amount_due ?? (a.total_amount == null ? void 0 : a.total_amount - (a.discount ?? 0));
31
34
  return {
32
- values: o,
33
- lineItems: s.length ? s : [n()],
34
- discount: r(i.discount),
35
- tax: r(i.tax_amount),
36
- total: c ? r(c) : ""
35
+ values: s,
36
+ lineItems: c.length ? c : [n()],
37
+ discount: r(a.discount),
38
+ tax: r(a.tax_amount),
39
+ total: l ? r(l) : ""
37
40
  };
38
41
  }
39
42
  //#endregion
40
- export { n as emptyLineItem, i as mapPayableToBillForm };
43
+ export { n as emptyLineItem, a as mapPayableToBillForm };
@@ -64,8 +64,8 @@ function y({ payable: n, lineItems: r, labels: i = e } = {}) {
64
64
  D((e) => {
65
65
  if (!e?.form || e.form !== O.current) return e;
66
66
  O.current = void 0;
67
- let { form: t, ...n } = e;
68
- return Object.keys(n).length ? n : void 0;
67
+ let t = { ...e };
68
+ return delete t.form, Object.keys(t).length ? t : void 0;
69
69
  });
70
70
  }, []), [M, N] = d(), [P, F] = d(), [I, L] = d(!1), [R, z] = d(!1), [B, V] = d(!1);
71
71
  l(() => {
@@ -3,47 +3,49 @@ import { BILL_FORM_FIELDS_LABELS_EN as n } from "./index33.js";
3
3
  import { useId as r } from "react";
4
4
  import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
5
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index34.js
6
- function o({ values: o, errors: s, onChange: c, disabled: l, testId: u, labels: d }) {
7
- let f = {
6
+ var o = 255;
7
+ function s({ values: s, errors: c, onChange: l, disabled: u, testId: d, labels: f }) {
8
+ let p = {
8
9
  ...n,
9
- ...d
10
- }, p = r(), m = (n, r, u) => {
11
- let d = `${p}-${n}`, f = `${d}-error`, m = s?.[n];
10
+ ...f
11
+ }, m = r(), h = (n, r, d) => {
12
+ let f = `${m}-${n}`, p = `${f}-error`, h = c?.[n];
12
13
  return /* @__PURE__ */ a("div", {
13
14
  className: "ttw:flex ttw:flex-col ttw:gap-1.5",
14
15
  children: [
15
16
  /* @__PURE__ */ i(t, {
16
- htmlFor: d,
17
+ htmlFor: f,
17
18
  children: r
18
19
  }),
19
20
  /* @__PURE__ */ i(e, {
20
- id: d,
21
- type: u,
22
- value: o[n],
23
- disabled: l,
24
- "aria-invalid": m ? !0 : void 0,
25
- "aria-describedby": m ? f : void 0,
26
- onChange: (e) => c({ [n]: e.target.value })
27
- }),
28
- m ? /* @__PURE__ */ i("p", {
29
21
  id: f,
22
+ type: d,
23
+ value: s[n],
24
+ disabled: u,
25
+ maxLength: n === "poNumber" ? o : void 0,
26
+ "aria-invalid": h ? !0 : void 0,
27
+ "aria-describedby": h ? p : void 0,
28
+ onChange: (e) => l({ [n]: e.target.value })
29
+ }),
30
+ h ? /* @__PURE__ */ i("p", {
31
+ id: p,
30
32
  className: "ttw:text-sm ttw:text-destructive",
31
- children: m
33
+ children: h
32
34
  }) : null
33
35
  ]
34
36
  });
35
37
  };
36
38
  return /* @__PURE__ */ a("div", {
37
39
  className: "ttw:flex ttw:flex-col ttw:gap-4",
38
- "data-testid": u,
40
+ "data-testid": d,
39
41
  children: [/* @__PURE__ */ a("div", {
40
42
  className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
41
- children: [m("invoiceDate", f.invoiceDate, "date"), m("dueDate", f.dueDate, "date")]
43
+ children: [h("invoiceDate", p.invoiceDate, "date"), h("dueDate", p.dueDate, "date")]
42
44
  }), /* @__PURE__ */ a("div", {
43
45
  className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
44
- children: [m("invoiceNumber", f.invoiceNumber), m("poNumber", f.poNumber)]
46
+ children: [h("invoiceNumber", p.invoiceNumber), h("poNumber", p.poNumber)]
45
47
  })]
46
48
  });
47
49
  }
48
50
  //#endregion
49
- export { o as BillFormFields, o as default };
51
+ export { s as BillFormFields, s as default };
@@ -83,10 +83,10 @@ function E({ items: E, glCodeOptions: D, glCodeDisabled: O, glCodeUnavailableMes
83
83
  }), M("description")]
84
84
  }),
85
85
  /* @__PURE__ */ b("div", {
86
- className: "ttw:grid ttw:grid-cols-3 ttw:@lg/line-item:grid-cols-6 ttw:gap-3",
86
+ className: "ttw:grid ttw:grid-cols-1 ttw:@sm/line-item:grid-cols-3 ttw:@4xl/line-item:grid-cols-12 ttw:gap-3",
87
87
  children: [
88
88
  /* @__PURE__ */ b("div", {
89
- className: "ttw:col-span-3 ttw:flex ttw:flex-col ttw:gap-1.5",
89
+ className: "ttw:col-span-1 ttw:@sm/line-item:col-span-3 ttw:@4xl/line-item:col-span-5 ttw:flex ttw:flex-col ttw:gap-1.5",
90
90
  children: [
91
91
  /* @__PURE__ */ b("div", {
92
92
  className: "ttw:flex ttw:items-center ttw:gap-1",
@@ -138,7 +138,7 @@ function E({ items: E, glCodeOptions: D, glCodeDisabled: O, glCodeUnavailableMes
138
138
  ]
139
139
  }),
140
140
  /* @__PURE__ */ b("div", {
141
- className: "ttw:col-span-1 ttw:flex ttw:flex-col ttw:gap-1.5",
141
+ className: "ttw:col-span-1 ttw:@4xl/line-item:col-span-3 ttw:flex ttw:flex-col ttw:gap-1.5",
142
142
  children: [
143
143
  /* @__PURE__ */ y(a, {
144
144
  htmlFor: `${v}-quantity`,
@@ -183,7 +183,7 @@ function E({ items: E, glCodeOptions: D, glCodeDisabled: O, glCodeUnavailableMes
183
183
  ]
184
184
  }),
185
185
  /* @__PURE__ */ b("div", {
186
- className: "ttw:col-span-1 ttw:flex ttw:flex-col ttw:gap-1.5",
186
+ className: "ttw:col-span-1 ttw:@4xl/line-item:col-span-2 ttw:flex ttw:flex-col ttw:gap-1.5",
187
187
  children: [
188
188
  /* @__PURE__ */ y(a, {
189
189
  htmlFor: `${v}-price`,
@@ -208,7 +208,7 @@ function E({ items: E, glCodeOptions: D, glCodeDisabled: O, glCodeUnavailableMes
208
208
  ]
209
209
  }),
210
210
  /* @__PURE__ */ b("div", {
211
- className: "ttw:col-span-1 ttw:flex ttw:flex-col ttw:gap-1.5",
211
+ className: "ttw:col-span-1 ttw:@4xl/line-item:col-span-2 ttw:flex ttw:flex-col ttw:gap-1.5",
212
212
  children: [
213
213
  /* @__PURE__ */ y(a, {
214
214
  htmlFor: `${v}-amount`,
@@ -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.5.38", n = "9d7fbd97f8e1233db8f081ecb15fa1e53a8c632b", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.5.40", n = "cf726abcf80a70bb2ca03fd1610339cc6bcd4e11", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.5.38",
3
+ "version": "0.5.40",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {