@tesouro/embedded-components-react 0.11.185 → 0.11.187

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/index.css +3 -0
  2. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index.js +3 -2
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index6.js +31 -4
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/data-access/dist/index7.js +5 -0
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index.js +4 -4
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index10.js +143 -12
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index11.js +33 -83
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index12.js +15 -48
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index13.js +76 -254
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index14.js +48 -34
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index15.js +241 -438
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index16.js +29 -298
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index17.js +460 -4
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index18.js +327 -4
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index19.js +3 -37
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index20.js +5 -1
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index21.js +38 -0
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index22.js +1 -0
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index5.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index7.js +30 -2
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index8.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index.js +7 -4
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index10.js +2 -200
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index11.js +38 -3
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index12.js +10 -2
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index13.js +196 -11
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index14.js +1 -0
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index15.js +2 -2
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index16.js +9 -15
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index18.js +2 -54
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index19.js +20 -16
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index20.js +2 -460
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index21.js +54 -2
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index22.js +17 -0
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index23.js +463 -0
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index24.js +3 -0
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index8.js +5 -36
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index9.js +28 -10
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/lib/queryKeys.js +8 -5
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillsTab.js +1 -1
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/mocks/billPay.js +11 -9
  42. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  43. package/dist/packages/shared-ui-shadcn/dist/index.js +3623 -3539
  44. package/package.json +1 -1
@@ -2,459 +2,262 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { toast as e } from "../../../../../../node_modules/sonner/dist/index.js";
6
- import { formatCalendarDate as t } from "../../../../shared/util/dist/lib/formatCalendarDate.js";
7
- import { formatMoneyExact as n } from "../../../../shared/util/dist/lib/formatMoneyExact.js";
5
+ import { formatMoneyExact as e } from "../../../../shared/util/dist/lib/formatMoneyExact.js";
8
6
  import "../../../../shared/util/dist/index.js";
9
- import { useEmbedApi as r } from "../../../../shared/data-access/dist/lib/EmbedApiContext.js";
10
- import "../../../../shared/ui/dist/index.js";
11
- import { useLocalCalendarDay as i } from "../../../../shared/feature/dist/lib/calendar/useLocalCalendarDay.js";
12
- import "../../../../shared/feature/dist/index.js";
13
- import { DuplicateVerdict as a } from "../../../util/dist/lib/duplicateVerdict.js";
14
- import { formatScheduledDateLabel as o } from "../../../util/dist/lib/formatScheduledDateLabel.js";
15
- import { hasSuspectedPayableDuplicate as s, suspectedPayableDuplicates as c } from "../../../util/dist/lib/payableDuplicates.js";
16
- import { compareByArrival as l, duplicateVerdictMatches as u, resolveDuplicateOriginalId as d } from "../../../util/dist/lib/groupDuplicates.js";
17
- import { isEditablePayableStatus as f } from "../../../util/dist/lib/isEditablePayableStatus.js";
18
- import { payableRemoval as p } from "../../../util/dist/lib/payableRemoval.js";
19
- import { resolveBillDueDate as m } from "../../../util/dist/lib/resolveBillDueDate.js";
20
- import { resolveVendorName as ee } from "../../../util/dist/lib/resolveVendor.js";
21
- import { buildGroupCollapse as h } from "../../../util/dist/lib/groupCollapse.js";
22
7
  import "../../../util/dist/index.js";
23
- import { derivePayableStatus as te } from "../../../../shared/document-status/util/dist/lib/derivePayableStatus.js";
24
- import { useApplyDuplicateVerdictsMutation as g } from "../../../data-access/dist/lib/useApplyDuplicateVerdictsMutation.js";
25
- import "../../../data-access/dist/index.js";
26
- import { BillColumn as _ } from "../../ui/dist/index19.js";
8
+ import { getCounterpartName as t } from "../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
9
+ import { useCounterpartsQuery as n } from "../../../../shared/counterpart-management/data-access/dist/index3.js";
10
+ import "../../../../shared/counterpart-management/feature/dist/index.js";
11
+ import { BILL_STATUS_FILTER_ORDER as r, billStatusFilterApiValues as i } from "./index4.js";
12
+ import { BillsFilterField as a } from "../../ui/dist/index12.js";
27
13
  import "../../ui/dist/index.js";
28
- import { BillQueue as v, DEFAULT_BILL_QUEUE as y, billQueueColumns as b, billQueueFilters as x, billQueueOffersAddPanel as ne, billSortColumnId as re, billSortField as ie } from "./index5.js";
29
- import { duplicateRemovalPrompt as ae } from "./index10.js";
30
- import { useBillsFilters as oe } from "./index13.js";
31
- import { BillVendorLookup as se, useBillVendorNames as ce } from "./index14.js";
32
- import { useFirstPayablesPagesQuery as le } from "../../data-access/dist/index2.js";
33
- import { usePayablesQuery as ue } from "../../data-access/dist/index4.js";
34
- import { usePayablesTotalCountQuery as de } from "../../data-access/dist/index5.js";
35
- import "../../data-access/dist/index.js";
36
- import { useCallback as S, useEffect as fe, useMemo as C, useState as w } from "react";
37
- import { BanIcon as pe, FileCheckIcon as me, Trash2Icon as he } from "lucide-react";
14
+ import { BillsDatePreset as o, resolveDatePreset as s } from "./index13.js";
15
+ import { BILLS_FILTER_LABELS_EN as c } from "./index14.js";
16
+ import { useCallback as l, useEffect as u, useMemo as d, useState as f } from "react";
17
+ import { format as p, formatISO as m } from "date-fns";
38
18
  // ../../libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index15.js
39
- var ge = 10, T = 100, _e = 3, ve = [{
40
- id: "addedOnLabel",
41
- desc: !0
42
- }], E = {
43
- AllBills: "allBills",
44
- PossibleDuplicates: "possibleDuplicates"
19
+ var h = {
20
+ Date: "date",
21
+ Status: "status",
22
+ Amount: "amount",
23
+ Vendor: "vendor",
24
+ Attachment: "attachment"
25
+ }, g = 50, _ = 300, v = "MMM d, yyyy", y = 864e5, b = {
26
+ [a.IssueDate]: "issued_at",
27
+ [a.DueDate]: "due_date",
28
+ [a.AddedOn]: "created_at"
29
+ }, x = {
30
+ [o.Today]: "current",
31
+ [o.ThisWeek]: "current",
32
+ [o.ThisMonth]: "current",
33
+ [o.ThisQuarter]: "current",
34
+ [o.ThisYear]: "current",
35
+ [o.Yesterday]: "past",
36
+ [o.LastWeek]: "past",
37
+ [o.LastMonth]: "past",
38
+ [o.Last30Days]: "past",
39
+ [o.Last90Days]: "past",
40
+ [o.LastQuarter]: "past",
41
+ [o.LastYear]: "past"
45
42
  };
46
- function ye(e, t) {
47
- let n = new Map(e.map((e) => [e.id, e])), r = /* @__PURE__ */ new Map(), i = (e) => {
48
- r.has(e) || r.set(e, /* @__PURE__ */ new Set());
49
- }, a = (e, t) => {
50
- i(e), i(t), r.get(e)?.add(t), r.get(t)?.add(e);
43
+ function S() {
44
+ return {
45
+ dateField: a.DueDate,
46
+ statuses: [],
47
+ amountMode: "any",
48
+ amountMin: "",
49
+ amountMax: "",
50
+ vendorIds: []
51
51
  };
52
- for (let t of e) {
53
- let e = c(t);
54
- if (e.length !== 0) {
55
- i(t.id);
56
- for (let n of e) a(t.id, n.matched_payable_id);
57
- }
58
- }
59
- let o = [], s = /* @__PURE__ */ new Set();
60
- for (let e of r.keys()) {
61
- if (s.has(e)) continue;
62
- let i = [], a = [e];
63
- for (s.add(e); a.length > 0;) {
64
- let e = a.pop();
65
- n.has(e) && i.push(e);
66
- for (let t of r.get(e) ?? []) s.has(t) || (s.add(t), a.push(t));
67
- }
68
- if (i.length === 0) continue;
69
- let c = i.map((e) => n.get(e)).filter((e) => !!e).sort(l), u = d(c), [f] = c, p = ee(f), m = f?.document_id ?? "", h = u ?? f?.id ?? e, te = `duplicate-group:${p || m ? `${p}|${m}` : h}`;
70
- o.push({
71
- componentIds: i,
72
- baseKey: te,
73
- anchorId: h,
74
- group: {
75
- label: t.groupHeader({
76
- vendorLabel: p,
77
- invoiceNumberLabel: m
78
- }),
79
- title: p,
80
- meta: m ? t.groupInvoice(m) : void 0,
81
- invoiceNumberLabel: m,
82
- vendorCounterpartId: f?.counterpart_id ?? void 0,
83
- originalPayableId: u
84
- }
85
- });
86
- }
87
- let u = /* @__PURE__ */ new Map();
88
- for (let { baseKey: e } of o) u.set(e, (u.get(e) ?? 0) + 1);
89
- let f = /* @__PURE__ */ new Map();
90
- for (let { componentIds: e, baseKey: t, anchorId: n, group: r } of o) {
91
- let i = (u.get(t) ?? 0) > 1 ? `${t}:${n}` : t, a = {
92
- ...r,
93
- key: i
94
- };
95
- for (let t of e) f.set(t, a);
96
- }
97
- return f;
98
52
  }
99
- function be({ enabled: c = !0, canPay: d, canReadVendors: h = !0, isVendorFilterPaused: se = !1, filterLabels: be, onOpenBill: we, duplicateRowNote: Te, attachmentLabel: Ee, duplicateGroupLabels: D, canManageDuplicates: De = !1, duplicateView: O = E.AllBills, scheduledRelativeDayLabels: Oe, dueDateLabels: ke }) {
100
- let k = i(), [A, Ae] = w(y), [je, Me] = w(ve), [j, Ne] = w(ge), [Pe, M] = w(), [Fe, Ie] = w(d);
101
- d !== void 0 && Fe !== d && (Ie(d), M(void 0));
102
- let Le = d ?? Fe, [Re, ze] = w(0), [N, Be] = w(""), [P, Ve] = w(""), [F, He] = w(), [I, Ue] = w(), L = S(() => {
103
- M(void 0), ze(0);
104
- }, []);
105
- fe(() => {
106
- if (N === P) return;
107
- let e = setTimeout(() => {
108
- Ve(N), L();
109
- }, 300);
110
- return () => clearTimeout(e);
111
- }, [
112
- N,
113
- P,
114
- L
115
- ]), fe(() => {
116
- L();
117
- }, [O, L]);
118
- let R = O === E.PossibleDuplicates, z = oe({
119
- offersStatusFilter: A === v.All && !R,
120
- offersVendorFilter: h,
121
- isVendorFilterPaused: se,
122
- labels: be,
123
- onFiltersChange: L
124
- }), { clearAll: We, filterByVendor: Ge } = z, Ke = je[0], qe = ie(Ke?.id), Je = qe ? Ke?.desc ? "desc" : "asc" : void 0, B = R ? v.All : A, Ye = C(() => {
125
- let e = x(B, Le ?? !1);
126
- return {
127
- ...z.query,
53
+ function C(e) {
54
+ let t = Number.parseFloat(e);
55
+ return Number.isFinite(t) ? Math.round(t * 100) : void 0;
56
+ }
57
+ function w({ offersStatusFilter: o = !1, offersVendorFilter: w = !0, isVendorFilterPaused: T = !1, onFiltersChange: E, labels: D } = {}) {
58
+ let O = d(() => ({
59
+ ...c,
60
+ ...D,
61
+ presets: {
62
+ ...c.presets,
63
+ ...D?.presets
64
+ },
65
+ statuses: {
66
+ ...c.statuses,
67
+ ...D?.statuses
68
+ },
69
+ dateFieldNames: {
70
+ ...c.dateFieldNames,
71
+ ...D?.dateFieldNames
72
+ }
73
+ }), [D]), [k, A] = f(S), [j, M] = f({}), [N, P] = f(""), [F, I] = f(""), L = l((e) => {
74
+ A((t) => ({
75
+ ...t,
76
+ ...e
77
+ })), E?.();
78
+ }, [E]);
79
+ u(() => {
80
+ w || A((e) => e.vendorIds.length === 0 ? e : (E?.(), {
81
+ ...e,
82
+ vendorIds: []
83
+ }));
84
+ }, [w, E]), u(() => {
85
+ o || A((e) => e.statuses.length === 0 ? e : (E?.(), {
128
86
  ...e,
129
- limit: R ? T : j,
130
- pagination_token: R ? void 0 : Pe,
131
- status__in: R ? void 0 : e.status__in ?? z.query.status__in,
132
- duplicate_match_status: R ? "suspected" : void 0,
133
- counterpart_name__icontains: P || void 0,
134
- sort: qe,
135
- order: Je
87
+ statuses: []
88
+ }));
89
+ }, [o, E]), u(() => {
90
+ let e = setTimeout(() => I(N.trim()), _);
91
+ return () => clearTimeout(e);
92
+ }, [N]);
93
+ let R = n({
94
+ enabled: w && !T,
95
+ is_vendor: !0,
96
+ sort: "counterpart_name",
97
+ order: "asc",
98
+ limit: g,
99
+ counterpart_name__icontains: F || void 0
100
+ }), z = d(() => (R.data?.data ?? []).map((e) => ({
101
+ value: e.id,
102
+ label: t(e)
103
+ })), [R.data?.data]), B = d(() => r.map((e) => ({
104
+ value: e,
105
+ label: O.statuses[e]
106
+ })), [O.statuses]), V = d(() => Object.entries(x).map(([e, t]) => ({
107
+ value: e,
108
+ label: O.presets[e],
109
+ group: t === "current" ? O.presetGroupCurrent : O.presetGroupPast
110
+ })), [
111
+ O.presetGroupCurrent,
112
+ O.presetGroupPast,
113
+ O.presets
114
+ ]), H = d(() => {
115
+ let e = {}, t = b[k.dateField], n = (e) => Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
116
+ if (k.dateFrom && (e[`${t}__gte`] = t === "created_at" ? new Date(n(k.dateFrom)).toISOString() : m(k.dateFrom, { representation: "date" })), k.dateTo && (t === "created_at" ? e.created_at__lt = new Date(n(k.dateTo) + y).toISOString() : e[`${t}__lte`] = m(k.dateTo, { representation: "date" })), k.statuses.length > 0 && (e.status__in = i(k.statuses)), k.amountMode !== "any") {
117
+ let t = "total_amount__gte", n = "total_amount__lte", r = C(k.amountMin), i = C(k.amountMax);
118
+ k.amountMode === "exact" ? r !== void 0 && (e[t] = r, e[n] = r) : (r !== void 0 && (e[t] = r), i !== void 0 && (e[n] = i));
119
+ }
120
+ return k.vendorIds.length > 0 && (e.counterpart_id__in = [...k.vendorIds]), k.hasFile !== void 0 && (e.has_file = k.hasFile), e;
121
+ }, [k]), U = d(() => {
122
+ let t = [], n = (e) => p(e, v), r = (e) => {
123
+ let [t, ...n] = e;
124
+ return t ? n.length === 0 ? t : O.moreSelected(t, n.length) : "";
136
125
  };
137
- }, [
138
- z.query,
139
- j,
140
- Pe,
141
- R,
142
- B,
143
- Le,
144
- P,
145
- qe,
146
- Je
147
- ]), { organizationId: Xe } = r(), V = JSON.stringify([Xe, Ye]), H = ue({
148
- ...Ye,
149
- enabled: c && d !== void 0 && !R,
150
- pollWhileOcrProcessing: !0
151
- }), U = le({
152
- ...Ye,
153
- enabled: c && R,
154
- maxPages: _e
155
- }), W = R ? {
156
- ...U,
157
- data: { data: U.payables },
158
- isLoading: U.isResolving,
159
- isFetching: U.isFetching || U.isResolving
160
- } : H, G = (W.data?.data ?? []).filter((e) => e.ocr_status !== "processing"), K = g(), q = S(async (t, n, r, i) => {
161
- let a = u(t, n, i);
162
- if (a.length) try {
163
- await K.mutateAsync({
164
- verdict: n,
165
- targets: a.map((e) => ({
166
- payableId: t.id,
167
- duplicateId: e.id,
168
- matchedPayableId: e.matched_payable_id,
169
- removeBy: p(t.status)
170
- }))
171
- }), e.success(r);
172
- } catch {
173
- e.error(D.actionFailedToast);
126
+ if (k.dateFrom || k.dateTo) {
127
+ let e = (k.datePreset ? O.presets[k.datePreset] : void 0) ?? (k.dateFrom && k.dateTo ? O.dateRange(n(k.dateFrom), n(k.dateTo)) : k.dateFrom ? O.dateFrom(n(k.dateFrom)) : O.dateTo(n(k.dateTo)));
128
+ t.push({
129
+ key: h.Date,
130
+ label: O.dateChip(O.dateFieldNames[k.dateField], e)
131
+ });
174
132
  }
175
- }, [K, D.actionFailedToast]), J = C(() => ({
176
- delete: {
177
- action: D.deleteAction,
178
- title: D.deleteConfirmTitle,
179
- description: D.deleteConfirmDescription,
180
- confirmButton: D.deleteConfirmButton,
181
- backButton: D.cancelConfirmBackButton,
182
- toast: D.deletedToast
183
- },
184
- cancel: {
185
- action: D.cancelAction,
186
- title: D.cancelConfirmTitle,
187
- description: D.cancelConfirmDescription,
188
- confirmButton: D.cancelConfirmButton,
189
- backButton: D.cancelConfirmBackButton,
190
- toast: D.cancelledToast
191
- },
192
- confirm: {
193
- action: D.confirmAction,
194
- title: D.confirmDuplicateTitle,
195
- description: D.confirmDuplicateDescription,
196
- confirmButton: D.confirmDuplicateButton,
197
- backButton: D.cancelConfirmBackButton,
198
- toast: D.confirmedToast
133
+ if (k.statuses.length > 0 && t.push({
134
+ key: h.Status,
135
+ label: O.statusChip(r(k.statuses.map((e) => O.statuses[e] ?? e)))
136
+ }), k.vendorIds.length > 0 && t.push({
137
+ key: h.Vendor,
138
+ label: O.vendorChip(r(k.vendorIds.map((e) => j[e] ?? e)))
139
+ }), k.amountMode !== "any") {
140
+ let n = (t) => {
141
+ let n = Number.parseFloat(t);
142
+ return Number.isFinite(n) ? e(n, { currencyCode: "USD" }) : "";
143
+ }, r = n(k.amountMin), i = n(k.amountMax), a = k.amountMode === "exact" ? r : r && i ? O.amountBetween(r, i) : r ? O.amountAtLeast(r) : i ? O.amountAtMost(i) : "";
144
+ a && t.push({
145
+ key: h.Amount,
146
+ label: O.amountChip(a)
147
+ });
199
148
  }
200
- }), [D]), Ze = F?.removeBy ?? "cancel", Qe = S(async () => {
201
- F && (await q(F.payable, a.Remove, J[F.removeBy].toast), He(void 0));
202
- }, [
203
- q,
204
- F,
205
- J
206
- ]), $e = S(async () => {
207
- I && (await q(I.payable, a.Keep, D.dismissedToast, I.originalPayableId), Ue(void 0));
149
+ return k.hasFile !== void 0 && t.push({
150
+ key: h.Attachment,
151
+ label: k.hasFile ? O.attachmentChipHas : O.attachmentChipNone
152
+ }), t;
208
153
  }, [
209
- q,
210
- D.dismissedToast,
211
- I
212
- ]), [et, tt] = w(V);
213
- fe(() => {
214
- W.isFetching || tt(V);
215
- }, [W.isFetching, V]);
216
- let nt = W.data?.data.length, rt = nt === 0, it = de({ enabled: c && rt }), at = !rt || (it.data?.count ?? 1) > 0, Y = C(() => O === E.PossibleDuplicates ? ye(G, D) : /* @__PURE__ */ new Map(), [
217
154
  O,
218
- G,
219
- D
220
- ]), ot = C(() => {
221
- if (Y.size === 0) return G;
222
- let e = /* @__PURE__ */ new Map();
223
- return G.forEach((t, n) => {
224
- let r = Y.get(t.id)?.key;
225
- r !== void 0 && !e.has(r) && e.set(r, n);
226
- }), G.map((t, n) => ({
227
- payable: t,
228
- index: n,
229
- order: e.get(Y.get(t.id)?.key ?? "") ?? n
230
- })).sort((e, t) => e.order - t.order || l(e.payable, t.payable) || e.index - t.index).map(({ payable: e }) => e);
231
- }, [G, Y]), { vendorNames: X, lookup: st } = ce({
232
- payables: W.data?.data,
233
- enabled: c,
234
- canReadVendors: h,
235
- isPaused: se
236
- }), ct = S((e) => {
237
- let t = e.title || (e.vendorCounterpartId ? X.get(e.vendorCounterpartId) ?? "" : "");
238
- return {
239
- key: e.key,
240
- label: t === e.title ? e.label : D.groupHeader({
241
- vendorLabel: t,
242
- invoiceNumberLabel: e.invoiceNumberLabel
243
- }),
244
- title: t,
245
- meta: e.meta
246
- };
247
- }, [X, D]), Z = C(() => xe(ot.map((e) => {
248
- let r = te({
249
- apiStatus: e.status,
250
- dueDate: e.due_date,
251
- scheduledPaymentDate: e.scheduled_payment_date
252
- }), i = e.amount_due ?? e.total_amount, a = e.status === "partially_paid" || e.status === "paid", c = (t) => t == null ? "" : n(t / 100, { currencyCode: e.currency ?? "USD" }), l = o(e.scheduled_payment_date, Oe, k), u = m({
253
- status: e.status,
254
- dueDate: e.due_date,
255
- today: k,
256
- isScheduled: r.status === "scheduled",
257
- labels: ke
258
- }), d = Y.get(e.id), h = s(e), g = ee(e) || (e.counterpart_id ? X.get(e.counterpart_id) ?? "" : ""), _ = e.document_id ?? "", y = p(e.status), b = d?.originalPayableId !== void 0 && d.originalPayableId === e.id, x = R && h && De && d ? {
259
- triggerLabel: D.menuTrigger({
260
- vendorLabel: g,
261
- invoiceNumberLabel: _
262
- }),
263
- items: [{
264
- id: "not-duplicate",
265
- label: D.notDuplicateAction,
266
- icon: me,
267
- disabled: K.isPending,
268
- onSelect: () => Ue({
269
- payable: e,
270
- originalPayableId: b ? void 0 : d.originalPayableId
271
- })
272
- }, ...y ? [{
273
- id: "cancel-duplicate",
274
- label: J[y].action,
275
- icon: y === "delete" ? he : pe,
276
- disabled: K.isPending,
277
- onSelect: () => He({
278
- payable: e,
279
- removeBy: y
280
- })
281
- }] : []]
282
- } : void 0;
283
- return {
284
- rowKey: e.id,
285
- vendorLabel: g,
286
- vendorLookup: g || !e.counterpart_id ? void 0 : Ce(st),
287
- invoiceNumberLabel: _,
288
- issueDateLabel: t(e.issued_at),
289
- dueDateLabel: u.label,
290
- dueDateOverdueLabel: u.overdueLabel,
291
- dueDateAccessibleLabel: u.accessibleLabel,
292
- scheduledDateLabel: l.label,
293
- scheduledDateExact: l.absoluteLabel,
294
- scheduledDateIsGap: B === v.Scheduled,
295
- paidDateLabel: t(e.paid_at?.slice(0, 10)),
296
- amountDueLabel: c(i),
297
- amountPaidLabel: a ? c(e.amount_paid) : "",
298
- amountPaidIsGap: B === v.Paid,
299
- amountScheduledLabel: c(e.amount_to_pay ?? i),
300
- totalAmountLabel: c(e.total_amount),
301
- attachment: e.file_id ? { label: Ee } : void 0,
302
- status: r.status,
303
- statusTone: r.tone,
304
- addedOnLabel: t(e.created_at?.slice(0, 10)),
305
- ...d ? { group: ct(d) } : {},
306
- ...x ? { menu: x } : {},
307
- ...!R && !d && h ? {
308
- marker: "duplicate",
309
- rowNote: Te
310
- } : {},
311
- onOpen: () => we(e.id, f(e.status))
312
- };
313
- }), D), [
314
- ot,
315
- Y,
316
- D,
317
- J,
318
- K.isPending,
319
- De,
320
- R,
321
- Te,
322
- Ee,
323
- Oe,
324
- ke,
325
155
  k,
326
- we,
327
- B,
328
- X,
329
- st,
330
- ct
331
- ]), lt = C(() => R ? Se(Z, T) : [], [Z, R]), Q = Math.min(Re, Math.max(0, lt.length - 1)), ut = R ? lt[Q] ?? [] : Z, $ = S((e) => {
332
- let t = e;
333
- Ae(t), Me((e) => {
334
- let n = e[0]?.id;
335
- return n ? b(t).some((e) => re(e) === n) ? e : ve : e;
336
- }), L();
337
- }, [L]), dt = S((e) => {
338
- $(v.All), Be(""), Ge(e);
339
- }, [Ge, $]), ft = S(() => {
340
- Be(""), Ve(""), We(), L();
341
- }, [We, L]), pt = S((e) => {
342
- Me((t) => typeof e == "function" ? e(t) : e), L();
343
- }, [L]), mt = S((e) => {
344
- Ne(e), L();
345
- }, [L]), ht = S(() => {
346
- R ? ze(Q + 1) : M(H.data?.next_pagination_token ?? void 0);
347
- }, [
348
- Q,
349
- R,
350
- H.data?.next_pagination_token
351
- ]), gt = S(() => {
352
- R ? ze(Math.max(0, Q - 1)) : M(H.data?.prev_pagination_token ?? void 0);
353
- }, [
354
- Q,
355
- R,
356
- H.data?.prev_pagination_token
357
- ]), _t = S(() => {
358
- W.refetch();
359
- }, [W.refetch]);
156
+ j
157
+ ]), W = l((e) => {
158
+ switch (e) {
159
+ case h.Date:
160
+ L({
161
+ datePreset: void 0,
162
+ dateFrom: void 0,
163
+ dateTo: void 0
164
+ });
165
+ break;
166
+ case h.Status:
167
+ L({ statuses: [] });
168
+ break;
169
+ case h.Vendor:
170
+ L({ vendorIds: [] });
171
+ break;
172
+ case h.Amount:
173
+ L({
174
+ amountMode: "any",
175
+ amountMin: "",
176
+ amountMax: ""
177
+ });
178
+ break;
179
+ case h.Attachment: L({ hasFile: void 0 });
180
+ }
181
+ }, [L]), G = l(() => {
182
+ A(S()), E?.();
183
+ }, [E]), K = l((e) => {
184
+ M((t) => ({
185
+ ...t,
186
+ [e.id]: e.name
187
+ })), A({
188
+ ...S(),
189
+ vendorIds: [e.id]
190
+ }), E?.();
191
+ }, [E]), q = l((e) => {
192
+ M((t) => {
193
+ let n = { ...t };
194
+ for (let t of z) e.includes(t.value) && (n[t.value] = t.label);
195
+ return n;
196
+ }), L({ vendorIds: e });
197
+ }, [L, z]);
360
198
  return {
361
- rows: ut,
362
- isLoading: W.isLoading || !R && Le === void 0 || V !== et || rt && it.isLoading || (nt ?? 0) > 0 && ut.length === 0,
363
- isError: W.isError,
364
- onRetry: _t,
365
- selectedFilterTabId: A,
366
- onFilterTabChange: $,
367
- showVendorBills: dt,
368
- clearQueryConstraints: ft,
369
- searchValue: N,
370
- onSearchChange: Be,
371
- hasAnyBills: at,
372
- isSearchActive: P.length > 0 || z.isFilterActive,
373
- filterBarProps: z.filterBarProps,
374
- visibleColumns: R ? [
375
- _.AddedOn,
376
- _.DueDate,
377
- _.AmountDue,
378
- _.Status
379
- ] : b(A),
380
- keepsColumnOrder: R,
381
- isSortable: !R,
382
- pageInfo: R ? D.pageInfo({
383
- billCount: Z.length,
384
- invoiceCount: new Set(Z.map((e) => e.group?.key ?? e.rowKey)).size
385
- }) : void 0,
386
- showAddPanelWhenEmpty: !R && ne(A),
387
- sorting: je,
388
- onSortingChange: pt,
389
- pageSize: R ? T : j,
390
- pageSizeOptions: R ? [T] : void 0,
391
- onPageSizeChange: mt,
392
- hasNextPage: R ? Q < lt.length - 1 : !!H.data?.next_pagination_token,
393
- hasPrevPage: R ? Q > 0 : !!H.data?.prev_pagination_token,
394
- onNextPage: ht,
395
- onPrevPage: gt,
396
- cancelConfirmation: {
397
- open: !!F,
398
- copy: ae(J[Ze], Ze),
399
- onConfirm: () => void Qe(),
400
- onCancel: () => He(void 0),
401
- isPending: K.isPending,
402
- cancelButtonLabel: J[Ze].backButton
403
- },
404
- keepConfirmation: {
405
- open: !!I,
406
- copy: {
407
- title: D.notDuplicateConfirmTitle,
408
- description: D.notDuplicateConfirmDescription,
409
- confirmButton: D.notDuplicateConfirmButton,
410
- presentation: {
411
- alignment: "center",
412
- icon: me,
413
- actionWidth: "equal"
414
- }
199
+ filterBarProps: {
200
+ fields: [...d(() => [
201
+ ...w ? [a.Vendor] : [],
202
+ a.IssueDate,
203
+ a.DueDate,
204
+ ...o ? [a.Status] : [],
205
+ a.TotalAmount,
206
+ a.AddedOn,
207
+ a.Attachment
208
+ ], [o, w])],
209
+ activeFilterCount: U.length,
210
+ chips: U,
211
+ onRemoveChip: W,
212
+ onClearAll: G,
213
+ dateField: k.dateField,
214
+ onDateFieldChange: (e) => {
215
+ let t = !!(k.dateFrom || k.dateTo);
216
+ A((t) => ({
217
+ ...t,
218
+ dateField: e
219
+ })), t && E?.();
415
220
  },
416
- onConfirm: () => void $e(),
417
- onCancel: () => Ue(void 0),
418
- isPending: K.isPending,
419
- cancelButtonLabel: D.notDuplicateConfirmBackButton
420
- }
221
+ datePresets: V,
222
+ selectedDatePreset: k.datePreset,
223
+ dateFrom: k.dateFrom,
224
+ dateTo: k.dateTo,
225
+ onDateRangeChange: ({ from: e, to: t }) => L({
226
+ datePreset: void 0,
227
+ dateFrom: e,
228
+ dateTo: t
229
+ }),
230
+ onDatePresetChange: (e) => {
231
+ let t = /* @__PURE__ */ new Date(), n = k.dateField === a.AddedOn ? new Date(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate()) : t, { from: r, to: i } = s(e, n);
232
+ L({
233
+ datePreset: e,
234
+ dateFrom: r,
235
+ dateTo: i
236
+ });
237
+ },
238
+ statusOptions: B,
239
+ selectedStatuses: k.statuses,
240
+ onStatusChange: (e) => L({ statuses: e }),
241
+ amountMode: k.amountMode,
242
+ onAmountModeChange: (e) => L({ amountMode: e }),
243
+ amountMin: k.amountMin,
244
+ amountMax: k.amountMax,
245
+ onAmountMinChange: (e) => L({ amountMin: e }),
246
+ onAmountMaxChange: (e) => L({ amountMax: e }),
247
+ vendorOptions: z,
248
+ selectedVendors: k.vendorIds,
249
+ onVendorChange: q,
250
+ vendorSearchValue: N,
251
+ onVendorSearchChange: P,
252
+ isVendorLoading: R.isLoading || T,
253
+ isVendorError: R.isError,
254
+ hasAttachment: k.hasFile,
255
+ onHasAttachmentChange: (e) => L({ hasFile: e })
256
+ },
257
+ query: H,
258
+ isFilterActive: U.length > 0,
259
+ clearAll: G,
260
+ filterByVendor: K
421
261
  };
422
262
  }
423
- function xe(e, t) {
424
- let n = /* @__PURE__ */ new Map();
425
- for (let t of e) {
426
- if (!t.group) continue;
427
- let e = n.get(t.group.key) ?? [];
428
- e.push(t.status), n.set(t.group.key, e);
429
- }
430
- return e.map((e) => {
431
- if (!e.group) return e;
432
- let r = h({
433
- statuses: n.get(e.group.key) ?? [],
434
- statusLabels: t.statusLabels,
435
- labels: {
436
- showMore: t.showMore,
437
- showLess: t.showLess,
438
- statusSummary: t.statusSummary
439
- }
440
- });
441
- return r ? {
442
- ...e,
443
- group: {
444
- ...e.group,
445
- collapse: r
446
- }
447
- } : e;
448
- });
449
- }
450
- function Se(e, t) {
451
- let n = [], r = [];
452
- return e.forEach((i, a) => {
453
- let o = i.group !== void 0 && i.group.key === e[a - 1]?.group?.key;
454
- r.length >= t && !o && (n.push(r), r = []), r.push(i);
455
- }), r.length && n.push(r), n;
456
- }
457
- function Ce(e) {
458
- return e === se.Settled ? void 0 : e;
459
- }
460
- export { E as BillDuplicateView, be as useBillsTable };
263
+ export { h as BillsFilterChipKey, w as useBillsFilters };