@tesouro/embedded-components-react 0.5.228 → 0.5.230

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 (85) hide show
  1. package/README.md +22 -21
  2. package/dist/index.d.ts +34 -1
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +34 -1
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +1 -1
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +32 -33
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +34 -32
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +1 -1
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +120 -52
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +44 -100
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +93 -337
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +356 -211
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +225 -157
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +152 -21
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +18 -221
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +224 -56
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +126 -231
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +53 -298
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +232 -43
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +295 -118
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +38 -145
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +126 -46
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +145 -117
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +38 -91
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +113 -107
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +94 -27
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +104 -619
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +34 -41
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +635 -34
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +39 -77
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +34 -117
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +75 -318
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index34.js +139 -0
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js +340 -0
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +55 -468
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +443 -97
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +24 -21
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +32 -2
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +205 -84
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +161 -3
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +12 -20
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +23 -40
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +2 -17
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +90 -68
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +3 -20
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +20 -12
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +40 -30
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +14 -7
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +15 -301
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +73 -1
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +17 -45
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +12 -68
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +26 -490
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +294 -95
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +1 -0
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +48 -2
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +72 -4
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +496 -1
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +121 -27
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +97 -91
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +2 -236
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +3 -2
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +1 -249
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +89 -82
  69. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +23 -54
  70. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +223 -340
  71. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +3 -0
  72. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +249 -0
  73. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +100 -216
  74. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +93 -0
  75. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +59 -0
  76. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +353 -0
  77. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +35 -29
  78. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +2 -216
  79. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +9 -159
  80. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +27 -14
  81. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +216 -23
  82. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  83. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +12 -12
  84. package/package.json +1 -1
  85. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +0 -28
@@ -1,82 +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 { useReceivableStatusCards as i } from "./index30.js";
9
- import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
1
+ import { formatMoney as e, getStatusTone as t } from "./index13.js";
10
2
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js
11
- var l = [];
12
- function u({ activeTab: u, messages: f, statusLabels: p }) {
13
- let [m, h] = c([]), [g, _] = c(10), [v, y] = c(), [b, x] = c(""), [S, C] = c(""), [w, T] = c("all");
14
- o(() => {
15
- y(void 0), T("all");
16
- }, [u]), o(() => {
17
- let e = setTimeout(() => {
18
- C(b), y(void 0);
19
- }, 300);
20
- return () => clearTimeout(e);
21
- }, [b]);
22
- let E = m[0]?.id, D = E ? d[E] : void 0, O = m[0] ? m[0].desc ? "desc" : "asc" : void 0, k = r({
23
- type: n(u),
24
- limit: g,
25
- pagination_token: v,
26
- search_text: S || void 0,
27
- status: w === "all" ? void 0 : w,
28
- ...D ? {
29
- sort: D,
30
- order: O
31
- } : {}
32
- }), A = i({
33
- enabled: u === "invoices",
34
- statusFilter: w,
35
- messages: f,
36
- statusLabels: p
37
- }), j = k.data?.data ?? l, M = s(() => new Map(j.map((e) => [e.id, e])), [j]), N = a((e) => M.get(e), [M]), P = s(() => e({
38
- receivables: j,
39
- messages: f
40
- }), [f, j]), F = !!S || w !== "all", I = a((e) => {
41
- let t = typeof e == "function" ? e(m) : e;
42
- h(t), y(void 0);
43
- }, [m]), L = a((e) => {
44
- _(e), y(void 0);
45
- }, []), R = a((e) => {
46
- T(e), y(void 0);
47
- }, []), z = a(() => y(k.data?.next_pagination_token ?? void 0), [k.data?.next_pagination_token]), B = a(() => y(k.data?.prev_pagination_token ?? void 0), [k.data?.prev_pagination_token]), V = a(() => {
48
- k.refetch();
49
- }, [k]);
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);
50
22
  return {
51
- rows: P,
52
- isLoading: k.isLoading,
53
- isError: k.isError,
54
- sorting: m,
55
- onSortingChange: I,
56
- pageSize: g,
57
- onPageSizeChange: L,
58
- hasNextPage: !!k.data?.next_pagination_token,
59
- hasPrevPage: !!k.data?.prev_pagination_token,
60
- onNextPage: z,
61
- onPrevPage: B,
62
- searchValue: b,
63
- onSearchChange: x,
64
- statusFilter: w,
65
- statusOptions: t(w),
66
- onStatusFilterChange: R,
67
- statusCards: A,
68
- isFiltering: F,
69
- onRetry: V,
70
- getReceivableById: N
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
+ }))
71
41
  };
72
42
  }
73
- var d = {
74
- documentLabel: "document_id",
75
- customerLabel: "counterpart_name",
76
- status: "status",
77
- issueDateLabel: "issue_date",
78
- dueDateLabel: "due_date",
79
- totalLabel: "total_amount"
80
- };
81
43
  //#endregion
82
- export { u as useReceivablesTable };
44
+ export { i as buildReceivableStatusCardsView };
@@ -2,125 +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 { RECEIVABLE_STATUS_BADGE_LABELS_EN as n } from "../../ui/dist/index4.js";
9
- import "../../ui/dist/index.js";
10
- import { coerceEnabledTabs as r, getDocumentTitle as i, resolveInitialTab as a, tabForType as o, typeForTab as s } from "./index12.js";
11
- import { RECEIVABLE_MESSAGE_LABELS_EN as c } from "./index13.js";
12
- import { useReceivableActions as l } from "./index16.js";
13
- import { useReceivableDetails as u } from "./index20.js";
14
- import { hasSelectedText as d } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
15
- import "../../../shared/product-catalog/feature/dist/index.js";
16
- import { useReceivableForm as f } from "./index28.js";
17
- import { useReceivablesTable as p } from "./index31.js";
18
- import { useCallback as m, useEffect as h, useMemo as g, useState as _ } 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 "./index31.js";
8
+ import { useMemo as n } from "react";
19
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js
20
- function v({ counterpartMessageLabels: v, defaultTab: y, embeddedBankName: b, enabledTabs: x, messageLabels: S, onReceivableCreated: C, onReceivableOpened: w, screenLabels: T }) {
21
- let E = e();
22
- h(() => {
23
- E(t.Mounted);
24
- }, [E]);
25
- let D = g(() => ({
26
- ...c,
27
- ...S
28
- }), [S]), O = T?.statusBadge, k = g(() => ({
29
- ...n,
30
- ...O
31
- }), [O]), A = g(() => r(x), [x]), [j, M] = _(() => a({
32
- defaultTab: y,
33
- enabledTabs: A
34
- })), [N, P] = _(), [F, I] = _(!1);
35
- h(() => {
36
- A.includes(j) || M(a({
37
- defaultTab: y,
38
- enabledTabs: A
39
- }));
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
+ });
40
32
  }, [
41
- j,
42
- y,
43
- A
33
+ u,
34
+ l,
35
+ r,
36
+ d,
37
+ a.notAvailable,
38
+ i,
39
+ o
44
40
  ]);
45
- let L = m((e, t) => {
46
- M(o(t)), P(e), I(!0), C?.(e, t);
47
- }, [C]), R = p({
48
- activeTab: j,
49
- messages: D,
50
- statusLabels: k
51
- }), z = u({
52
- selectedReceivableId: N,
53
- enabled: F,
54
- messages: D,
55
- statusLabels: k
56
- }), B = f({
57
- messages: D,
58
- counterpartMessageLabels: v,
59
- embeddedBankName: b,
60
- onCreated: L
61
- }), V = m(() => {
62
- let e = s(j);
63
- B.openCreate(e === "quote" ? "quote" : "invoice");
64
- }, [j, B.openCreate]), H = l({
65
- selectedReceivable: z.receivable,
66
- messages: D,
67
- onCreated: L,
68
- onDeleted: (e) => {
69
- e === N && (P(void 0), I(!1));
70
- },
71
- onCompleteBeforeIssue: (e) => {
72
- B.openEdit(e, { highlightForIssue: !0 }), I(!1);
73
- }
74
- }), U = m((e) => {
75
- d() || (P(e.id), I(!0), w?.(e.id, e.type));
76
- }, [w]);
77
- return {
78
- activeTab: j,
79
- enabledTabs: A,
80
- setActiveTab: M,
81
- table: R,
82
- details: z,
83
- detailsOpen: F,
84
- closeDetails: m(() => {
85
- I(!1), P(void 0);
86
- }, []),
87
- form: B,
88
- openCreate: V,
89
- actions: H,
90
- handleRowClick: U,
91
- handleActionClick: m((e, t) => {
92
- let n = R.getReceivableById(t.id);
93
- if (e === "edit") {
94
- if (n) {
95
- B.openEdit(n);
96
- return;
97
- }
98
- P(t.id), I(!0);
99
- return;
100
- }
101
- P(t.id), H.openAction(e, t, n ?? null);
102
- }, [
103
- H,
104
- B.openEdit,
105
- R.getReceivableById
106
- ]),
107
- handleDetailsActionClick: m((e, t) => {
108
- if (e === "edit") {
109
- z.receivable && (B.openEdit(z.receivable), I(!1));
110
- return;
111
- }
112
- H.openAction(e, {
113
- id: t.id,
114
- title: z.receivable ? i(z.receivable, D) : t.title,
115
- type: t.type
116
- }, z.receivable ?? null);
117
- }, [
118
- H,
119
- z.receivable,
120
- B.openEdit,
121
- D
122
- ])
123
- };
124
41
  }
125
42
  //#endregion
126
- export { v as useReceivablesWidget };
43
+ export { r as useReceivableStatusCards };