@tesouro/embedded-components-react 0.11.180 → 0.11.183

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 (31) hide show
  1. package/README.md +5 -0
  2. package/dist/index.css +22 -0
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index.js +4 -4
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index10.js +14 -17
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index11.js +82 -13
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index12.js +47 -83
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index13.js +261 -47
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index14.js +23 -251
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index15.js +450 -25
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index16.js +286 -442
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index17.js +4 -300
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index18.js +5 -4
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index19.js +37 -4
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index20.js +1 -38
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index5.js +11 -11
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index7.js +88 -7
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index8.js +17 -89
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index9.js +18 -18
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index10.js +4 -4
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index18.js +0 -1
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index20.js +263 -262
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillsTab.js +1 -1
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/mocks/labels.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index14.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +2 -2
  26. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/index.js +7 -5
  28. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/AttentionStrip/AttentionStrip.js +29 -0
  29. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/AttentionStrip/AttentionViewBar.js +33 -0
  30. package/package.json +3 -1
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index21.js +0 -1
package/README.md CHANGED
@@ -11,6 +11,11 @@ dependencies.
11
11
  These steps put one widget on screen: a token route on your server, a provider
12
12
  in the browser, and the widget itself. The examples use the Next.js App Router.
13
13
 
14
+ To load the widgets from the Tesouro CDN instead of bundling them, see
15
+ [Load from the Tesouro CDN](https://components.tesouro.com/components/load-from-cdn).
16
+ The hosted build runs on the React already on your page, and the token route
17
+ below is the same.
18
+
14
19
  Using a coding assistant? Point it at
15
20
  [`llms-full.txt`](https://components.tesouro.com/llms-full.txt), which has every
16
21
  page of the docs site as Markdown in one file.
package/dist/index.css CHANGED
@@ -562,6 +562,9 @@
562
562
  .ttw\:-ml-2 {
563
563
  margin-left: calc(var(--ttw-spacing) * -2);
564
564
  }
565
+ .ttw\:-ml-3 {
566
+ margin-left: calc(var(--ttw-spacing) * -3);
567
+ }
565
568
  .ttw\:ml-1 {
566
569
  margin-left: var(--ttw-spacing);
567
570
  }
@@ -2094,6 +2097,9 @@
2094
2097
  .ttw\:border-violet-200 {
2095
2098
  border-color: var(--ttw-color-violet-200);
2096
2099
  }
2100
+ .ttw\:border-warning {
2101
+ border-color: var(--ttw-warning);
2102
+ }
2097
2103
  .ttw\:border-warning\/40 {
2098
2104
  border-color: var(--ttw-warning);
2099
2105
  @supports (color: color-mix(in lab, red, red)) {
@@ -3270,6 +3276,9 @@
3270
3276
  );
3271
3277
  }
3272
3278
  }
3279
+ .ttw\:bg-warning {
3280
+ background-color: var(--ttw-warning);
3281
+ }
3273
3282
  .ttw\:bg-warning-subtle {
3274
3283
  background-color: var(
3275
3284
  --ttw-warning-subtle,
@@ -3860,6 +3869,9 @@
3860
3869
  .ttw\:pl-0 {
3861
3870
  padding-left: 0px;
3862
3871
  }
3872
+ .ttw\:pl-0\.5\! {
3873
+ padding-left: calc(var(--ttw-spacing) * 0.5) !important;
3874
+ }
3863
3875
  .ttw\:pl-1 {
3864
3876
  padding-left: var(--ttw-spacing);
3865
3877
  }
@@ -5109,6 +5121,12 @@
5109
5121
  .ttw\:hover\:border-border:hover {
5110
5122
  border-color: var(--ttw-border);
5111
5123
  }
5124
+ .ttw\:hover\:border-destructive:hover {
5125
+ border-color: var(--ttw-destructive);
5126
+ }
5127
+ .ttw\:hover\:border-warning:hover {
5128
+ border-color: var(--ttw-warning);
5129
+ }
5112
5130
  .ttw\:hover\:border-b-transparent:hover {
5113
5131
  border-bottom-color: transparent;
5114
5132
  }
@@ -6413,6 +6431,10 @@
6413
6431
  .ttw\:\[\&_svg\]\:pointer-events-none svg {
6414
6432
  pointer-events: none;
6415
6433
  }
6434
+ .ttw\:\[\&_svg\]\:size-4 svg {
6435
+ width: calc(var(--ttw-spacing) * 4);
6436
+ height: calc(var(--ttw-spacing) * 4);
6437
+ }
6416
6438
  .ttw\:\[\&_svg\]\:size-5 svg {
6417
6439
  width: calc(var(--ttw-spacing) * 5);
6418
6440
  height: calc(var(--ttw-spacing) * 5);
@@ -1,7 +1,7 @@
1
1
  import "./index5.js";
2
- import "./index8.js";
2
+ import "./index7.js";
3
+ import "./index15.js";
3
4
  import "./index16.js";
4
5
  import "./index17.js";
5
- import "./index18.js";
6
- export { BillsListWidget } from "./index20.js";
7
- import "./index21.js";
6
+ export { BillsListWidget } from "./index19.js";
7
+ import "./index20.js";
@@ -1,19 +1,16 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { BILL_QUEUE_ORDER as e, billQueueFilters as t } from "./index5.js";
6
- import { usePayablesCountQueries as n } from "../../data-access/dist/index3.js";
7
- import "../../data-access/dist/index.js";
8
- import { useMemo as r, useState as i } from "react";
1
+ import { BanIcon as e, Trash2Icon as t } from "lucide-react";
9
2
  // ../../libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index10.js
10
- function a({ enabled: a = !0, canPay: o } = {}) {
11
- let [s, c] = i(o);
12
- o !== void 0 && s !== o && c(o);
13
- let l = o ?? s, u = r(() => e.map((e) => t(e, l ?? !1)), [l]), d = n({
14
- filters: u,
15
- enabled: a && o !== void 0
16
- });
17
- return r(() => Object.fromEntries(e.map((e, t) => [e, d[t]?.count])), [d]);
3
+ function n(n, r) {
4
+ return {
5
+ title: n.title,
6
+ description: n.description,
7
+ confirmButton: n.confirmButton,
8
+ presentation: {
9
+ alignment: "center",
10
+ icon: r === "delete" ? t : e,
11
+ tone: r === "confirm" ? "default" : "destructive",
12
+ actionWidth: "equal"
13
+ }
14
+ };
18
15
  }
19
- export { a as useBillQueueCounts };
16
+ export { n as duplicateRemovalPrompt };
@@ -1,16 +1,85 @@
1
- import { BanIcon as e, Trash2Icon as t } from "lucide-react";
1
+ import { endOfDay as e, endOfMonth as t, endOfQuarter as n, endOfWeek as r, endOfYear as i, startOfDay as a, startOfMonth as o, startOfQuarter as s, startOfWeek as c, startOfYear as l, subDays as u, subMonths as d, subQuarters as f, subWeeks as p, subYears as m } from "date-fns";
2
2
  // ../../libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index11.js
3
- function n(n, r) {
4
- return {
5
- title: n.title,
6
- description: n.description,
7
- confirmButton: n.confirmButton,
8
- presentation: {
9
- alignment: "center",
10
- icon: r === "delete" ? t : e,
11
- tone: r === "confirm" ? "default" : "destructive",
12
- actionWidth: "equal"
3
+ var h = {
4
+ Today: "today",
5
+ ThisWeek: "this_week",
6
+ ThisMonth: "this_month",
7
+ ThisQuarter: "this_quarter",
8
+ ThisYear: "this_year",
9
+ Yesterday: "yesterday",
10
+ LastWeek: "last_week",
11
+ LastMonth: "last_month",
12
+ Last30Days: "last_30_days",
13
+ Last90Days: "last_90_days",
14
+ LastQuarter: "last_quarter",
15
+ LastYear: "last_year"
16
+ };
17
+ function g(g, _ = /* @__PURE__ */ new Date()) {
18
+ let v = a(_);
19
+ switch (g) {
20
+ case h.Today: return {
21
+ from: v,
22
+ to: e(v)
23
+ };
24
+ case h.ThisWeek: return {
25
+ from: c(v),
26
+ to: r(v)
27
+ };
28
+ case h.ThisMonth: return {
29
+ from: o(v),
30
+ to: t(v)
31
+ };
32
+ case h.ThisQuarter: return {
33
+ from: s(v),
34
+ to: n(v)
35
+ };
36
+ case h.ThisYear: return {
37
+ from: l(v),
38
+ to: i(v)
39
+ };
40
+ case h.Yesterday: {
41
+ let t = u(v, 1);
42
+ return {
43
+ from: t,
44
+ to: e(t)
45
+ };
13
46
  }
14
- };
47
+ case h.LastWeek: {
48
+ let e = c(p(v, 1));
49
+ return {
50
+ from: e,
51
+ to: r(e)
52
+ };
53
+ }
54
+ case h.LastMonth: {
55
+ let e = o(d(v, 1));
56
+ return {
57
+ from: e,
58
+ to: t(e)
59
+ };
60
+ }
61
+ case h.Last30Days: return {
62
+ from: u(v, 29),
63
+ to: e(v)
64
+ };
65
+ case h.Last90Days: return {
66
+ from: u(v, 89),
67
+ to: e(v)
68
+ };
69
+ case h.LastQuarter: {
70
+ let e = s(f(v, 1));
71
+ return {
72
+ from: e,
73
+ to: n(e)
74
+ };
75
+ }
76
+ case h.LastYear: {
77
+ let e = l(m(v, 1));
78
+ return {
79
+ from: e,
80
+ to: i(e)
81
+ };
82
+ }
83
+ }
15
84
  }
16
- export { n as duplicateRemovalPrompt };
85
+ export { h as BillsDatePreset, g as resolveDatePreset };
@@ -1,85 +1,49 @@
1
- import { endOfDay as e, endOfMonth as t, endOfQuarter as n, endOfWeek as r, endOfYear as i, startOfDay as a, startOfMonth as o, startOfQuarter as s, startOfWeek as c, startOfYear as l, subDays as u, subMonths as d, subQuarters as f, subWeeks as p, subYears as m } from "date-fns";
1
+ import { BillStatusFilter as e } from "./index4.js";
2
+ import { BillsDatePreset as t } from "./index11.js";
2
3
  // ../../libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index12.js
3
- var h = {
4
- Today: "today",
5
- ThisWeek: "this_week",
6
- ThisMonth: "this_month",
7
- ThisQuarter: "this_quarter",
8
- ThisYear: "this_year",
9
- Yesterday: "yesterday",
10
- LastWeek: "last_week",
11
- LastMonth: "last_month",
12
- Last30Days: "last_30_days",
13
- Last90Days: "last_90_days",
14
- LastQuarter: "last_quarter",
15
- LastYear: "last_year"
4
+ var n = {
5
+ presets: {
6
+ [t.Today]: "Today",
7
+ [t.ThisWeek]: "This week",
8
+ [t.ThisMonth]: "This month",
9
+ [t.ThisQuarter]: "This quarter",
10
+ [t.ThisYear]: "This year",
11
+ [t.Yesterday]: "Yesterday",
12
+ [t.LastWeek]: "Last week",
13
+ [t.LastMonth]: "Last month",
14
+ [t.Last30Days]: "Last 30 days",
15
+ [t.Last90Days]: "Last 90 days",
16
+ [t.LastQuarter]: "Last quarter",
17
+ [t.LastYear]: "Last year"
18
+ },
19
+ presetGroupCurrent: "Current",
20
+ presetGroupPast: "Past",
21
+ statuses: {
22
+ [e.Draft]: "Draft",
23
+ [e.ReadyToSubmit]: "Ready to submit",
24
+ [e.PendingApproval]: "Pending review",
25
+ [e.ReadyToPay]: "Ready to pay",
26
+ [e.Paid]: "Paid",
27
+ [e.Canceled]: "Cancelled",
28
+ [e.Rejected]: "Rejected"
29
+ },
30
+ dateFieldNames: {
31
+ issueDate: "Issue date",
32
+ dueDate: "Due date",
33
+ addedOn: "Added on"
34
+ },
35
+ dateChip: (e, t) => `${e}: ${t}`,
36
+ statusChip: (e) => `Status: ${e}`,
37
+ vendorChip: (e) => `Vendor: ${e}`,
38
+ amountChip: (e) => `Total amount: ${e}`,
39
+ attachmentChipHas: "Has attachment",
40
+ attachmentChipNone: "No attachment",
41
+ moreSelected: (e, t) => `${e} + ${t} more`,
42
+ amountAtLeast: (e) => `${e} or more`,
43
+ amountAtMost: (e) => `${e} or less`,
44
+ amountBetween: (e, t) => `${e} - ${t}`,
45
+ dateRange: (e, t) => `${e} - ${t}`,
46
+ dateFrom: (e) => `From ${e}`,
47
+ dateTo: (e) => `Until ${e}`
16
48
  };
17
- function g(g, _ = /* @__PURE__ */ new Date()) {
18
- let v = a(_);
19
- switch (g) {
20
- case h.Today: return {
21
- from: v,
22
- to: e(v)
23
- };
24
- case h.ThisWeek: return {
25
- from: c(v),
26
- to: r(v)
27
- };
28
- case h.ThisMonth: return {
29
- from: o(v),
30
- to: t(v)
31
- };
32
- case h.ThisQuarter: return {
33
- from: s(v),
34
- to: n(v)
35
- };
36
- case h.ThisYear: return {
37
- from: l(v),
38
- to: i(v)
39
- };
40
- case h.Yesterday: {
41
- let t = u(v, 1);
42
- return {
43
- from: t,
44
- to: e(t)
45
- };
46
- }
47
- case h.LastWeek: {
48
- let e = c(p(v, 1));
49
- return {
50
- from: e,
51
- to: r(e)
52
- };
53
- }
54
- case h.LastMonth: {
55
- let e = o(d(v, 1));
56
- return {
57
- from: e,
58
- to: t(e)
59
- };
60
- }
61
- case h.Last30Days: return {
62
- from: u(v, 29),
63
- to: e(v)
64
- };
65
- case h.Last90Days: return {
66
- from: u(v, 89),
67
- to: e(v)
68
- };
69
- case h.LastQuarter: {
70
- let e = s(f(v, 1));
71
- return {
72
- from: e,
73
- to: n(e)
74
- };
75
- }
76
- case h.LastYear: {
77
- let e = l(m(v, 1));
78
- return {
79
- from: e,
80
- to: i(e)
81
- };
82
- }
83
- }
84
- }
85
- export { h as BillsDatePreset, g as resolveDatePreset };
49
+ export { n as BILLS_FILTER_LABELS_EN };
@@ -1,49 +1,263 @@
1
- import { BillStatusFilter as e } from "./index4.js";
2
- import { BillsDatePreset as t } from "./index12.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { formatMoneyExact as e } from "../../../../shared/util/dist/lib/formatMoneyExact.js";
6
+ import "../../../../shared/util/dist/index.js";
7
+ import "../../../util/dist/index.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/index9.js";
13
+ import "../../ui/dist/index.js";
14
+ import { BillsDatePreset as o, resolveDatePreset as s } from "./index11.js";
15
+ import { BILLS_FILTER_LABELS_EN as c } from "./index12.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";
3
18
  // ../../libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index13.js
4
- var n = {
5
- presets: {
6
- [t.Today]: "Today",
7
- [t.ThisWeek]: "This week",
8
- [t.ThisMonth]: "This month",
9
- [t.ThisQuarter]: "This quarter",
10
- [t.ThisYear]: "This year",
11
- [t.Yesterday]: "Yesterday",
12
- [t.LastWeek]: "Last week",
13
- [t.LastMonth]: "Last month",
14
- [t.Last30Days]: "Last 30 days",
15
- [t.Last90Days]: "Last 90 days",
16
- [t.LastQuarter]: "Last quarter",
17
- [t.LastYear]: "Last year"
18
- },
19
- presetGroupCurrent: "Current",
20
- presetGroupPast: "Past",
21
- statuses: {
22
- [e.Draft]: "Draft",
23
- [e.ReadyToSubmit]: "Ready to submit",
24
- [e.PendingApproval]: "Pending review",
25
- [e.ReadyToPay]: "Ready to pay",
26
- [e.Paid]: "Paid",
27
- [e.Canceled]: "Cancelled",
28
- [e.Rejected]: "Rejected"
29
- },
30
- dateFieldNames: {
31
- issueDate: "Issue date",
32
- dueDate: "Due date",
33
- addedOn: "Added on"
34
- },
35
- dateChip: (e, t) => `${e}: ${t}`,
36
- statusChip: (e) => `Status: ${e}`,
37
- vendorChip: (e) => `Vendor: ${e}`,
38
- amountChip: (e) => `Total amount: ${e}`,
39
- attachmentChipHas: "Has attachment",
40
- attachmentChipNone: "No attachment",
41
- moreSelected: (e, t) => `${e} + ${t} more`,
42
- amountAtLeast: (e) => `${e} or more`,
43
- amountAtMost: (e) => `${e} or less`,
44
- amountBetween: (e, t) => `${e} - ${t}`,
45
- dateRange: (e, t) => `${e} - ${t}`,
46
- dateFrom: (e) => `From ${e}`,
47
- dateTo: (e) => `Until ${e}`
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"
48
42
  };
49
- export { n as BILLS_FILTER_LABELS_EN };
43
+ function S() {
44
+ return {
45
+ dateField: a.DueDate,
46
+ statuses: [],
47
+ amountMode: "any",
48
+ amountMin: "",
49
+ amountMax: "",
50
+ vendorIds: []
51
+ };
52
+ }
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?.(), {
86
+ ...e,
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) : "";
125
+ };
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
+ });
132
+ }
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
+ });
148
+ }
149
+ return k.hasFile !== void 0 && t.push({
150
+ key: h.Attachment,
151
+ label: k.hasFile ? O.attachmentChipHas : O.attachmentChipNone
152
+ }), t;
153
+ }, [
154
+ O,
155
+ k,
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]);
198
+ return {
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?.();
220
+ },
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
261
+ };
262
+ }
263
+ export { h as BillsFilterChipKey, w as useBillsFilters };