@tesouro/embedded-components-react 0.5.219 → 0.5.221

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 (20) hide show
  1. package/dist/index.css +3 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +1 -0
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +2 -2
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +22 -1
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +39 -70
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +34 -106
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +75 -307
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +121 -0
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +317 -0
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +15 -15
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +6 -6
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +50 -335
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +353 -0
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +8 -7
  19. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  20. package/package.json +1 -1
package/dist/index.css CHANGED
@@ -2327,6 +2327,9 @@
2327
2327
  .ttw\:border-border {
2328
2328
  border-color: var(--ttw-border);
2329
2329
  }
2330
+ .ttw\:border-card {
2331
+ border-color: var(--ttw-card);
2332
+ }
2330
2333
  .ttw\:border-cyan-100 {
2331
2334
  border-color: var(--ttw-color-cyan-100);
2332
2335
  }
package/dist/index.d.ts CHANGED
@@ -4937,6 +4937,7 @@ interface ReceivablesScreenLabels {
4937
4937
  templateSettingsButton: string;
4938
4938
  searchPlaceholder: string;
4939
4939
  statusFilterAll: string;
4940
+ statusCardsAll: string;
4940
4941
  tabInvoices: string;
4941
4942
  tabQuotes: string;
4942
4943
  tabCreditNotes: string;
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import { InsightsWidget as L } from "./libs/tesouro-embedded-components-react/in
27
27
  import { UploadReceiptWidget as R } from "./libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index2.js";
28
28
  import { ExpenseManagementWidget as z } from "./libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index21.js";
29
29
  import { InvoicingWidget as B } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index3.js";
30
- import { ReceivablesWidget as V } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js";
30
+ import { ReceivablesWidget as V } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js";
31
31
  import { SettingsSection as H } from "./libs/tesouro-embedded-components-react/settings-widget/feature/dist/index4.js";
32
32
  import { HELP_FAQ_EN as U } from "./libs/tesouro-embedded-components-react/settings-widget/help/ui/contract/dist/index3.js";
33
33
  import { SettingsWidget as W } from "./libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js";
@@ -927,6 +927,7 @@ interface ReceivablesScreenLabels {
927
927
  templateSettingsButton: string;
928
928
  searchPlaceholder: string;
929
929
  statusFilterAll: string;
930
+ statusCardsAll: string;
930
931
  tabInvoices: string;
931
932
  tabQuotes: string;
932
933
  tabCreditNotes: string;
@@ -1,3 +1,3 @@
1
- import { ReceivablesWidget as e } from "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js";
1
+ import { ReceivablesWidget as e } from "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js";
2
2
  import "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js";
3
3
  export { e as ReceivablesWidget };
@@ -9,5 +9,5 @@ import "./index8.js";
9
9
  import { useMarkReceivablePaidMutation as m, useMarkReceivablePartiallyPaidMutation as h, useMarkReceivableUncollectibleMutation as g } from "./index9.js";
10
10
  import { useReceivableHistoryQuery as _, useReceivableMailsQuery as v, useReceivablePdfLinkQuery as y, useReceivableQuery as b, useReceivablesQuery as x } from "./index10.js";
11
11
  import { useCreateOverdueReminderMutation as S, useCreatePaymentReminderMutation as C, useCreateRecurrenceMutation as w, useOverdueRemindersQuery as T, usePaymentRemindersQuery as E, useRecurrenceQuery as D, useUpdateRecurrenceMutation as O } from "./index11.js";
12
- import "./index12.js";
13
- export { o as useAcceptReceivableMutation, s as useCancelReceivableMutation, c as useCloneReceivableMutation, t as useCreateEntityBankAccountMutation, S as useCreateOverdueReminderMutation, C as useCreatePaymentReminderMutation, l as useCreateReceivableMutation, w as useCreateRecurrenceMutation, u as useDeclineReceivableMutation, r as useDeleteReceivableAttachmentMutation, d as useDeleteReceivableMutation, f as useIssueReceivableMutation, m as useMarkReceivablePaidMutation, h as useMarkReceivablePartiallyPaidMutation, g as useMarkReceivableUncollectibleMutation, T as useOverdueRemindersQuery, n as usePaymentAccountsQuery, E as usePaymentRemindersQuery, e as usePaymentTermsQuery, _ as useReceivableHistoryQuery, v as useReceivableMailsQuery, y as useReceivablePdfLinkQuery, b as useReceivableQuery, x as useReceivablesQuery, D as useRecurrenceQuery, a as useSendReceivableEmailMutation, p as useUpdateReceivableMutation, O as useUpdateRecurrenceMutation, i as useUploadReceivableAttachmentMutation };
12
+ import { useReceivablesAnalyticsQuery as k } from "./index12.js";
13
+ export { o as useAcceptReceivableMutation, s as useCancelReceivableMutation, c as useCloneReceivableMutation, t as useCreateEntityBankAccountMutation, S as useCreateOverdueReminderMutation, C as useCreatePaymentReminderMutation, l as useCreateReceivableMutation, w as useCreateRecurrenceMutation, u as useDeclineReceivableMutation, r as useDeleteReceivableAttachmentMutation, d as useDeleteReceivableMutation, f as useIssueReceivableMutation, m as useMarkReceivablePaidMutation, h as useMarkReceivablePartiallyPaidMutation, g as useMarkReceivableUncollectibleMutation, T as useOverdueRemindersQuery, n as usePaymentAccountsQuery, E as usePaymentRemindersQuery, e as usePaymentTermsQuery, _ as useReceivableHistoryQuery, v as useReceivableMailsQuery, y as useReceivablePdfLinkQuery, b as useReceivableQuery, k as useReceivablesAnalyticsQuery, x as useReceivablesQuery, D as useRecurrenceQuery, a as useSendReceivableEmailMutation, p as useUpdateReceivableMutation, O as useUpdateRecurrenceMutation, i as useUploadReceivableAttachmentMutation };
@@ -2,5 +2,26 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
+ import { getAnalyticsReceivablesOptions as e } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
6
+ import { withAuthEpoch as t } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
7
+ import { useEmbedApi as n } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
+ import { organizationHeaders as r } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
5
9
  import "../../../shared/data-access/dist/index.js";
6
- import "@tanstack/react-query";
10
+ import { useQuery as i } from "@tanstack/react-query";
11
+ //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js
12
+ function a({ enabled: a = !0, ...o }) {
13
+ let { client: s, organizationId: c, widgetToken: l, authEpoch: u, organizationPending: d } = n(), f = !!(c && l) && a, p = e({
14
+ client: s,
15
+ headers: r(c),
16
+ query: o
17
+ });
18
+ return i({
19
+ ...t(p, {
20
+ authEpoch: u,
21
+ organizationPending: d
22
+ }),
23
+ enabled: f
24
+ });
25
+ }
26
+ //#endregion
27
+ export { a as useReceivablesAnalyticsQuery };
@@ -1,3 +1,3 @@
1
1
  import { InvoicingWidget as e } from "./index3.js";
2
- import { ReceivablesWidget as t } from "./index26.js";
2
+ import { ReceivablesWidget as t } from "./index28.js";
3
3
  export { e as InvoicingWidget, t as ReceivablesWidget };
@@ -1,75 +1,44 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { buildReceivableRows as e, statusFilterOptions as t, typeForTab as n } from "./index12.js";
6
- import { useReceivablesQuery as r } from "../../data-access/dist/index10.js";
7
- import "../../data-access/dist/index.js";
8
- import { useCallback as i, useEffect as a, useMemo as o, useState as s } from "react";
1
+ import { formatMoney as e, getStatusTone as t } from "./index12.js";
9
2
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js
10
- var c = [];
11
- function l({ activeTab: l, messages: d }) {
12
- let [f, p] = s([]), [m, h] = s(10), [g, _] = s(), [v, y] = s(""), [b, x] = s(""), [S, C] = s("all");
13
- a(() => {
14
- _(void 0), C("all");
15
- }, [l]), a(() => {
16
- let e = setTimeout(() => {
17
- x(v), _(void 0);
18
- }, 300);
19
- return () => clearTimeout(e);
20
- }, [v]);
21
- let w = f[0]?.id, T = w ? u[w] : void 0, E = f[0] ? f[0].desc ? "desc" : "asc" : void 0, D = r({
22
- type: n(l),
23
- limit: m,
24
- pagination_token: g,
25
- search_text: b || void 0,
26
- status: S === "all" ? void 0 : S,
27
- ...T ? {
28
- sort: T,
29
- order: E
30
- } : {}
31
- }), O = D.data?.data ?? c, k = o(() => new Map(O.map((e) => [e.id, e])), [O]), A = i((e) => k.get(e), [k]), j = o(() => e({
32
- receivables: O,
33
- messages: d
34
- }), [d, O]), M = !!b || S !== "all", N = i((e) => {
35
- let t = typeof e == "function" ? e(f) : e;
36
- p(t), _(void 0);
37
- }, [f]), P = i((e) => {
38
- h(e), _(void 0);
39
- }, []), F = i((e) => {
40
- C(e), _(void 0);
41
- }, []), I = i(() => _(D.data?.next_pagination_token ?? void 0), [D.data?.next_pagination_token]), L = i(() => _(D.data?.prev_pagination_token ?? void 0), [D.data?.prev_pagination_token]), R = i(() => {
42
- D.refetch();
43
- }, [D]);
3
+ var n = [
4
+ "draft",
5
+ "issued",
6
+ "overdue",
7
+ "partially_paid",
8
+ "paid",
9
+ "recurring",
10
+ "canceled",
11
+ "uncollectible"
12
+ ];
13
+ function r(e) {
14
+ let t = n.indexOf(e);
15
+ return t === -1 ? n.length : t;
16
+ }
17
+ function i({ counts: n, amounts: i, statusFilter: a, statusLabels: o, fallback: s }) {
18
+ let c = new Map(Object.entries(o)), l = new Map(i.map((e) => [e.dimension_value, e.metric_value])), u = n.flatMap((e) => e.dimension_value ? [{
19
+ status: e.dimension_value,
20
+ count: e.metric_value
21
+ }] : []), d = u.filter(({ status: e }) => e !== "recurring").reduce((e, { count: t }) => e + t, 0);
44
22
  return {
45
- rows: j,
46
- isLoading: D.isLoading,
47
- isError: D.isError,
48
- sorting: f,
49
- onSortingChange: N,
50
- pageSize: m,
51
- onPageSizeChange: P,
52
- hasNextPage: !!D.data?.next_pagination_token,
53
- hasPrevPage: !!D.data?.prev_pagination_token,
54
- onNextPage: I,
55
- onPrevPage: L,
56
- searchValue: v,
57
- onSearchChange: y,
58
- statusFilter: S,
59
- statusOptions: t(),
60
- onStatusFilterChange: F,
61
- isFiltering: M,
62
- onRetry: R,
63
- getReceivableById: A
23
+ kind: "ready",
24
+ all: {
25
+ value: "all",
26
+ countLabel: String(d),
27
+ selected: a === "all"
28
+ },
29
+ statuses: [...u].sort((e, t) => r(e.status) - r(t.status)).map(({ status: n, count: r }) => ({
30
+ value: n,
31
+ statusLabel: c.get(n) ?? o.unknown,
32
+ statusTone: t(n),
33
+ countLabel: String(r),
34
+ amountLabel: e({
35
+ amount: l.get(n) ?? 0,
36
+ currency: "USD",
37
+ fallback: s
38
+ }),
39
+ selected: a === n
40
+ }))
64
41
  };
65
42
  }
66
- var u = {
67
- documentLabel: "document_id",
68
- customerLabel: "counterpart_name",
69
- status: "status",
70
- issueDateLabel: "issue_date",
71
- dueDateLabel: "due_date",
72
- totalLabel: "total_amount"
73
- };
74
43
  //#endregion
75
- export { l as useReceivablesTable };
44
+ export { i as buildReceivableStatusCardsView };
@@ -2,114 +2,42 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { useAnalyticsTrack as e } from "../../../shared/feature/dist/lib/analytics/hooks.js";
6
- import "../../../shared/feature/dist/index.js";
7
- import { ReceivablesWidgetAnalyticsEvent as t } from "./index2.js";
8
- import { coerceEnabledTabs as n, resolveInitialTab as r, tabForType as i, typeForTab as a } from "./index12.js";
9
- import { RECEIVABLE_MESSAGE_LABELS_EN as o } from "./index13.js";
10
- import { useReceivableActions as s } from "./index15.js";
11
- import { useReceivableDetails as c } from "./index16.js";
12
- import { hasSelectedText as l } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
13
- import "../../../shared/product-catalog/feature/dist/index.js";
14
- import { useReceivableForm as u } from "./index23.js";
15
- import { useReceivablesTable as d } from "./index24.js";
16
- import { useCallback as f, useEffect as p, useMemo as m, useState as h } from "react";
5
+ import { useReceivablesAnalyticsQuery as e } from "../../data-access/dist/index12.js";
6
+ import "../../data-access/dist/index.js";
7
+ import { buildReceivableStatusCardsView as t } from "./index24.js";
8
+ import { useMemo as n } from "react";
17
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js
18
- function g({ counterpartMessageLabels: g, defaultTab: _, embeddedBankName: v, enabledTabs: y, messageLabels: b, onReceivableCreated: x, onReceivableOpened: S }) {
19
- let C = e();
20
- p(() => {
21
- C(t.Mounted);
22
- }, [C]);
23
- let w = m(() => ({
24
- ...o,
25
- ...b
26
- }), [b]), T = m(() => n(y), [y]), [E, D] = h(() => r({
27
- defaultTab: _,
28
- enabledTabs: T
29
- })), [O, k] = h(), [A, j] = h(!1);
30
- p(() => {
31
- T.includes(E) || D(r({
32
- defaultTab: _,
33
- enabledTabs: T
34
- }));
10
+ function r({ enabled: r, statusFilter: i, messages: a, statusLabels: o }) {
11
+ let s = e({
12
+ enabled: r,
13
+ dimension: "status",
14
+ metric: "id",
15
+ aggregation_function: "count",
16
+ type: "invoice"
17
+ }), c = e({
18
+ enabled: r,
19
+ dimension: "status",
20
+ metric: "total_amount",
21
+ aggregation_function: "summary",
22
+ type: "invoice"
23
+ }), l = s.data?.data, u = c.data?.data, d = s.isPending || c.isPending;
24
+ return n(() => {
25
+ if (r) return d ? { kind: "loading" } : t({
26
+ counts: l ?? [],
27
+ amounts: u ?? [],
28
+ statusFilter: i,
29
+ statusLabels: o,
30
+ fallback: a.notAvailable
31
+ });
35
32
  }, [
36
- E,
37
- _,
38
- T
33
+ u,
34
+ l,
35
+ r,
36
+ d,
37
+ a.notAvailable,
38
+ i,
39
+ o
39
40
  ]);
40
- let M = f((e, t) => {
41
- D(i(t)), k(e), j(!0), x?.(e, t);
42
- }, [x]), N = d({
43
- activeTab: E,
44
- messages: w
45
- }), P = c({
46
- selectedReceivableId: O,
47
- enabled: A,
48
- messages: w
49
- }), F = u({
50
- messages: w,
51
- counterpartMessageLabels: g,
52
- embeddedBankName: v,
53
- onCreated: M
54
- }), I = f(() => {
55
- let e = a(E);
56
- F.openCreate(e === "quote" ? "quote" : "invoice");
57
- }, [E, F.openCreate]), L = s({
58
- selectedReceivable: P.receivable,
59
- messages: w,
60
- onCreated: M,
61
- onDeleted: (e) => {
62
- e === O && (k(void 0), j(!1));
63
- }
64
- }), R = f((e) => {
65
- l() || (k(e.id), j(!0), S?.(e.id, e.type));
66
- }, [S]);
67
- return {
68
- activeTab: E,
69
- enabledTabs: T,
70
- setActiveTab: D,
71
- table: N,
72
- details: P,
73
- detailsOpen: A,
74
- closeDetails: f(() => {
75
- j(!1), k(void 0);
76
- }, []),
77
- form: F,
78
- openCreate: I,
79
- actions: L,
80
- handleRowClick: R,
81
- handleActionClick: f((e, t) => {
82
- let n = N.getReceivableById(t.id);
83
- if (e === "edit") {
84
- if (n) {
85
- F.openEdit(n);
86
- return;
87
- }
88
- k(t.id), j(!0);
89
- return;
90
- }
91
- k(t.id), L.openAction(e, t, n ?? null);
92
- }, [
93
- L,
94
- F.openEdit,
95
- N.getReceivableById
96
- ]),
97
- handleDetailsActionClick: f((e, t) => {
98
- if (e === "edit") {
99
- P.receivable && (F.openEdit(P.receivable), j(!1));
100
- return;
101
- }
102
- L.openAction(e, {
103
- id: t.id,
104
- title: t.title,
105
- type: t.type
106
- }, P.receivable ?? null);
107
- }, [
108
- L,
109
- P.receivable,
110
- F.openEdit
111
- ])
112
- };
113
41
  }
114
42
  //#endregion
115
- export { g as useReceivablesWidget };
43
+ export { r as useReceivableStatusCards };