@tesouro/embedded-components-react 0.5.62 → 0.5.63

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.
@@ -6,7 +6,7 @@ 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
8
  function s(e) {
9
- return typeof e.total_amount == "number" ? e.total_amount - (e.discount ?? 0) : e.amount_due ?? void 0;
9
+ return e.total_amount ?? e.amount_due ?? void 0;
10
10
  }
11
11
  function c(e) {
12
12
  return typeof e == "string" ? e : "";
@@ -22,30 +22,33 @@ function o(e) {
22
22
  return Number.isFinite(t) ? t : 0;
23
23
  }
24
24
  function s(e) {
25
+ let t = n(e);
26
+ return t === null ? e : c(t);
27
+ }
28
+ function c(e) {
25
29
  return (e / 100).toFixed(2);
26
30
  }
27
- function c({ values: e, initialLineItems: r, counterpartId: i, clearCounterpart: a, counterpartBankAccountId: o, editedTotals: s, currentTotals: c, lineItems: d, document: f, includeBlankPoNumber: p = !0 }) {
31
+ function l({ values: e, initialLineItems: r, counterpartId: i, clearCounterpart: a, counterpartBankAccountId: o, editedTotals: s, currentTotals: c, lineItems: l, document: f, includeBlankPoNumber: p = !0 }) {
28
32
  let m = { currency: t };
29
33
  i ? m.counterpart_id = i : a && (m.counterpart_id = null), i ? m.counterpart_bank_account_id = o ?? null : a && (m.counterpart_bank_account_id = null), e.invoiceNumber && (m.document_id = e.invoiceNumber), e.invoiceDate && (m.issued_at = e.invoiceDate), e.dueDate && (m.due_date = e.dueDate);
30
34
  let h = e.poNumber.trim();
31
- if ((h || p) && (m.purchase_order_number = h || null), f && (m.base64_encoded_file = f.base64EncodedFile, m.file_name = f.fileName), s) {
32
- let e = n(s.discount) ?? 0;
33
- m.discount = e, m.tax_amount = n(s.tax) ?? 0, s.total !== void 0 && (m.total_amount = (n(s.total) ?? 0) + e);
34
- }
35
- if (c && d) {
36
- let e = u(d), t = n(c.tax) ?? 0, r = n(c.discount) ?? 0, i = c.total === void 0 ? (e ?? 0) + t : (n(c.total) ?? 0) + r;
35
+ if ((h || p) && (m.purchase_order_number = h || null), f && (m.base64_encoded_file = f.base64EncodedFile, m.file_name = f.fileName), s && (m.discount = n(s.discount) ?? 0, m.tax_amount = n(s.tax) ?? 0, s.total !== void 0 && (m.total_amount = n(s.total) ?? 0)), c && l) {
36
+ let e = d(l), t = n(c.tax) ?? 0, r = n(c.discount) ?? 0, i = c.total === void 0 ? (e ?? 0) - r + t : n(c.total) ?? 0;
37
37
  e !== void 0 && (m.subtotal = e), m.discount = r, m.tax_amount = t, m.total_amount = i;
38
38
  } else if (r && !("total_amount" in m)) {
39
- let e = l(r, { tax: s?.tax });
39
+ let e = u(r, {
40
+ tax: s?.tax,
41
+ discount: s?.discount
42
+ });
40
43
  e !== void 0 && (m.total_amount = e);
41
44
  }
42
45
  return m;
43
46
  }
44
- function l(e, { tax: t }) {
45
- let r = u(e);
46
- if (r !== void 0) return r + (t ? n(t) ?? 0 : 0);
47
+ function u(e, { tax: t, discount: r }) {
48
+ let i = d(e);
49
+ if (i !== void 0) return i + (t ? n(t) ?? 0 : 0) - (r ? n(r) ?? 0 : 0);
47
50
  }
48
- function u(e) {
51
+ function d(e) {
49
52
  let t = !1, r = e.reduce((e, r) => {
50
53
  if (!i(r)) return e;
51
54
  let a = n(r.amount);
@@ -53,14 +56,14 @@ function u(e) {
53
56
  }, 0);
54
57
  if (t) return r;
55
58
  }
56
- function d({ lineItems: e, editedTotals: t }) {
57
- let r = u(e), i = n(t.tax) ?? 0, a = n(t.discount) ?? 0, o = {
59
+ function f({ lineItems: e, editedTotals: t }) {
60
+ let r = d(e), i = n(t.tax) ?? 0, a = n(t.discount) ?? 0, o = {
58
61
  discount: a,
59
62
  tax_amount: i
60
63
  };
61
- return r !== void 0 && (o.subtotal = r), t.total === void 0 ? r !== void 0 && (o.total_amount = r + i) : o.total_amount = (n(t.total) ?? 0) + a, o;
64
+ return r !== void 0 && (o.subtotal = r), t.total === void 0 ? r !== void 0 && (o.total_amount = r - a + i) : o.total_amount = n(t.total) ?? 0, o;
62
65
  }
63
- function f(e) {
66
+ function p(e) {
64
67
  return e.filter(i).map((e) => {
65
68
  let t = n(e.amount), i = r(e.quantity) ?? 1, a = n(e.price) ?? (t === null ? 0 : Math.round(t / i)), o = Math.round(i * a), s = t ?? o;
66
69
  return {
@@ -75,11 +78,11 @@ function f(e) {
75
78
  };
76
79
  });
77
80
  }
78
- function p(e, t) {
79
- return s(Math.round(o(e) * a(t)));
81
+ function m(e, t) {
82
+ return c(Math.round(o(e) * a(t)));
80
83
  }
81
- function m(e, t, n) {
82
- return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
84
+ function h(e, t, n) {
85
+ return c(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
83
86
  }
84
87
  //#endregion
85
- export { m as calculateTotal, p as displayLineAmount, i as isPersistableLineItem, c as mapBillFormToPayload, f as mapLineItemsToPayload, d as mapPayableAmountFieldsToPayload, n as parseMoneyToMinorUnits, r as parseQuantity };
88
+ export { h as calculateTotal, m as displayLineAmount, i as isPersistableLineItem, l as mapBillFormToPayload, p as mapLineItemsToPayload, f as mapPayableAmountFieldsToPayload, s as normalizeMoneyOnBlur, n as parseMoneyToMinorUnits, r as parseQuantity };
@@ -18,8 +18,7 @@ function i(e) {
18
18
  return typeof e == "string" ? e : "";
19
19
  }
20
20
  function a(e) {
21
- if (typeof e.amount_due == "number") return e.amount_due;
22
- if (typeof e.total_amount == "number") return e.total_amount - (e.discount ?? 0);
21
+ return e.total_amount ?? e.amount_due ?? void 0;
23
22
  }
24
23
  function o({ payable: o, lineItems: s }) {
25
24
  let c = {
@@ -3,90 +3,90 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index49.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";
6
+ import { calculateTotal as t, displayLineAmount as n, normalizeMoneyOnBlur as r, parseMoneyToMinorUnits as i, parseQuantity as a } from "./index55.js";
7
+ import { validateBillTotals as o } from "./index56.js";
8
+ import { emptyLineItem as s, mapPayableToBillForm as c } from "./index58.js";
9
+ import { useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
10
10
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js
11
- var f = /^[0-9.,-]+$/;
12
- function p(e) {
11
+ var m = /^[0-9.,-]+$/;
12
+ function h(e) {
13
13
  let t = e.trim().replace(/^\$\s*/, "");
14
- return t ? f.test(t) ? t : null : "";
14
+ return t ? m.test(t) ? t : null : "";
15
15
  }
16
- var m = [
16
+ var g = [
17
17
  "quantity",
18
18
  "price",
19
19
  "amount"
20
20
  ];
21
- function h(e) {
21
+ function _(e) {
22
22
  let t = e.trim(), n = /[.,]$/.test(t) ? t.slice(0, -1) : t;
23
23
  return t && !n ? null : n;
24
24
  }
25
- function g(e, t, n) {
25
+ function v(e, t, n) {
26
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];
27
+ let r = _(t);
28
+ if (r !== null) return o(e === "discount" ? r : "", e === "tax" ? r : "", e === "total" ? r : void 0, n)?.[e];
29
29
  }
30
- function _(e, t) {
31
- let n = {}, a = {
30
+ function y(e, t) {
31
+ let n = {}, r = {
32
32
  price: null,
33
33
  amount: null
34
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));
35
+ for (let a of ["price", "amount"]) {
36
+ let o = _(e[a]);
37
+ o !== null && (r[a] = i(o), o && r[a] === null && (n[a] = t.unreadableMoney));
38
38
  }
39
- let o = h(e.quantity);
39
+ let o = _(e.quantity);
40
40
  if (o !== null) {
41
- let e = a.price !== null || a.amount !== null;
42
- i(o) === null && (o || e) && (n.quantity = t.unusableQuantity);
41
+ let e = r.price !== null || r.amount !== null;
42
+ a(o) === null && (o || e) && (n.quantity = t.unusableQuantity);
43
43
  }
44
44
  return n;
45
45
  }
46
- function v(e, t, i) {
47
- return r(t) === null ? i : n(e, t);
46
+ function b(e, t, r) {
47
+ return i(t) === null ? r : n(e, t);
48
48
  }
49
- function y({ payable: n, lineItems: r, labels: i = e } = {}) {
50
- let a = u(() => s({
49
+ function x({ payable: n, lineItems: i, labels: a = e } = {}) {
50
+ let o = d(() => c({
51
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) => {
52
+ lineItems: i ?? []
53
+ }), [n, i]), [m, _] = p(o.values), [x, S] = p(o.lineItems), [C, w] = p(o.discount), [T, E] = p(o.tax), [D, O] = p(o.total || void 0), [ee, k] = p(), A = f(void 0), te = l((e) => {
54
+ k((t) => {
55
55
  let n = typeof e == "function" ? e(t) : e;
56
- return n?.form !== O.current && (O.current = void 0), n;
56
+ return n?.form !== A.current && (A.current = void 0), n;
57
57
  });
58
- }, []), A = c((e) => {
59
- O.current = e, D((t) => ({
58
+ }, []), ne = l((e) => {
59
+ A.current = e, k((t) => ({
60
60
  ...t,
61
61
  form: e
62
62
  }));
63
- }, []), j = c(() => {
64
- D((e) => {
65
- if (!e?.form || e.form !== O.current) return e;
66
- O.current = void 0;
63
+ }, []), j = l(() => {
64
+ k((e) => {
65
+ if (!e?.form || e.form !== A.current) return e;
66
+ A.current = void 0;
67
67
  let t = { ...e };
68
68
  return delete t.form, Object.keys(t).length ? t : void 0;
69
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) => ({
70
+ }, []), [re, M] = p(), [N, P] = p(), [F, I] = p(!1), [L, R] = p(!1), [z, B] = p(!1);
71
+ u(() => {
72
+ F || _(o.values);
73
+ }, [o]), u(() => {
74
+ L || S(o.lineItems);
75
+ }, [o]), u(() => {
76
+ z || (w(o.discount), E(o.tax), O(o.total || void 0));
77
+ }, [o]);
78
+ let ie = l((e) => {
79
+ _((t) => ({
80
80
  ...t,
81
81
  ...e
82
- })), L(!0), D((t) => {
82
+ })), I(!0), k((t) => {
83
83
  if (!t) return t;
84
84
  let n = { ...t };
85
85
  for (let t of Object.keys(e)) delete n[t];
86
86
  return Object.keys(n).length ? n : void 0;
87
87
  }), j();
88
- }, [j]), U = c((e, t) => {
89
- N((n) => {
88
+ }, [j]), V = l((e, t) => {
89
+ M((n) => {
90
90
  if (!n?.[e] && !t) return n;
91
91
  let r = {
92
92
  ...n,
@@ -94,13 +94,13 @@ function y({ payable: n, lineItems: r, labels: i = e } = {}) {
94
94
  };
95
95
  return t || delete r[e], Object.keys(r).length ? r : void 0;
96
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) => {
97
+ }, []), H = l((e, t) => {
98
+ V(e, v(e, t, a));
99
+ }, [a, V]), U = l(() => {
100
+ O(void 0), H("total", void 0), j();
101
+ }, [H, j]), W = l((e, t = []) => {
102
+ let n = y(e, a);
103
+ P((r) => {
104
104
  let i = r?.[e.id], a = { ...i };
105
105
  for (let e of [
106
106
  "price",
@@ -113,130 +113,142 @@ function y({ payable: n, lineItems: r, labels: i = e } = {}) {
113
113
  let s = { ...r };
114
114
  return o ? s[e.id] = a : delete s[e.id], Object.keys(s).length ? s : void 0;
115
115
  });
116
- }, [i]), q = c((e, t, n) => {
117
- F((r) => ({
116
+ }, [a]), G = l((e, t, n) => {
117
+ P((r) => ({
118
118
  ...r,
119
119
  [e]: {
120
120
  ...r?.[e],
121
121
  [t]: n
122
122
  }
123
123
  }));
124
- }, []), J = c((e, t, n = []) => {
125
- let r = y.find((t) => t.id === e);
124
+ }, []), K = l((e, t, n = []) => {
125
+ let r = x.find((t) => t.id === e);
126
126
  if (!r) return;
127
127
  let i = t(r);
128
- b(y.map((t) => t.id === e ? i : t)), K(i, n), z(!0), G();
128
+ S(x.map((t) => t.id === e ? i : t)), W(i, n), R(!0), U();
129
129
  }, [
130
- G,
131
- y,
132
- K
133
- ]), Y = c((e, t) => {
130
+ U,
131
+ x,
132
+ W
133
+ ]), q = l((e, t) => {
134
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);
135
+ for (let r of g) {
136
+ let i = t[r];
137
+ if (i === void 0) continue;
138
+ let o = h(i);
139
139
  if (o === null) {
140
- q(e, r, i.numbersOnly);
140
+ G(e, r, a.numbersOnly);
141
141
  return;
142
142
  }
143
143
  n[r] = o;
144
144
  }
145
- J(e, (e) => {
145
+ K(e, (e) => {
146
146
  let t = {
147
147
  ...e,
148
148
  ...n
149
149
  };
150
150
  return "amount" in n ? t : {
151
151
  ...t,
152
- amount: v(t.quantity, t.price, t.amount)
152
+ amount: b(t.quantity, t.price, t.amount)
153
153
  };
154
154
  }, Object.keys(n));
155
155
  }, [
156
- J,
157
- i,
158
- q
159
- ]), X = c((e, t) => {
160
- J(e, (e) => {
156
+ K,
157
+ a,
158
+ G
159
+ ]), J = l((e, t) => {
160
+ S((n) => n.map((n) => n.id === e ? {
161
+ ...n,
162
+ [t]: r(n[t])
163
+ } : n));
164
+ }, []), Y = l((e, t) => {
165
+ K(e, (e) => {
161
166
  let n = Number.parseFloat(e.quantity), r = String(Math.max(1, (Number.isFinite(n) ? n : 0) + t));
162
167
  return {
163
168
  ...e,
164
169
  quantity: r,
165
- amount: v(r, e.price, e.amount)
170
+ amount: b(r, e.price, e.amount)
166
171
  };
167
172
  });
168
- }, [J]), Z = c((e) => {
169
- F((t) => {
173
+ }, [K]), X = l((e) => {
174
+ P((t) => {
170
175
  if (!t?.[e]) return t;
171
176
  let n = { ...t };
172
177
  return delete n[e], Object.keys(n).length ? n : void 0;
173
178
  });
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);
179
+ }, []), Z = l((e) => {
180
+ X(e), S((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), R(!0), U();
181
+ }, [X, U]), ae = l(() => {
182
+ S((e) => [...e, s()]), R(!0), U();
183
+ }, [U]), Q = l((e, t, n) => {
184
+ let r = h(t);
180
185
  if (r === null) {
181
- U(e, i.numbersOnly);
186
+ V(e, a.numbersOnly);
182
187
  return;
183
188
  }
184
- n(r), V(!0), G(), W(e, r);
189
+ n(r), B(!0), U(), H(e, r);
185
190
  }, [
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);
191
+ U,
192
+ a,
193
+ H,
194
+ V
195
+ ]), oe = l((e) => Q("discount", e, w), [Q]), se = l((e) => Q("tax", e, E), [Q]), $ = l(() => w((e) => r(e)), []), ce = l(() => E((e) => r(e)), []), le = l((e) => {
196
+ let t = h(e);
192
197
  if (t === null) {
193
- U("total", i.numbersOnly);
198
+ V("total", a.numbersOnly);
194
199
  return;
195
200
  }
196
- E(t), V(!0), W("total", t), j();
201
+ O(t), B(!0), H("total", t), j();
197
202
  }, [
198
203
  j,
199
- i,
200
- W,
201
- U
202
- ]), oe = u(() => y.map((e) => ({
204
+ a,
205
+ H,
206
+ V
207
+ ]), ue = l(() => {
208
+ O((e) => e === void 0 ? e : r(e));
209
+ }, []), de = d(() => x.map((e) => ({
203
210
  ...e,
204
- onChange: (t) => Y(e.id, t),
205
- onQuantityStep: (t) => X(e.id, t),
206
- onRemove: () => Q(e.id)
211
+ onChange: (t) => q(e.id, t),
212
+ onBlur: (t) => J(e.id, t),
213
+ onQuantityStep: (t) => Y(e.id, t),
214
+ onRemove: () => Z(e.id)
207
215
  })), [
208
- y,
209
- Y,
210
- Q,
211
- X
212
- ]), se = u(() => t(y, C, x), [
213
- y,
214
- C,
215
- x
216
+ J,
217
+ x,
218
+ q,
219
+ Z,
220
+ Y
221
+ ]), fe = d(() => t(x, T, C), [
222
+ x,
223
+ T,
224
+ C
216
225
  ]);
217
226
  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
227
+ values: m,
228
+ errors: ee,
229
+ setErrors: te,
230
+ setSaveFailureMessage: ne,
231
+ lineItemErrors: N,
232
+ setLineItemErrors: P,
233
+ totalsErrors: re,
234
+ setTotalsErrors: M,
235
+ onChange: ie,
236
+ lineItems: x,
237
+ lineItemRows: de,
238
+ discount: C,
239
+ onDiscountChange: oe,
240
+ onDiscountBlur: $,
241
+ tax: T,
242
+ onTaxChange: se,
243
+ onTaxBlur: ce,
244
+ total: D ?? fe,
245
+ totalOverride: D,
246
+ onTotalChange: le,
247
+ onTotalBlur: ue,
248
+ onAddLineItem: ae,
249
+ isTotalsDirty: z,
250
+ isDirty: F || L || z
239
251
  };
240
252
  }
241
253
  //#endregion
242
- export { y as useBillForm };
254
+ export { x as useBillForm };
@@ -437,10 +437,13 @@ function l({ open: l, onOpenChange: u, payableId: $e, readOnly: d = !1, copy: et
437
437
  glCodeUnavailableMessage: J,
438
438
  discount: D.discount,
439
439
  onDiscountChange: D.onDiscountChange,
440
+ onDiscountBlur: D.onDiscountBlur,
440
441
  tax: D.tax,
441
442
  onTaxChange: D.onTaxChange,
443
+ onTaxBlur: D.onTaxBlur,
442
444
  total: D.total,
443
445
  onTotalChange: D.onTotalChange,
446
+ onTotalBlur: D.onTotalBlur,
444
447
  onAddLineItem: D.onAddLineItem,
445
448
  errors: D.lineItemErrors,
446
449
  totalsErrors: D.totalsErrors,
@@ -15,36 +15,36 @@ var D = {
15
15
  tax: t.Optional,
16
16
  total: t.Required
17
17
  };
18
- function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMessage: j, discount: M, onDiscountChange: N, tax: P, onTaxChange: F, total: I, onTotalChange: L, onAddLineItem: R, errors: z, totalsErrors: B, disabled: V, testId: H, labels: U }) {
19
- let W = v(U), G = y(), K = t.length > 1, q = j ? `${G}-gl-code-unavailable` : void 0, J = (e) => `${G}-${e}-error`, Y = (e) => {
20
- let t = B?.[e];
18
+ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMessage: j, discount: M, onDiscountChange: N, onDiscountBlur: P, tax: F, onTaxChange: I, onTaxBlur: L, total: R, onTotalChange: z, onTotalBlur: B, onAddLineItem: V, errors: H, totalsErrors: U, disabled: W, testId: G, labels: K }) {
19
+ let q = v(K), J = y(), Y = t.length > 1, X = j ? `${J}-gl-code-unavailable` : void 0, Z = (e) => `${J}-${e}-error`, Q = (e) => {
20
+ let t = U?.[e];
21
21
  return t ? /* @__PURE__ */ b("p", {
22
- id: J(e),
22
+ id: Z(e),
23
23
  className: "ttw:text-sm ttw:text-destructive ttw:text-right",
24
24
  children: t
25
25
  }) : null;
26
26
  };
27
27
  return /* @__PURE__ */ x("section", {
28
28
  className: "ttw:flex ttw:flex-col ttw:gap-3",
29
- "data-testid": H,
29
+ "data-testid": G,
30
30
  children: [
31
31
  /* @__PURE__ */ b(g, {
32
32
  component: "h2",
33
33
  variant: "h6",
34
34
  className: "ttw:font-semibold",
35
- children: W.heading
35
+ children: q.heading
36
36
  }),
37
37
  /* @__PURE__ */ b("p", {
38
38
  className: "ttw:text-sm ttw:text-muted-foreground",
39
- children: W.helpText
39
+ children: q.helpText
40
40
  }),
41
41
  j ? /* @__PURE__ */ b("span", {
42
- id: q,
42
+ id: X,
43
43
  className: "ttw:sr-only",
44
44
  children: j
45
45
  }) : null,
46
46
  t.map((t, g) => {
47
- let v = `${G}-${t.id}`, y = z?.[t.id], O = (e) => `${v}-${e}-error`, M = (e) => y?.[e], N = (e) => {
47
+ let v = `${J}-${t.id}`, y = H?.[t.id], O = (e) => `${v}-${e}-error`, M = (e) => y?.[e], N = (e) => {
48
48
  let t = M(e);
49
49
  return t ? /* @__PURE__ */ b("p", {
50
50
  id: O(e),
@@ -61,21 +61,21 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
61
61
  className: "ttw:flex ttw:items-center ttw:justify-between ttw:gap-2",
62
62
  children: [/* @__PURE__ */ x("div", {
63
63
  className: "ttw:flex ttw:items-center ttw:gap-2",
64
- children: [K ? /* @__PURE__ */ x("span", {
64
+ children: [Y ? /* @__PURE__ */ x("span", {
65
65
  className: "ttw:text-sm ttw:text-muted-foreground",
66
66
  children: [g + 1, "."]
67
67
  }) : null, /* @__PURE__ */ b(o, {
68
68
  htmlFor: `${v}-description`,
69
69
  requirement: D.description,
70
- labels: W.fieldMarkers,
71
- children: W.description
70
+ labels: q.fieldMarkers,
71
+ children: q.description
72
72
  })]
73
- }), K ? /* @__PURE__ */ b(e, {
73
+ }), Y ? /* @__PURE__ */ b(e, {
74
74
  type: "button",
75
75
  variant: "ghost",
76
76
  size: "icon",
77
- disabled: V,
78
- "aria-label": W.removeLineItem(g + 1),
77
+ disabled: W,
78
+ "aria-label": q.removeLineItem(g + 1),
79
79
  onClick: t.onRemove,
80
80
  children: /* @__PURE__ */ b(T, { className: "ttw:size-4" })
81
81
  }) : null]
@@ -84,9 +84,9 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
84
84
  className: "ttw:flex ttw:flex-col ttw:gap-1.5",
85
85
  children: [/* @__PURE__ */ b(n, {
86
86
  id: `${v}-description`,
87
- placeholder: W.descriptionPlaceholder,
87
+ placeholder: q.descriptionPlaceholder,
88
88
  value: t.description,
89
- disabled: V,
89
+ disabled: W,
90
90
  "aria-required": !0,
91
91
  "aria-invalid": M("description") ? !0 : void 0,
92
92
  "aria-describedby": M("description") ? O("description") : void 0,
@@ -104,8 +104,8 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
104
104
  children: [/* @__PURE__ */ b(o, {
105
105
  htmlFor: `${v}-gl-code`,
106
106
  requirement: D.glCode,
107
- labels: W.fieldMarkers,
108
- children: W.glCode
107
+ labels: q.fieldMarkers,
108
+ children: q.glCode
109
109
  }), j ? /* @__PURE__ */ b(m, { children: /* @__PURE__ */ x(f, { children: [/* @__PURE__ */ b(h, {
110
110
  type: "button",
111
111
  className: "ttw:inline-flex ttw:shrink-0 ttw:cursor-help ttw:text-muted-foreground",
@@ -117,23 +117,23 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
117
117
  className: "ttw:relative",
118
118
  children: [/* @__PURE__ */ x(s, {
119
119
  value: t.glCode,
120
- disabled: V || A,
120
+ disabled: W || A,
121
121
  onValueChange: (e) => t.onChange({ glCode: e }),
122
122
  children: [/* @__PURE__ */ b(u, {
123
123
  id: `${v}-gl-code`,
124
124
  className: _("ttw:w-full", t.glCode && "ttw:[&>svg:last-child]:hidden!"),
125
125
  "aria-invalid": M("glCode") ? !0 : void 0,
126
- "aria-describedby": [M("glCode") ? O("glCode") : null, q].filter(Boolean).join(" ") || void 0,
127
- children: /* @__PURE__ */ b(d, { placeholder: W.glCodePlaceholder })
126
+ "aria-describedby": [M("glCode") ? O("glCode") : null, X].filter(Boolean).join(" ") || void 0,
127
+ children: /* @__PURE__ */ b(d, { placeholder: q.glCodePlaceholder })
128
128
  }), /* @__PURE__ */ b(c, { children: k.map((e) => /* @__PURE__ */ b(l, {
129
129
  value: e.value,
130
130
  children: e.label
131
131
  }, e.value)) })]
132
- }), t.glCode && !(V || A) ? /* @__PURE__ */ b(e, {
132
+ }), t.glCode && !(W || A) ? /* @__PURE__ */ b(e, {
133
133
  type: "button",
134
134
  variant: "ghost",
135
135
  size: "icon-sm",
136
- "aria-label": W.glCodeClear,
136
+ "aria-label": q.glCodeClear,
137
137
  className: "ttw:absolute ttw:top-1/2 ttw:right-1 ttw:-translate-y-1/2",
138
138
  onPointerDown: (e) => {
139
139
  e.preventDefault(), e.stopPropagation();
@@ -156,8 +156,8 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
156
156
  /* @__PURE__ */ b(o, {
157
157
  htmlFor: `${v}-quantity`,
158
158
  requirement: D.quantity,
159
- labels: W.fieldMarkers,
160
- children: W.quantity
159
+ labels: q.fieldMarkers,
160
+ children: q.quantity
161
161
  }),
162
162
  /* @__PURE__ */ x(r, {
163
163
  className: "ttw:h-9 ttw:rounded-md ttw:border ttw:border-input ttw:shadow-xs ttw:has-[:focus-visible]:border-ring ttw:has-[:focus-visible]:ring-[3px] ttw:has-[:focus-visible]:ring-ring/50 ttw:has-[[aria-invalid=true]]:border-destructive ttw:has-[[aria-invalid=true]]:ring-destructive/20",
@@ -167,8 +167,8 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
167
167
  variant: "ghost",
168
168
  size: "icon",
169
169
  className: "ttw:h-full ttw:shrink-0 ttw:rounded-r-none",
170
- disabled: V,
171
- "aria-label": W.decreaseQuantity(g + 1),
170
+ disabled: W,
171
+ "aria-label": q.decreaseQuantity(g + 1),
172
172
  onClick: () => t.onQuantityStep(-1),
173
173
  children: /* @__PURE__ */ b(C, { className: "ttw:size-3.5" })
174
174
  }),
@@ -177,7 +177,7 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
177
177
  inputMode: "decimal",
178
178
  className: "ttw:min-w-0 ttw:flex-1 ttw:rounded-none ttw:border-0 ttw:text-center ttw:shadow-none ttw:focus-visible:ring-0",
179
179
  value: t.quantity,
180
- disabled: V,
180
+ disabled: W,
181
181
  "aria-required": !0,
182
182
  "aria-invalid": M("quantity") ? !0 : void 0,
183
183
  "aria-describedby": M("quantity") ? O("quantity") : void 0,
@@ -188,8 +188,8 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
188
188
  variant: "ghost",
189
189
  size: "icon",
190
190
  className: "ttw:h-full ttw:shrink-0 ttw:rounded-l-none",
191
- disabled: V,
192
- "aria-label": W.increaseQuantity(g + 1),
191
+ disabled: W,
192
+ "aria-label": q.increaseQuantity(g + 1),
193
193
  onClick: () => t.onQuantityStep(1),
194
194
  children: /* @__PURE__ */ b(w, { className: "ttw:size-3.5" })
195
195
  })
@@ -204,24 +204,25 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
204
204
  /* @__PURE__ */ b(o, {
205
205
  htmlFor: `${v}-price`,
206
206
  requirement: D.price,
207
- labels: W.fieldMarkers,
208
- children: W.price
207
+ labels: q.fieldMarkers,
208
+ children: q.price
209
209
  }),
210
210
  /* @__PURE__ */ x(r, { children: [/* @__PURE__ */ b(i, {
211
211
  align: "inline-start",
212
212
  "aria-hidden": !0,
213
- children: W.currencySymbol
213
+ children: q.currencySymbol
214
214
  }), /* @__PURE__ */ b(a, {
215
215
  id: `${v}-price`,
216
216
  "data-has-start-addon": !0,
217
217
  inputMode: "decimal",
218
218
  className: "ttw:text-right ttw:aria-invalid:border-destructive ttw:aria-invalid:ring-destructive/20",
219
219
  value: t.price,
220
- disabled: V,
220
+ disabled: W,
221
221
  "aria-required": !0,
222
222
  "aria-invalid": M("price") ? !0 : void 0,
223
223
  "aria-describedby": M("price") ? O("price") : void 0,
224
- onChange: (e) => t.onChange({ price: e.target.value })
224
+ onChange: (e) => t.onChange({ price: e.target.value }),
225
+ onBlur: () => t.onBlur?.("price")
225
226
  })] }),
226
227
  N("price")
227
228
  ]
@@ -232,24 +233,25 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
232
233
  /* @__PURE__ */ b(o, {
233
234
  htmlFor: `${v}-amount`,
234
235
  requirement: D.amount,
235
- labels: W.fieldMarkers,
236
- children: W.amount
236
+ labels: q.fieldMarkers,
237
+ children: q.amount
237
238
  }),
238
239
  /* @__PURE__ */ x(r, { children: [/* @__PURE__ */ b(i, {
239
240
  align: "inline-start",
240
241
  "aria-hidden": !0,
241
- children: W.currencySymbol
242
+ children: q.currencySymbol
242
243
  }), /* @__PURE__ */ b(a, {
243
244
  id: `${v}-amount`,
244
245
  "data-has-start-addon": !0,
245
246
  inputMode: "decimal",
246
247
  className: "ttw:text-right ttw:aria-invalid:border-destructive ttw:aria-invalid:ring-destructive/20",
247
248
  value: t.amount,
248
- disabled: V,
249
+ disabled: W,
249
250
  "aria-required": !0,
250
251
  "aria-invalid": M("amount") ? !0 : void 0,
251
252
  "aria-describedby": M("amount") ? O("amount") : void 0,
252
- onChange: (e) => t.onChange({ amount: e.target.value })
253
+ onChange: (e) => t.onChange({ amount: e.target.value }),
254
+ onBlur: () => t.onBlur?.("amount")
253
255
  })] }),
254
256
  N("amount")
255
257
  ]
@@ -263,10 +265,10 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
263
265
  /* @__PURE__ */ b(e, {
264
266
  type: "button",
265
267
  variant: "link",
266
- disabled: V,
268
+ disabled: W,
267
269
  className: "ttw:self-start",
268
- onClick: R,
269
- children: W.addLineItem
270
+ onClick: V,
271
+ children: q.addLineItem
270
272
  }),
271
273
  /* @__PURE__ */ x("div", {
272
274
  className: "ttw:flex ttw:flex-col ttw:gap-2 ttw:border-t ttw:border-border ttw:pt-3",
@@ -274,10 +276,10 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
274
276
  /* @__PURE__ */ x("div", {
275
277
  className: "ttw:flex ttw:items-start ttw:justify-between ttw:gap-4",
276
278
  children: [/* @__PURE__ */ b(o, {
277
- htmlFor: `${G}-discount`,
279
+ htmlFor: `${J}-discount`,
278
280
  requirement: O.discount,
279
- labels: W.fieldMarkers,
280
- children: W.discount
281
+ labels: q.fieldMarkers,
282
+ children: q.discount
281
283
  }), /* @__PURE__ */ x("div", {
282
284
  className: "ttw:flex ttw:flex-col ttw:items-end ttw:gap-1.5",
283
285
  children: [/* @__PURE__ */ x(r, {
@@ -285,28 +287,29 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
285
287
  children: [/* @__PURE__ */ b(i, {
286
288
  align: "inline-start",
287
289
  "aria-hidden": !0,
288
- children: W.currencySymbol
290
+ children: q.currencySymbol
289
291
  }), /* @__PURE__ */ b(a, {
290
- id: `${G}-discount`,
292
+ id: `${J}-discount`,
291
293
  "data-has-start-addon": !0,
292
294
  inputMode: "decimal",
293
295
  className: "ttw:text-right ttw:aria-invalid:border-destructive ttw:aria-invalid:ring-destructive/20",
294
296
  value: M,
295
- disabled: V,
296
- "aria-invalid": B?.discount ? !0 : void 0,
297
- "aria-describedby": B?.discount ? J("discount") : void 0,
298
- onChange: (e) => N(e.target.value)
297
+ disabled: W,
298
+ "aria-invalid": U?.discount ? !0 : void 0,
299
+ "aria-describedby": U?.discount ? Z("discount") : void 0,
300
+ onChange: (e) => N(e.target.value),
301
+ onBlur: P
299
302
  })]
300
- }), Y("discount")]
303
+ }), Q("discount")]
301
304
  })]
302
305
  }),
303
306
  /* @__PURE__ */ x("div", {
304
307
  className: "ttw:flex ttw:items-start ttw:justify-between ttw:gap-4",
305
308
  children: [/* @__PURE__ */ b(o, {
306
- htmlFor: `${G}-tax`,
309
+ htmlFor: `${J}-tax`,
307
310
  requirement: O.tax,
308
- labels: W.fieldMarkers,
309
- children: W.tax
311
+ labels: q.fieldMarkers,
312
+ children: q.tax
310
313
  }), /* @__PURE__ */ x("div", {
311
314
  className: "ttw:flex ttw:flex-col ttw:items-end ttw:gap-1.5",
312
315
  children: [/* @__PURE__ */ x(r, {
@@ -314,29 +317,30 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
314
317
  children: [/* @__PURE__ */ b(i, {
315
318
  align: "inline-start",
316
319
  "aria-hidden": !0,
317
- children: W.currencySymbol
320
+ children: q.currencySymbol
318
321
  }), /* @__PURE__ */ b(a, {
319
- id: `${G}-tax`,
322
+ id: `${J}-tax`,
320
323
  "data-has-start-addon": !0,
321
324
  inputMode: "decimal",
322
325
  className: "ttw:text-right ttw:aria-invalid:border-destructive ttw:aria-invalid:ring-destructive/20",
323
- value: P,
324
- disabled: V,
325
- "aria-invalid": B?.tax ? !0 : void 0,
326
- "aria-describedby": B?.tax ? J("tax") : void 0,
327
- onChange: (e) => F(e.target.value)
326
+ value: F,
327
+ disabled: W,
328
+ "aria-invalid": U?.tax ? !0 : void 0,
329
+ "aria-describedby": U?.tax ? Z("tax") : void 0,
330
+ onChange: (e) => I(e.target.value),
331
+ onBlur: L
328
332
  })]
329
- }), Y("tax")]
333
+ }), Q("tax")]
330
334
  })]
331
335
  }),
332
336
  /* @__PURE__ */ x("div", {
333
337
  className: "ttw:flex ttw:items-start ttw:justify-between ttw:gap-4",
334
338
  children: [/* @__PURE__ */ b(o, {
335
- htmlFor: `${G}-total`,
339
+ htmlFor: `${J}-total`,
336
340
  className: "ttw:font-semibold",
337
341
  requirement: O.total,
338
- labels: W.fieldMarkers,
339
- children: W.totalAmount
342
+ labels: q.fieldMarkers,
343
+ children: q.totalAmount
340
344
  }), /* @__PURE__ */ x("div", {
341
345
  className: "ttw:flex ttw:flex-col ttw:items-end ttw:gap-1.5",
342
346
  children: [/* @__PURE__ */ x(r, {
@@ -344,20 +348,21 @@ function k({ items: t, glCodeOptions: k, glCodeDisabled: A, glCodeUnavailableMes
344
348
  children: [/* @__PURE__ */ b(i, {
345
349
  align: "inline-start",
346
350
  "aria-hidden": !0,
347
- children: W.currencySymbol
351
+ children: q.currencySymbol
348
352
  }), /* @__PURE__ */ b(a, {
349
- id: `${G}-total`,
353
+ id: `${J}-total`,
350
354
  "data-has-start-addon": !0,
351
355
  inputMode: "decimal",
352
356
  className: "ttw:text-right ttw:font-semibold ttw:aria-invalid:border-destructive ttw:aria-invalid:ring-destructive/20",
353
- value: I,
354
- disabled: V,
357
+ value: R,
358
+ disabled: W,
355
359
  "aria-required": !0,
356
- "aria-invalid": B?.total ? !0 : void 0,
357
- "aria-describedby": B?.total ? J("total") : void 0,
358
- onChange: (e) => L(e.target.value)
360
+ "aria-invalid": U?.total ? !0 : void 0,
361
+ "aria-describedby": U?.total ? Z("total") : void 0,
362
+ onChange: (e) => z(e.target.value),
363
+ onBlur: B
359
364
  })]
360
- }), Y("total")]
365
+ }), Q("total")]
361
366
  })]
362
367
  })
363
368
  ]
@@ -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.62", n = "b4c35830c633c55357a2f8b2a88df4fd4dcf68b9", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.5.63", n = "34ab770a11f7fab14c9dfc21d23b7685134bb2b4", 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.62",
3
+ "version": "0.5.63",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {