@tesouro/embedded-components-react 0.11.192 → 0.11.195

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.
@@ -23,7 +23,7 @@ import "../../../util/dist/index.js";
23
23
  import { derivePayableStatus as te } from "../../../../shared/document-status/util/dist/lib/derivePayableStatus.js";
24
24
  import { BillColumn as g } from "../../ui/dist/index22.js";
25
25
  import "../../ui/dist/index.js";
26
- import { BillQueue as _, DEFAULT_BILL_QUEUE as ne, billQueueColumns as v, billQueueFilters as re, billQueueOffersAddPanel as ie, billSortColumnId as ae, billSortField as oe } from "./index5.js";
26
+ import { BillQueue as _, DEFAULT_BILL_QUEUE as v, billQueueColumns as ne, billQueueFilters as re, billQueueStatusFilters as ie, billSortColumnId as ae, billSortField as oe } from "./index5.js";
27
27
  import { BillSummaryCard as se, isBillSummaryCard as ce } from "./index10.js";
28
28
  import { duplicateRemovalPrompt as le } from "./index12.js";
29
29
  import { useBillsFilters as ue } from "./index15.js";
@@ -98,65 +98,69 @@ function we(e, t) {
98
98
  return f;
99
99
  }
100
100
  function Te({ enabled: c = !0, canPay: d, canReadVendors: h = !0, isVendorFilterPaused: de = !1, filterLabels: Te, onOpenBill: ke, duplicateRowNote: Ae, attachmentLabel: je, duplicateGroupLabels: T, canManageDuplicates: Me = !1, duplicateView: E = w.AllBills, scheduledRelativeDayLabels: Ne, dueDateLabels: Pe, selectedSummaryCard: D, onSummaryCardChange: Fe }) {
101
- let O = i(), [k, Ie] = S(D ? _.All : ne), [Le, Re] = S(Ce), [ze, Be] = S(xe), [Ve, A] = S(), [He, Ue] = S(d);
101
+ let O = i(), [k, Ie] = S(D ? _.All : v), [Le, Re] = S(Ce), [ze, Be] = S(xe), [Ve, A] = S(), [He, Ue] = S(d);
102
102
  d !== void 0 && He !== d && (Ue(d), A(void 0));
103
- let We = d ?? He, [Ge, Ke] = S(0), [j, qe] = S(""), [M, Je] = S(""), [N, Ye] = S(), [P, Xe] = S(), F = y(() => {
104
- A(void 0), Ke(0);
103
+ let j = d ?? He, [We, Ge] = S(0), [M, Ke] = S(""), [N, qe] = S(""), [P, Je] = S(), [F, Ye] = S(), I = y(() => {
104
+ A(void 0), Ge(0);
105
105
  }, []);
106
106
  b(() => {
107
- if (j === M) return;
107
+ if (M === N) return;
108
108
  let e = setTimeout(() => {
109
- Je(j), F();
109
+ qe(M), I();
110
110
  }, 300);
111
111
  return () => clearTimeout(e);
112
112
  }, [
113
- j,
114
113
  M,
115
- F
114
+ N,
115
+ I
116
116
  ]), b(() => {
117
- F();
118
- }, [E, F]);
119
- let I = E === w.PossibleDuplicates, L = ue({
120
- offersStatusFilter: k === _.All && !I,
117
+ I();
118
+ }, [E, I]);
119
+ let L = E === w.PossibleDuplicates, Xe = x(() => L ? [] : ie(k, j ?? !1), [
120
+ L,
121
+ k,
122
+ j
123
+ ]), R = ue({
124
+ statusOptions: Xe,
121
125
  offersVendorFilter: h,
122
126
  isVendorFilterPaused: de,
123
127
  labels: Te,
124
- onFiltersChange: F,
128
+ onFiltersChange: I,
125
129
  initialSummaryCard: D,
126
130
  onSummaryCardChange: Fe,
127
131
  today: O
128
- }), { clearAll: Ze, filterByVendor: Qe, summaryCard: R, selectSummaryCard: z, applySummaryCard: $e } = L, et = R === se.Overdue && !O, tt = Le[0], nt = oe(tt?.id), rt = nt ? tt?.desc ? "desc" : "asc" : void 0, B = I ? _.All : k, it = x(() => {
129
- let e = re(B, We ?? !1);
132
+ }), { clearAll: Ze, filterByVendor: Qe, summaryCard: z, selectSummaryCard: B, applySummaryCard: $e } = R, et = z === se.Overdue && !O, tt = Le[0], nt = oe(tt?.id), rt = nt ? tt?.desc ? "desc" : "asc" : void 0, it = L ? _.All : k, at = x(() => {
133
+ let e = re(it, j ?? !1);
130
134
  return {
131
- ...L.query,
135
+ ...R.query,
132
136
  ...e,
133
- limit: I ? C : ze,
134
- pagination_token: I ? void 0 : Ve,
135
- status__in: I ? void 0 : e.status__in ?? L.query.status__in,
136
- duplicate_match_status: I ? "suspected" : void 0,
137
- counterpart_name__icontains: M || void 0,
137
+ limit: L ? C : ze,
138
+ pagination_token: L ? void 0 : Ve,
139
+ status__in: L ? void 0 : R.query.status__in ?? e.status__in,
140
+ duplicate_match_status: L ? "suspected" : void 0,
141
+ counterpart_name__icontains: N || void 0,
138
142
  sort: nt,
139
143
  order: rt
140
144
  };
141
145
  }, [
142
- L.query,
146
+ R.query,
143
147
  ze,
144
148
  Ve,
145
- I,
146
- B,
147
- We,
148
- M,
149
+ L,
150
+ it,
151
+ j,
152
+ N,
149
153
  nt,
150
154
  rt
151
- ]), { organizationId: at } = r(), V = JSON.stringify([at, it]), H = he({
152
- ...it,
153
- enabled: c && d !== void 0 && !I && !et,
155
+ ]), { organizationId: ot } = r(), V = JSON.stringify([ot, at]), H = he({
156
+ ...at,
157
+ enabled: c && d !== void 0 && !L && !et,
154
158
  pollWhileOcrProcessing: !0
155
159
  }), U = pe({
156
- ...it,
157
- enabled: c && I,
160
+ ...at,
161
+ enabled: c && L,
158
162
  maxPages: Se
159
- }), W = I ? {
163
+ }), W = L ? {
160
164
  ...U,
161
165
  data: { data: U.payables },
162
166
  isLoading: U.isResolving,
@@ -201,27 +205,27 @@ function Te({ enabled: c = !0, canPay: d, canReadVendors: h = !0, isVendorFilter
201
205
  backButton: T.cancelConfirmBackButton,
202
206
  toast: T.confirmedToast
203
207
  }
204
- }), [T]), ot = N?.removeBy ?? "cancel", st = y(async () => {
205
- N && (await q(N.payable, a.Remove, J[N.removeBy].toast), Ye(void 0));
208
+ }), [T]), st = P?.removeBy ?? "cancel", ct = y(async () => {
209
+ P && (await q(P.payable, a.Remove, J[P.removeBy].toast), Je(void 0));
206
210
  }, [
207
211
  q,
208
- N,
212
+ P,
209
213
  J
210
- ]), ct = y(async () => {
211
- P && (await q(P.payable, a.Keep, T.dismissedToast, P.originalPayableId), Xe(void 0));
214
+ ]), lt = y(async () => {
215
+ F && (await q(F.payable, a.Keep, T.dismissedToast, F.originalPayableId), Ye(void 0));
212
216
  }, [
213
217
  q,
214
218
  T.dismissedToast,
215
- P
216
- ]), [lt, ut] = S(V);
219
+ F
220
+ ]), [ut, dt] = S(V);
217
221
  b(() => {
218
- W.isFetching || ut(V);
222
+ W.isFetching || dt(V);
219
223
  }, [W.isFetching, V]);
220
- let dt = W.data?.data.length, ft = dt === 0, pt = ge({ enabled: c && ft }), mt = !ft || (pt.data?.count ?? 1) > 0, Y = x(() => E === w.PossibleDuplicates ? we(G, T) : /* @__PURE__ */ new Map(), [
224
+ let ft = W.data?.data.length, pt = ft === 0, mt = ge({ enabled: c && pt }), ht = !pt || (mt.data?.count ?? 1) > 0, Y = x(() => E === w.PossibleDuplicates ? we(G, T) : /* @__PURE__ */ new Map(), [
221
225
  E,
222
226
  G,
223
227
  T
224
- ]), ht = x(() => {
228
+ ]), gt = x(() => {
225
229
  if (Y.size === 0) return G;
226
230
  let e = /* @__PURE__ */ new Map();
227
231
  return G.forEach((t, n) => {
@@ -232,12 +236,12 @@ function Te({ enabled: c = !0, canPay: d, canReadVendors: h = !0, isVendorFilter
232
236
  index: n,
233
237
  order: e.get(Y.get(t.id)?.key ?? "") ?? n
234
238
  })).sort((e, t) => e.order - t.order || l(e.payable, t.payable) || e.index - t.index).map(({ payable: e }) => e);
235
- }, [G, Y]), { vendorNames: X, lookup: gt } = fe({
239
+ }, [G, Y]), { vendorNames: X, lookup: _t } = fe({
236
240
  payables: W.data?.data,
237
241
  enabled: c,
238
242
  canReadVendors: h,
239
243
  isPaused: de
240
- }), _t = y((e) => {
244
+ }), vt = y((e) => {
241
245
  let t = e.title || (e.vendorCounterpartId ? X.get(e.vendorCounterpartId) ?? "" : "");
242
246
  return {
243
247
  key: e.key,
@@ -248,7 +252,7 @@ function Te({ enabled: c = !0, canPay: d, canReadVendors: h = !0, isVendorFilter
248
252
  title: t,
249
253
  meta: e.meta
250
254
  };
251
- }, [X, T]), Z = x(() => Ee(ht.map((e) => {
255
+ }, [X, T]), Z = x(() => Ee(gt.map((e) => {
252
256
  let r = te({
253
257
  apiStatus: e.status,
254
258
  dueDate: e.due_date,
@@ -259,26 +263,26 @@ function Te({ enabled: c = !0, canPay: d, canReadVendors: h = !0, isVendorFilter
259
263
  today: O,
260
264
  isScheduled: r.status === "scheduled",
261
265
  labels: Pe
262
- }), d = Y.get(e.id), h = s(e), g = ee(e) || (e.counterpart_id ? X.get(e.counterpart_id) ?? "" : ""), ne = e.document_id ?? "", v = p(e.status), re = d?.originalPayableId !== void 0 && d.originalPayableId === e.id, ie = I && h && Me && d ? {
266
+ }), d = Y.get(e.id), h = s(e), g = ee(e) || (e.counterpart_id ? X.get(e.counterpart_id) ?? "" : ""), _ = e.document_id ?? "", v = p(e.status), ne = d?.originalPayableId !== void 0 && d.originalPayableId === e.id, re = L && h && Me && d ? {
263
267
  triggerLabel: T.menuTrigger({
264
268
  vendorLabel: g,
265
- invoiceNumberLabel: ne
269
+ invoiceNumberLabel: _
266
270
  }),
267
271
  items: [{
268
272
  id: "not-duplicate",
269
273
  label: T.notDuplicateAction,
270
274
  icon: ye,
271
275
  disabled: K.isPending,
272
- onSelect: () => Xe({
276
+ onSelect: () => Ye({
273
277
  payable: e,
274
- originalPayableId: re ? void 0 : d.originalPayableId
278
+ originalPayableId: ne ? void 0 : d.originalPayableId
275
279
  })
276
280
  }, ...v ? [{
277
281
  id: "cancel-duplicate",
278
282
  label: J[v].action,
279
283
  icon: v === "delete" ? be : ve,
280
284
  disabled: K.isPending,
281
- onSelect: () => Ye({
285
+ onSelect: () => Je({
282
286
  payable: e,
283
287
  removeBy: v
284
288
  })
@@ -287,145 +291,142 @@ function Te({ enabled: c = !0, canPay: d, canReadVendors: h = !0, isVendorFilter
287
291
  return {
288
292
  rowKey: e.id,
289
293
  vendorLabel: g,
290
- vendorLookup: g || !e.counterpart_id ? void 0 : Oe(gt),
291
- invoiceNumberLabel: ne,
294
+ vendorLookup: g || !e.counterpart_id ? void 0 : Oe(_t),
295
+ invoiceNumberLabel: _,
292
296
  issueDateLabel: t(e.issued_at),
293
297
  dueDateLabel: u.label,
294
298
  dueDateOverdueLabel: u.overdueLabel,
295
299
  dueDateAccessibleLabel: u.accessibleLabel,
296
300
  scheduledDateLabel: l.label,
297
301
  scheduledDateExact: l.absoluteLabel,
298
- scheduledDateIsGap: B === _.Scheduled,
299
302
  paidDateLabel: t(e.paid_at?.slice(0, 10)),
300
303
  amountDueLabel: c(i),
301
304
  amountPaidLabel: a ? c(e.amount_paid) : "",
302
- amountPaidIsGap: B === _.Paid,
303
305
  amountScheduledLabel: c(e.amount_to_pay ?? i),
304
306
  totalAmountLabel: c(e.total_amount),
305
307
  attachment: e.file_id ? { label: je } : void 0,
306
308
  status: r.status,
307
309
  statusTone: r.tone,
308
310
  addedOnLabel: t(e.created_at?.slice(0, 10)),
309
- ...d ? { group: _t(d) } : {},
310
- ...ie ? { menu: ie } : {},
311
- ...!I && !d && h ? {
311
+ ...d ? { group: vt(d) } : {},
312
+ ...re ? { menu: re } : {},
313
+ ...!L && !d && h ? {
312
314
  marker: "duplicate",
313
315
  rowNote: Ae
314
316
  } : {},
315
317
  onOpen: () => ke(e.id, f(e.status))
316
318
  };
317
319
  }), T), [
318
- ht,
320
+ gt,
319
321
  Y,
320
322
  T,
321
323
  J,
322
324
  K.isPending,
323
325
  Me,
324
- I,
326
+ L,
325
327
  Ae,
326
328
  je,
327
329
  Ne,
328
330
  Pe,
329
331
  O,
330
332
  ke,
331
- B,
332
333
  X,
333
- gt,
334
- _t
335
- ]), vt = x(() => I ? De(Z, C) : [], [Z, I]), Q = Math.min(Ge, Math.max(0, vt.length - 1)), yt = I ? vt[Q] ?? [] : Z, $ = y((e) => {
334
+ _t,
335
+ vt
336
+ ]), yt = x(() => L ? De(Z, C) : [], [Z, L]), Q = Math.min(We, Math.max(0, yt.length - 1)), bt = L ? yt[Q] ?? [] : Z, $ = y((e) => {
336
337
  let t = e;
337
- Ie(t), t !== _.All && z(null), Re((e) => {
338
+ Ie(t), t !== _.All && B(null), Re((e) => {
338
339
  let n = e[0]?.id;
339
- return n ? v(t).some((e) => ae(e) === n) ? e : Ce : e;
340
- }), F();
341
- }, [F, z]), bt = y((e) => {
340
+ return n ? ne(t).some((e) => ae(e) === n) ? e : Ce : e;
341
+ }), I();
342
+ }, [I, B]), xt = y((e) => {
342
343
  if (!ce(e)) return;
343
- let t = e === R ? null : e;
344
- t && $(_.All), z(t);
344
+ let t = e === z ? null : e;
345
+ t && $(_.All), B(t);
345
346
  }, [
346
347
  $,
347
- z,
348
- R
349
- ]), xt = _e(D);
348
+ B,
349
+ z
350
+ ]), St = _e(D);
350
351
  b(() => {
351
- D !== void 0 && D !== xt.current && (xt.current = D, D !== R && (D && $(_.All), $e(D)));
352
+ D !== void 0 && D !== St.current && (St.current = D, D !== z && (D && $(_.All), $e(D)));
352
353
  }, [
353
354
  $e,
354
355
  $,
355
356
  D,
356
- R
357
+ z
357
358
  ]);
358
- let St = y((e) => {
359
- $(_.All), qe(""), Qe(e);
360
- }, [Qe, $]), Ct = y(() => {
361
- qe(""), Je(""), Ze(), F();
362
- }, [Ze, F]), wt = y((e) => {
363
- Re((t) => typeof e == "function" ? e(t) : e), F();
364
- }, [F]), Tt = y((e) => {
365
- Be(e), F();
366
- }, [F]), Et = y(() => {
367
- I ? Ke(Q + 1) : A(H.data?.next_pagination_token ?? void 0);
359
+ let Ct = y((e) => {
360
+ $(_.All), Ke(""), Qe(e);
361
+ }, [Qe, $]), wt = y(() => {
362
+ Ke(""), qe(""), Ze(), I();
363
+ }, [Ze, I]), Tt = y((e) => {
364
+ Re((t) => typeof e == "function" ? e(t) : e), I();
365
+ }, [I]), Et = y((e) => {
366
+ Be(e), I();
367
+ }, [I]), Dt = y(() => {
368
+ L ? Ge(Q + 1) : A(H.data?.next_pagination_token ?? void 0);
368
369
  }, [
369
370
  Q,
370
- I,
371
+ L,
371
372
  H.data?.next_pagination_token
372
- ]), Dt = y(() => {
373
- I ? Ke(Math.max(0, Q - 1)) : A(H.data?.prev_pagination_token ?? void 0);
373
+ ]), Ot = y(() => {
374
+ L ? Ge(Math.max(0, Q - 1)) : A(H.data?.prev_pagination_token ?? void 0);
374
375
  }, [
375
376
  Q,
376
- I,
377
+ L,
377
378
  H.data?.prev_pagination_token
378
- ]), Ot = y(() => {
379
- W.refetch();
380
- }, [W.refetch]);
379
+ ]), kt = W.refetch, At = y(() => {
380
+ kt();
381
+ }, [kt]);
381
382
  return {
382
- rows: yt,
383
- isLoading: W.isLoading || !I && We === void 0 || et || V !== lt || ft && pt.isLoading || (dt ?? 0) > 0 && yt.length === 0,
383
+ rows: bt,
384
+ isLoading: W.isLoading || !L && j === void 0 || et || V !== ut || pt && mt.isLoading || (ft ?? 0) > 0 && bt.length === 0,
384
385
  isError: W.isError,
385
- onRetry: Ot,
386
+ onRetry: At,
386
387
  selectedFilterTabId: k,
387
388
  onFilterTabChange: $,
388
- showVendorBills: St,
389
- clearQueryConstraints: Ct,
390
- summaryCard: R,
391
- onSummaryCardSelect: bt,
392
- searchValue: j,
393
- onSearchChange: qe,
394
- hasAnyBills: mt,
395
- isSearchActive: M.length > 0 || L.isFilterActive,
396
- filterBarProps: L.filterBarProps,
397
- visibleColumns: I ? [
389
+ showVendorBills: Ct,
390
+ clearQueryConstraints: wt,
391
+ summaryCard: z,
392
+ onSummaryCardSelect: xt,
393
+ searchValue: M,
394
+ onSearchChange: Ke,
395
+ hasAnyBills: ht,
396
+ isSearchActive: N.length > 0 || R.isFilterActive,
397
+ filterBarProps: R.filterBarProps,
398
+ visibleColumns: L ? [
398
399
  g.AddedOn,
399
400
  g.DueDate,
400
401
  g.AmountDue,
401
402
  g.Status
402
- ] : v(k),
403
- keepsColumnOrder: I,
404
- isSortable: !I,
405
- pageInfo: I ? T.pageInfo({
403
+ ] : ne(k),
404
+ keepsColumnOrder: L,
405
+ isSortable: !L,
406
+ pageInfo: L ? T.pageInfo({
406
407
  billCount: Z.length,
407
- invoiceCount: new Set(Z.map((e) => e.group?.key ?? e.rowKey)).size
408
+ groupCount: new Set(Z.map((e) => e.group?.key ?? e.rowKey)).size
408
409
  }) : void 0,
409
- showAddPanelWhenEmpty: !I && ie(k),
410
+ showAddPanelWhenEmpty: !L,
410
411
  sorting: Le,
411
- onSortingChange: wt,
412
- pageSize: I ? C : ze,
413
- pageSizeOptions: I ? [C] : void 0,
414
- onPageSizeChange: Tt,
415
- hasNextPage: I ? Q < vt.length - 1 : !!H.data?.next_pagination_token,
416
- hasPrevPage: I ? Q > 0 : !!H.data?.prev_pagination_token,
417
- onNextPage: Et,
418
- onPrevPage: Dt,
412
+ onSortingChange: Tt,
413
+ pageSize: L ? C : ze,
414
+ pageSizeOptions: L ? [C] : void 0,
415
+ onPageSizeChange: Et,
416
+ hasNextPage: L ? Q < yt.length - 1 : !!H.data?.next_pagination_token,
417
+ hasPrevPage: L ? Q > 0 : !!H.data?.prev_pagination_token,
418
+ onNextPage: Dt,
419
+ onPrevPage: Ot,
419
420
  cancelConfirmation: {
420
- open: !!N,
421
- copy: le(J[ot], ot),
422
- onConfirm: () => void st(),
423
- onCancel: () => Ye(void 0),
421
+ open: !!P,
422
+ copy: le(J[st], st),
423
+ onConfirm: () => void ct(),
424
+ onCancel: () => Je(void 0),
424
425
  isPending: K.isPending,
425
- cancelButtonLabel: J[ot].backButton
426
+ cancelButtonLabel: J[st].backButton
426
427
  },
427
428
  keepConfirmation: {
428
- open: !!P,
429
+ open: !!F,
429
430
  copy: {
430
431
  title: T.notDuplicateConfirmTitle,
431
432
  description: T.notDuplicateConfirmDescription,
@@ -436,8 +437,8 @@ function Te({ enabled: c = !0, canPay: d, canReadVendors: h = !0, isVendorFilter
436
437
  actionWidth: "equal"
437
438
  }
438
439
  },
439
- onConfirm: () => void ct(),
440
- onCancel: () => Xe(void 0),
440
+ onConfirm: () => void lt(),
441
+ onCancel: () => Ye(void 0),
441
442
  isPending: K.isPending,
442
443
  cancelButtonLabel: T.notDuplicateConfirmBackButton
443
444
  }
@@ -454,11 +455,10 @@ function Ee(e, t) {
454
455
  if (!e.group) return e;
455
456
  let r = h({
456
457
  statuses: n.get(e.group.key) ?? [],
457
- statusLabels: t.statusLabels,
458
458
  labels: {
459
459
  showMore: t.showMore,
460
460
  showLess: t.showLess,
461
- statusSummary: t.statusSummary
461
+ statusSummary: (e) => t.statusSummary(e.map(({ status: e, count: n }) => (t.statusCount[e] ?? t.statusCount.unknown)(n)))
462
462
  }
463
463
  });
464
464
  return r ? {