@tesouro/embedded-components-react 0.4.17 → 0.4.19

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.d.ts CHANGED
@@ -1109,6 +1109,9 @@ interface WidgetTokenManager {
1109
1109
  subscribe(listener: () => void): () => void;
1110
1110
  }
1111
1111
 
1112
+ declare const DOCUMENT_KINDS: readonly ["invoice", "quote", "credit_note"];
1113
+ type ReceivableDocumentKind = (typeof DOCUMENT_KINDS)[number];
1114
+
1112
1115
  interface WidgetTokenRefreshProviderProps {
1113
1116
  fetcher: WidgetTokenFetcher;
1114
1117
  leadSeconds?: number;
@@ -3990,7 +3993,7 @@ interface ReceivableActionDialogLabels {
3990
3993
  confirmButton: string;
3991
3994
  }
3992
3995
 
3993
- type ReceivableDocumentType = 'invoice' | 'quote' | 'credit_note';
3996
+ type ReceivableDocumentType = ReceivableDocumentKind;
3994
3997
  type ReceivablesWidgetTab = 'invoices' | 'quotes' | 'credit_notes';
3995
3998
 
3996
3999
  interface ReceivableMessageLabels {
@@ -634,6 +634,9 @@ interface WidgetProviderProps extends WidgetProviderBaseProps {
634
634
  providerLabels?: Partial<WidgetProviderLabels>;
635
635
  }
636
636
 
637
+ declare const DOCUMENT_KINDS: readonly ["invoice", "quote", "credit_note"];
638
+ type ReceivableDocumentKind = (typeof DOCUMENT_KINDS)[number];
639
+
637
640
  interface AddressFieldGroupLabels {
638
641
  line1: string;
639
642
  line2: string;
@@ -970,7 +973,7 @@ interface ReceivableActionDialogLabels {
970
973
  confirmButton: string;
971
974
  }
972
975
 
973
- type ReceivableDocumentType = 'invoice' | 'quote' | 'credit_note';
976
+ type ReceivableDocumentType = ReceivableDocumentKind;
974
977
  type ReceivablesWidgetTab = 'invoices' | 'quotes' | 'credit_notes';
975
978
 
976
979
  interface ReceivableMessageLabels {
@@ -1,24 +1,25 @@
1
+ import { minorExponentForCurrency as e } from "../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
1
2
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js
2
- var e = /^(\d{4})-(\d{2})-(\d{2})$/, t = {
3
+ var t = /^(\d{4})-(\d{2})-(\d{2})$/, n = {
3
4
  to: "",
4
5
  cc: "",
5
6
  bcc: "",
6
7
  subject: "",
7
8
  body: ""
8
- }, n = {
9
+ }, r = {
9
10
  mode: "full",
10
11
  amountPaid: "",
11
12
  paidAt: "",
12
13
  comment: ""
13
14
  };
14
- function r() {
15
+ function i() {
15
16
  return {
16
17
  id: typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`,
17
18
  productId: "",
18
19
  quantity: "1"
19
20
  };
20
21
  }
21
- function i() {
22
+ function a() {
22
23
  return {
23
24
  type: "invoice",
24
25
  customerId: "",
@@ -27,16 +28,16 @@ function i() {
27
28
  dueDate: "",
28
29
  memo: "",
29
30
  paymentTermsId: "",
30
- lineItems: [r()]
31
+ lineItems: [i()]
31
32
  };
32
33
  }
33
- function a(e) {
34
+ function o(e) {
34
35
  return e === "quotes" ? "quote" : e === "credit_notes" ? "credit_note" : "invoice";
35
36
  }
36
- function o(e) {
37
+ function s(e) {
37
38
  return e === "quote" ? "quotes" : e === "credit_note" ? "credit_notes" : "invoices";
38
39
  }
39
- function s(e) {
40
+ function c(e) {
40
41
  return (e?.length ? e : [
41
42
  "invoices",
42
43
  "quotes",
@@ -47,44 +48,46 @@ function s(e) {
47
48
  "credit_notes"
48
49
  ].includes(e) && n.indexOf(e) === t);
49
50
  }
50
- function c({ defaultTab: e, enabledTabs: t }) {
51
+ function l({ defaultTab: e, enabledTabs: t }) {
51
52
  return e && t.includes(e) ? e : t[0] ?? "invoices";
52
53
  }
53
- function l(e, t) {
54
+ function u(e, t) {
54
55
  if (!e) return t;
55
- let n = u(e);
56
+ let n = d(e);
56
57
  return Number.isNaN(n.getTime()) ? t : new Intl.DateTimeFormat(void 0, {
57
58
  day: "numeric",
58
59
  month: "short",
59
60
  year: "numeric"
60
61
  }).format(n);
61
62
  }
62
- function u(t) {
63
- let n = e.exec(t);
64
- if (!n) return new Date(t);
63
+ function d(e) {
64
+ let n = t.exec(e);
65
+ if (!n) return new Date(e);
65
66
  let r = Number(n[1]), i = Number(n[2]) - 1, a = Number(n[3]), o = new Date(r, i, a);
66
67
  return o.getFullYear() !== r || o.getMonth() !== i || o.getDate() !== a ? /* @__PURE__ */ new Date(NaN) : o;
67
68
  }
68
- function d({ amount: e, currency: t, fallback: n }) {
69
- return e == null || !t ? n : new Intl.NumberFormat(void 0, {
70
- currency: t,
69
+ function f({ amount: t, currency: n, fallback: r }) {
70
+ return t == null || !n ? r : new Intl.NumberFormat(void 0, {
71
+ currency: n,
71
72
  style: "currency"
72
- }).format(e / 100);
73
+ }).format(t / 10 ** e(n));
73
74
  }
74
- function f(e) {
75
- let t = Number(e);
76
- if (Number.isFinite(t)) return Math.round(t * 100);
75
+ function p(t, n) {
76
+ let r = Number(t);
77
+ if (!Number.isFinite(r)) return;
78
+ let i = n ? e(n) : 2;
79
+ return Math.round(r * 10 ** i);
77
80
  }
78
- function p(e, t) {
81
+ function m(e, t) {
79
82
  return e.document_id || t.untitledDocument;
80
83
  }
81
- function m(e, t) {
84
+ function h(e, t) {
82
85
  return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
83
86
  }
84
- function h(e) {
87
+ function g(e) {
85
88
  return e === "paid" || e === "accepted" || e === "issued" || e === "recurring" ? "success" : e === "draft" || e === "issuing" ? "neutral" : e === "overdue" || e === "partially_paid" ? "warning" : e === "failed" || e === "declined" || e === "expired" || e === "uncollectible" || e === "canceled" || e === "deleted" ? "danger" : "info";
86
89
  }
87
- function g(e) {
90
+ function _(e) {
88
91
  let t = e.status === "draft", n = e.status === "issued", r = e.type === "invoice", i = e.type === "quote", a = e.type === "credit_note", o = r && [
89
92
  "issued",
90
93
  "overdue",
@@ -114,48 +117,48 @@ function g(e) {
114
117
  ].includes(e.status) && !a
115
118
  };
116
119
  }
117
- function _({ receivables: e, messages: t }) {
120
+ function v({ receivables: e, messages: t }) {
118
121
  return e.map((e) => {
119
122
  let n = e.type === "invoice" ? e.amount_due : void 0;
120
123
  return {
121
124
  id: e.id,
122
125
  type: e.type,
123
- documentLabel: p(e, t),
126
+ documentLabel: m(e, t),
124
127
  customerLabel: e.counterpart_name || t.unknownCustomer,
125
128
  status: e.status,
126
- statusTone: h(e.status),
127
- issueDateLabel: l(e.issue_date, t.notAvailable),
128
- dueDateLabel: l(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
129
- totalLabel: d({
129
+ statusTone: g(e.status),
130
+ issueDateLabel: u(e.issue_date, t.notAvailable),
131
+ dueDateLabel: u(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
132
+ totalLabel: f({
130
133
  amount: e.total_amount,
131
134
  currency: e.currency,
132
135
  fallback: t.notAvailable
133
136
  }),
134
- amountDueLabel: d({
137
+ amountDueLabel: f({
135
138
  amount: n,
136
139
  currency: e.currency,
137
140
  fallback: t.notAvailable
138
141
  }),
139
- actions: g(e)
142
+ actions: _(e)
140
143
  };
141
144
  });
142
145
  }
143
- function v({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
146
+ function y({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
144
147
  if (!e) return;
145
148
  let a = e.type === "invoice" ? e.amount_due : void 0, o = e.type === "quote" ? e.expiry_date : e.due_date;
146
149
  return {
147
150
  id: e.id,
148
151
  type: e.type,
149
- title: p(e, i),
152
+ title: m(e, i),
150
153
  customerLabel: e.counterpart_name || i.unknownCustomer,
151
154
  status: e.status,
152
- statusTone: h(e.status),
153
- totalLabel: d({
155
+ statusTone: g(e.status),
156
+ totalLabel: f({
154
157
  amount: e.total_amount,
155
158
  currency: e.currency,
156
159
  fallback: i.notAvailable
157
160
  }),
158
- amountDueLabel: d({
161
+ amountDueLabel: f({
159
162
  amount: a,
160
163
  currency: e.currency,
161
164
  fallback: i.notAvailable
@@ -164,11 +167,11 @@ function v({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
164
167
  summaryItems: [
165
168
  {
166
169
  label: i.summaryDocumentType,
167
- value: m(e.type, i)
170
+ value: h(e.type, i)
168
171
  },
169
172
  {
170
173
  label: i.summaryDocumentNumber,
171
- value: p(e, i)
174
+ value: m(e, i)
172
175
  },
173
176
  {
174
177
  label: i.summaryCustomer,
@@ -176,23 +179,23 @@ function v({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
176
179
  },
177
180
  {
178
181
  label: i.summaryIssued,
179
- value: l(e.issue_date, i.notAvailable)
182
+ value: u(e.issue_date, i.notAvailable)
180
183
  },
181
184
  {
182
185
  label: i.summaryDue,
183
- value: l(o, i.notAvailable)
186
+ value: u(o, i.notAvailable)
184
187
  },
185
188
  {
186
189
  label: i.summaryCreated,
187
- value: l(e.created_at, i.notAvailable)
190
+ value: u(e.created_at, i.notAvailable)
188
191
  },
189
192
  {
190
193
  label: i.summaryUpdated,
191
- value: l(e.updated_at, i.notAvailable)
194
+ value: u(e.updated_at, i.notAvailable)
192
195
  },
193
196
  {
194
197
  label: i.summaryTotal,
195
- value: d({
198
+ value: f({
196
199
  amount: e.total_amount,
197
200
  currency: e.currency,
198
201
  fallback: i.notAvailable
@@ -200,7 +203,7 @@ function v({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
200
203
  },
201
204
  {
202
205
  label: i.summaryAmountDue,
203
- value: d({
206
+ value: f({
204
207
  amount: a,
205
208
  currency: e.currency,
206
209
  fallback: i.notAvailable
@@ -211,12 +214,12 @@ function v({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
211
214
  id: t.product.id || String(n),
212
215
  name: t.product.name,
213
216
  quantityLabel: String(t.quantity),
214
- unitPriceLabel: d({
217
+ unitPriceLabel: f({
215
218
  amount: t.product.price?.value,
216
219
  currency: t.product.price?.currency || e.currency,
217
220
  fallback: i.notAvailable
218
221
  }),
219
- totalLabel: d({
222
+ totalLabel: f({
220
223
  amount: t.total_after_tax ?? t.total_before_tax,
221
224
  currency: e.currency,
222
225
  fallback: i.notAvailable
@@ -224,23 +227,23 @@ function v({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
224
227
  })),
225
228
  activityItems: t.map((e) => ({
226
229
  id: e.id,
227
- title: y(e.event_type, i),
230
+ title: b(e.event_type, i),
228
231
  description: e.event_type,
229
- timestampLabel: l(e.timestamp, i.notAvailable)
232
+ timestampLabel: u(e.timestamp, i.notAvailable)
230
233
  })),
231
234
  mailItems: n.map((e) => ({
232
235
  id: e.id,
233
236
  statusLabel: e.status,
234
- recipientsLabel: b(e, i),
235
- sentAtLabel: l(e.created_at, i.notAvailable)
237
+ recipientsLabel: x(e, i),
238
+ sentAtLabel: u(e.created_at, i.notAvailable)
236
239
  })),
237
- actions: g(e)
240
+ actions: _(e)
238
241
  };
239
242
  }
240
- function y(e, t) {
243
+ function b(e, t) {
241
244
  return e === "status_changed" ? t.activityStatusChanged : e === "receivable_created" ? t.activityReceivableCreated : e === "receivable_updated" ? t.activityReceivableUpdated : e === "payment_received" ? t.activityPaymentReceived : e === "mail_sent" ? t.activityMailSent : t.activityUnknown;
242
245
  }
243
- function b(e, t) {
246
+ function x(e, t) {
244
247
  let n = [
245
248
  ...e.recipients?.to ?? [],
246
249
  ...e.recipients?.cc ?? [],
@@ -248,7 +251,7 @@ function b(e, t) {
248
251
  ].map((e) => e.email).filter(Boolean);
249
252
  return n.length > 0 ? n.join(", ") : t.recipientsNone;
250
253
  }
251
- function x({ values: e, billingAddressId: t, messages: n }) {
254
+ function S({ values: e, billingAddressId: t, messages: n }) {
252
255
  let r = {};
253
256
  e.customerId ? t || (r.customerId = n.customerAddressRequired) : r.customerId = n.customerRequired, e.currency || (r.currency = n.currencyRequired);
254
257
  for (let t of e.lineItems) {
@@ -260,10 +263,10 @@ function x({ values: e, billingAddressId: t, messages: n }) {
260
263
  }
261
264
  return r;
262
265
  }
263
- function S(e) {
266
+ function C(e) {
264
267
  return Object.keys(e).length > 0;
265
268
  }
266
- function C({ values: e, billingAddressId: t }) {
269
+ function w({ values: e, billingAddressId: t }) {
267
270
  let n = e.lineItems.map((e) => ({
268
271
  product_id: e.productId,
269
272
  quantity: Number(e.quantity)
@@ -285,25 +288,25 @@ function C({ values: e, billingAddressId: t }) {
285
288
  type: "invoice"
286
289
  };
287
290
  }
288
- function w(e) {
289
- let t = e.type === "quote" ? "quote" : "invoice", n = e.type === "invoice" ? e.payment_terms?.id ?? "" : "", a = e.line_items.map((e) => ({
290
- id: r().id,
291
+ function T(e) {
292
+ let t = e.type === "quote" ? "quote" : "invoice", n = e.type === "invoice" ? e.payment_terms?.id ?? "" : "", r = e.line_items.map((e) => ({
293
+ id: i().id,
291
294
  productId: e.product.id || "",
292
295
  quantity: String(e.quantity)
293
296
  })).filter((e) => e.productId);
294
297
  return {
295
- ...i(),
298
+ ...a(),
296
299
  type: t,
297
300
  customerId: e.counterpart_id,
298
301
  currency: e.currency,
299
- issueDate: D(e.issue_date),
300
- dueDate: D(e.type === "quote" ? e.expiry_date : e.due_date),
302
+ issueDate: O(e.issue_date),
303
+ dueDate: O(e.type === "quote" ? e.expiry_date : e.due_date),
301
304
  memo: e.memo ?? "",
302
305
  paymentTermsId: n,
303
- lineItems: a.length > 0 ? a : [r()]
306
+ lineItems: r.length > 0 ? r : [i()]
304
307
  };
305
308
  }
306
- function T({ values: e, billingAddressId: t }) {
309
+ function E({ values: e, billingAddressId: t }) {
307
310
  let n = {
308
311
  counterpart_billing_address_id: t,
309
312
  counterpart_id: e.customerId,
@@ -322,57 +325,57 @@ function T({ values: e, billingAddressId: t }) {
322
325
  payment_terms: !e.paymentTermsId && e.dueDate ? { term_final: { end_date: e.dueDate } } : void 0
323
326
  } };
324
327
  }
325
- function E(e) {
328
+ function D(e) {
326
329
  return { data: e.lineItems.map((e) => ({
327
330
  product_id: e.productId,
328
331
  quantity: Number(e.quantity)
329
332
  })) };
330
333
  }
331
- function D(e) {
334
+ function O(e) {
332
335
  return e?.slice(0, 10) ?? "";
333
336
  }
334
- function O(e) {
337
+ function k(e) {
335
338
  return (e ?? []).map((e) => ({
336
339
  value: e.id,
337
340
  label: e.name
338
341
  }));
339
342
  }
340
- function k(e, t) {
343
+ function A(e, t) {
341
344
  let n = {};
342
345
  return e.to.trim() || (n.to = t.sendToRequired), e.subject.trim() || (n.subject = t.sendSubjectRequired), e.body.trim() || (n.body = t.sendBodyRequired), n;
343
346
  }
344
- function A(e) {
347
+ function j(e) {
345
348
  return Object.keys(e).length > 0;
346
349
  }
347
- function j(e) {
350
+ function M(e) {
348
351
  return e.split(",").map((e) => e.trim()).filter(Boolean);
349
352
  }
350
- function M(e, t) {
351
- let n = {};
353
+ function N(e, t, n) {
354
+ let r = {};
352
355
  if (e.mode === "partial") {
353
- let r = f(e.amountPaid);
354
- (!r || r <= 0) && (n.amountPaid = t.paymentAmountInvalid);
356
+ let i = p(e.amountPaid, n);
357
+ (!i || i <= 0) && (r.amountPaid = t.paymentAmountInvalid);
355
358
  }
356
- return n;
359
+ return r;
357
360
  }
358
- function N(e) {
361
+ function P(e) {
359
362
  return Object.keys(e).length > 0;
360
363
  }
361
- function P(e, n) {
364
+ function F(e, t) {
362
365
  return {
363
- ...t,
366
+ ...n,
364
367
  to: e?.counterpart_contact?.email ?? "",
365
- subject: e?.document_id ? `${n.sendSubjectDefault} ${e.document_id}` : n.sendSubjectDefault,
366
- body: n.sendBodyDefault
368
+ subject: e?.document_id ? `${t.sendSubjectDefault} ${e.document_id}` : t.sendSubjectDefault,
369
+ body: t.sendBodyDefault
367
370
  };
368
371
  }
369
- function F() {
372
+ function I() {
370
373
  return {
371
- ...n,
374
+ ...r,
372
375
  paidAt: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
373
376
  };
374
377
  }
375
- function I() {
378
+ function L() {
376
379
  return [
377
380
  "draft",
378
381
  "issued",
@@ -392,4 +395,4 @@ function I() {
392
395
  }));
393
396
  }
394
397
  //#endregion
395
- export { n as EMPTY_RECEIVABLE_PAYMENT_VALUES, t as EMPTY_RECEIVABLE_SEND_VALUES, g as buildReceivableActions, v as buildReceivableDetailsView, _ as buildReceivableRows, s as coerceEnabledTabs, i as createEmptyReceivableFormValues, r as createLineItem, F as defaultPaymentValues, P as defaultSendValues, l as formatDate, d as formatMoney, f as fromMajorUnits, p as getDocumentTitle, m as getDocumentTypeLabel, O as getPaymentTermOptions, h as getStatusTone, N as hasPaymentErrors, S as hasReceivableFormErrors, A as hasSendErrors, C as receivableFormValuesToCreatePayload, E as receivableFormValuesToLineItemsPayload, T as receivableFormValuesToUpdatePayload, w as receivableToFormValues, c as resolveInitialTab, j as splitEmailList, I as statusFilterOptions, o as tabForType, a as typeForTab, M as validatePaymentValues, x as validateReceivableForm, k as validateSendValues };
398
+ export { r as EMPTY_RECEIVABLE_PAYMENT_VALUES, n as EMPTY_RECEIVABLE_SEND_VALUES, _ as buildReceivableActions, y as buildReceivableDetailsView, v as buildReceivableRows, c as coerceEnabledTabs, a as createEmptyReceivableFormValues, i as createLineItem, I as defaultPaymentValues, F as defaultSendValues, u as formatDate, f as formatMoney, p as fromMajorUnits, m as getDocumentTitle, h as getDocumentTypeLabel, k as getPaymentTermOptions, g as getStatusTone, P as hasPaymentErrors, C as hasReceivableFormErrors, j as hasSendErrors, w as receivableFormValuesToCreatePayload, D as receivableFormValuesToLineItemsPayload, E as receivableFormValuesToUpdatePayload, T as receivableToFormValues, l as resolveInitialTab, M as splitEmailList, L as statusFilterOptions, s as tabForType, o as typeForTab, N as validatePaymentValues, S as validateReceivableForm, A as validateSendValues };
@@ -5,74 +5,76 @@
5
5
  import { extractApiErrorMessage as e } from "../../../shared/util/dist/lib/apiErrors.js";
6
6
  import { defaultPaymentValues as t, defaultSendValues as n, fromMajorUnits as r, hasPaymentErrors as i, hasSendErrors as a, splitEmailList as o, validatePaymentValues as s, validateSendValues as c } from "./index5.js";
7
7
  import { useSendReceivableEmailMutation as l } from "../../data-access/dist/index3.js";
8
- import { useAcceptReceivableMutation as ee, useCancelReceivableMutation as u, useCloneReceivableMutation as d, useDeclineReceivableMutation as f, useDeleteReceivableMutation as p, useIssueReceivableMutation as m } from "../../data-access/dist/index4.js";
9
- import { useMarkReceivablePaidMutation as h, useMarkReceivablePartiallyPaidMutation as g, useMarkReceivableUncollectibleMutation as _ } from "../../data-access/dist/index5.js";
8
+ import { useAcceptReceivableMutation as ee, useCancelReceivableMutation as te, useCloneReceivableMutation as u, useDeclineReceivableMutation as d, useDeleteReceivableMutation as f, useIssueReceivableMutation as p } from "../../data-access/dist/index4.js";
9
+ import { useMarkReceivablePaidMutation as m, useMarkReceivablePartiallyPaidMutation as h, useMarkReceivableUncollectibleMutation as g } from "../../data-access/dist/index5.js";
10
10
  import "../../data-access/dist/index.js";
11
- import { useCallback as v, useState as y } from "react";
11
+ import { useCallback as _, useState as v } from "react";
12
12
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js
13
- function b({ selectedReceivable: b, messages: S, onCreated: C, onDeleted: w }) {
14
- let T = m(), E = u(), D = d(), O = ee(), k = f(), A = p(), j = l(), M = h(), N = g(), P = _(), [F, I] = y(), [te, L] = y(), [R, z] = y(), [B, V] = y(() => n(void 0, S)), [H, U] = y({}), [W, G] = y(), [K, q] = y(() => t()), [J, Y] = y({}), X = v((e, r, i) => {
13
+ function y({ selectedReceivable: y, messages: x, onCreated: S, onDeleted: C }) {
14
+ let w = p(), T = te(), E = u(), D = ee(), O = d(), k = f(), A = l(), j = m(), M = h(), N = g(), [P, F] = v(), [I, L] = v(), [R, z] = v(), [B, V] = v(() => n(void 0, x)), [H, U] = v({}), [W, G] = v(), [K, q] = v(() => t()), [J, Y] = v({}), X = _((e, r, i) => {
15
15
  let a = "documentLabel" in r ? r.documentLabel : r.title, o = {
16
16
  id: r.id,
17
17
  type: r.type,
18
18
  title: a,
19
19
  action: e
20
- };
20
+ }, s = i === void 0 ? y : i ?? void 0;
21
21
  if (e === "send") {
22
- let e = i === void 0 ? b : i ?? void 0;
23
- z(o), V(n(e, S)), U({});
22
+ z(o), V(n(s, x)), U({});
24
23
  return;
25
24
  }
26
25
  if (e === "recordPayment") {
27
- G(o), q(t()), Y({});
26
+ G({
27
+ ...o,
28
+ currency: s?.currency
29
+ }), q(t()), Y({});
28
30
  return;
29
31
  }
30
- L(void 0), I(o);
31
- }, [S, b]), Z = v(() => {
32
- I(void 0), L(void 0);
33
- }, []), Q = v(() => {
32
+ L(void 0), F(o);
33
+ }, [x, y]), Z = _(() => {
34
+ F(void 0), L(void 0);
35
+ }, []), Q = _(() => {
34
36
  z(void 0), U({});
35
- }, []), $ = v(() => {
37
+ }, []), $ = _(() => {
36
38
  G(void 0), Y({});
37
- }, []), ne = v(async () => {
38
- if (!F) return;
39
- let t = { receivable_id: F.id };
39
+ }, []), ne = _(async () => {
40
+ if (!P) return;
41
+ let t = { receivable_id: P.id };
40
42
  try {
41
- if (F.action === "issue") await T.mutateAsync({ path: t });
42
- else if (F.action === "cancel") await E.mutateAsync({ path: t });
43
- else if (F.action === "clone") {
44
- let e = await D.mutateAsync({ path: t });
45
- e?.id && C?.(e.id, e.type);
46
- } else F.action === "accept" ? await O.mutateAsync({ path: t }) : F.action === "decline" ? await k.mutateAsync({ path: t }) : F.action === "delete" ? (await A.mutateAsync({ path: t }), w?.(F.id)) : F.action === "markPaid" ? await M.mutateAsync({
43
+ if (P.action === "issue") await w.mutateAsync({ path: t });
44
+ else if (P.action === "cancel") await T.mutateAsync({ path: t });
45
+ else if (P.action === "clone") {
46
+ let e = await E.mutateAsync({ path: t });
47
+ e?.id && S?.(e.id, e.type);
48
+ } else P.action === "accept" ? await D.mutateAsync({ path: t }) : P.action === "decline" ? await O.mutateAsync({ path: t }) : P.action === "delete" ? (await k.mutateAsync({ path: t }), C?.(P.id)) : P.action === "markPaid" ? await j.mutateAsync({
47
49
  path: t,
48
50
  body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
49
- }) : F.action === "markUncollectible" && await P.mutateAsync({ path: t });
50
- I(void 0), L(void 0);
51
+ }) : P.action === "markUncollectible" && await N.mutateAsync({ path: t });
52
+ F(void 0), L(void 0);
51
53
  } catch (t) {
52
- L(e(t) ?? S.genericError);
54
+ L(e(t) ?? x.genericError);
53
55
  }
54
56
  }, [
55
- O,
56
- F,
57
- E,
58
57
  D,
59
- k,
60
- A,
58
+ P,
61
59
  T,
62
- M,
63
- S.genericError,
64
- C,
60
+ E,
61
+ O,
62
+ k,
65
63
  w,
66
- P
67
- ]), re = v(async () => {
64
+ j,
65
+ x.genericError,
66
+ S,
67
+ C,
68
+ N
69
+ ]), re = _(async () => {
68
70
  if (!R) return;
69
- let t = c(B, S);
71
+ let t = c(B, x);
70
72
  if (a(t)) {
71
73
  U(t);
72
74
  return;
73
75
  }
74
76
  try {
75
- await j.mutateAsync({
77
+ await A.mutateAsync({
76
78
  path: { receivable_id: R.id },
77
79
  body: {
78
80
  body_text: B.body,
@@ -85,72 +87,72 @@ function b({ selectedReceivable: b, messages: S, onCreated: C, onDeleted: w }) {
85
87
  }
86
88
  }), Q();
87
89
  } catch (t) {
88
- U({ form: e(t) ?? S.genericError });
90
+ U({ form: e(t) ?? x.genericError });
89
91
  }
90
92
  }, [
91
93
  Q,
92
- S,
93
- j,
94
+ x,
95
+ A,
94
96
  R,
95
97
  B
96
- ]), ie = v(async () => {
98
+ ]), ie = _(async () => {
97
99
  if (!W) return;
98
- let t = s(K, S);
100
+ let t = s(K, x, W.currency);
99
101
  if (i(t)) {
100
102
  Y(t);
101
103
  return;
102
104
  }
103
105
  try {
104
106
  let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
105
- K.mode === "full" ? await M.mutateAsync({
107
+ K.mode === "full" ? await j.mutateAsync({
106
108
  path: e,
107
109
  body: {
108
110
  comment: K.comment || void 0,
109
111
  paid_at: t
110
112
  }
111
- }) : await N.mutateAsync({
113
+ }) : await M.mutateAsync({
112
114
  path: e,
113
115
  body: {
114
- amount_paid: r(K.amountPaid) ?? 0,
116
+ amount_paid: r(K.amountPaid, W.currency) ?? 0,
115
117
  comment: K.comment || void 0
116
118
  }
117
119
  }), $();
118
120
  } catch (t) {
119
- Y({ form: e(t) ?? S.genericError });
121
+ Y({ form: e(t) ?? x.genericError });
120
122
  }
121
123
  }, [
122
124
  $,
125
+ j,
126
+ x,
123
127
  M,
124
- S,
125
- N,
126
128
  W,
127
129
  K
128
130
  ]);
129
131
  return {
130
- actionTarget: F,
131
- actionDialog: F ? x(F.action, S) : void 0,
132
- actionError: te,
133
- actionInProgress: T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || A.isPending || M.isPending || P.isPending,
132
+ actionTarget: P,
133
+ actionDialog: P ? b(P.action, x) : void 0,
134
+ actionError: I,
135
+ actionInProgress: w.isPending || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || j.isPending || N.isPending,
134
136
  openAction: X,
135
137
  closeAction: Z,
136
138
  confirmAction: ne,
137
139
  sendOpen: !!R,
138
140
  sendValues: B,
139
141
  sendErrors: H,
140
- sendInProgress: j.isPending,
142
+ sendInProgress: A.isPending,
141
143
  setSendValues: V,
142
144
  closeSend: Q,
143
145
  submitSend: re,
144
146
  paymentOpen: !!W,
145
147
  paymentValues: K,
146
148
  paymentErrors: J,
147
- paymentInProgress: M.isPending || N.isPending,
149
+ paymentInProgress: j.isPending || M.isPending,
148
150
  setPaymentValues: q,
149
151
  closePayment: $,
150
152
  submitPayment: ie
151
153
  };
152
154
  }
153
- function x(e, t) {
155
+ function b(e, t) {
154
156
  return e === "issue" ? {
155
157
  title: t.issueTitle,
156
158
  description: t.issueDescription,
@@ -190,4 +192,4 @@ function x(e, t) {
190
192
  };
191
193
  }
192
194
  //#endregion
193
- export { b as useReceivableActions };
195
+ export { y as useReceivableActions };
@@ -430,7 +430,7 @@ var We = e.object({ total: e.union([e.int().min(-2147483648, { error: "Invalid v
430
430
  bank_account_id: e.uuid().nullish(),
431
431
  type: e.literal("counterpart")
432
432
  });
433
- e.object({ file: e.string() }), e.object({
433
+ e.object({ file: e.string() }), e.object({ file: e.string() }), e.object({
434
434
  amount: e.union([e.coerce.bigint().min(BigInt("-9223372036854775808"), { error: "Invalid value: Expected int64 to be >= -9223372036854775808" }).max(BigInt("9223372036854775807"), { error: "Invalid value: Expected int64 to be <= 9223372036854775807" }), e.coerce.bigint().min(BigInt("-9223372036854775808"), { error: "Invalid value: Expected int64 to be >= -9223372036854775808" }).max(BigInt("9223372036854775807"), { error: "Invalid value: Expected int64 to be <= 9223372036854775807" })]),
435
435
  currencyCode: e.string().optional().default("USD"),
436
436
  fromBankAccountId: e.uuid(),
@@ -2199,7 +2199,7 @@ var da = e.object({
2199
2199
  e.object({
2200
2200
  document_type: pa.nullish(),
2201
2201
  file_url: e.string()
2202
- }), e.object({ file: e.string() });
2202
+ });
2203
2203
  var ma = e.object({
2204
2204
  description: e.string().nullish(),
2205
2205
  line_reference: e.string().nullish(),
@@ -14,6 +14,7 @@ import { RefreshingRootWidgetProvider as m } from "./lib/WidgetProvider/Refreshi
14
14
  import { useDisclosuresAcceptanceSurface as h, useOwnWidgetConfig as g, useRefetchWidget as _, useWidgetConfig as v, useWidgetError as y, useWidgetInitStaleForToken as b, useWidgetLoading as x } from "./lib/WidgetProvider/hooks.js";
15
15
  import "./lib/WidgetProvider/index.js";
16
16
  import { getNaicsOptions as S } from "./lib/naicsCodeMap.js";
17
+ import "./lib/user/useOrganizationUserNames.js";
17
18
  import { CardProgram as C } from "./lib/card/cardProgram.js";
18
19
  import { CARD_STATUS_LABELS_EN as w, CARD_STATUS_TONE as T, CARD_TYPE_LABELS_EN as E } from "./lib/card/cardPresentation.js";
19
20
  import "./lib/analytics/index.js";
@@ -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.4.17", n = "77f1297ee63eab83488f750e34a020bf23ae2e63", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.4.19", n = "a961a8a7b45e4d505f679336f464b9dfc0b94039", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import "../../../../data-access/dist/index.js";
6
+ import "react";
@@ -20,15 +20,23 @@ var e = [
20
20
  function t(t) {
21
21
  return e.includes(t);
22
22
  }
23
- function n(e) {
24
- return t(e) ? 0 : 2;
25
- }
23
+ var n = /* @__PURE__ */ new Map();
26
24
  function r(e) {
27
- return n(e);
25
+ let r = e.toUpperCase(), i = n.get(r);
26
+ if (i !== void 0) return i;
27
+ let a = 2;
28
+ if (t(r)) a = 0;
29
+ else try {
30
+ a = new Intl.NumberFormat("en-US", {
31
+ style: "currency",
32
+ currency: r
33
+ }).resolvedOptions().maximumFractionDigits ?? 2;
34
+ } catch {}
35
+ return n.set(r, a), a;
28
36
  }
29
37
  function i(e) {
30
- let t = n(e.currencyCode || "USD");
31
- return Number(e.value) / 10 ** t;
38
+ let t = e.currencyCode || "USD";
39
+ return Number(e.value) / 10 ** r(t);
32
40
  }
33
41
  //#endregion
34
42
  export { e as ZERO_DECIMAL_CURRENCY_CODES, i as amountOutputToMajorUnits, t as isZeroDecimalCurrencyCode, r as minorExponentForCurrency };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.4.17",
3
+ "version": "0.4.19",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {