@tesouro/embedded-components-react 0.5.235 → 0.5.236

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 (77) hide show
  1. package/README.md +3 -0
  2. package/dist/index.d.ts +110 -1
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +110 -1
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +1 -1
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +3 -3
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +1 -1
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +1 -1
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +1 -1
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +210 -208
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +98 -40
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +159 -39
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index34.js +53 -77
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js +99 -132
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index36.js +40 -341
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index37.js +43 -0
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index38.js +92 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index39.js +146 -0
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index40.js +354 -0
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +28 -24
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +2 -37
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +9 -214
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +27 -159
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +233 -14
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +34 -22
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +214 -2
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +153 -87
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +16 -3
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +22 -21
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +2 -51
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +30 -15
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +90 -14
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +3 -10
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +20 -69
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +51 -33
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +16 -17
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +8 -14
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +70 -30
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +33 -14
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +17 -25
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +12 -83
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +9 -121
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +28 -401
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +16 -2
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +22 -42
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +80 -65
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +383 -473
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +2 -106
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +48 -0
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +72 -2
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +498 -4
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +106 -1
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +141 -93
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +2 -28
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +4 -236
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +0 -2
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +90 -239
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +24 -89
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +231 -54
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +3 -353
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index48.js +249 -0
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +93 -0
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +3 -40
  69. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +59 -0
  70. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +353 -0
  71. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +18 -2
  72. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +121 -9
  73. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +100 -27
  74. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +38 -233
  75. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  76. package/package.json +1 -1
  77. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +0 -100
@@ -2,143 +2,110 @@
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/index9.js";
9
- import "../../ui/dist/index.js";
10
- import { hasSelectedText as r } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
11
- import "../../../shared/product-catalog/feature/dist/index.js";
12
- import { getCreateFollowUp as i } from "./index8.js";
13
- import { coerceEnabledTabs as a, getDocumentTitle as o, resolveInitialTab as s, tabForType as c, typeForTab as l } from "./index13.js";
14
- import { RECEIVABLE_MESSAGE_LABELS_EN as u } from "./index14.js";
15
- import { useReceivableActions as d } from "./index17.js";
16
- import { useReceivableActionsModal as f } from "./index18.js";
17
- import { useReceivableDetails as p } from "./index23.js";
18
- import { useReceivableForm as m } from "./index31.js";
19
- import { useReceivablesTable as h } from "./index34.js";
20
- import { useCallback as g, useEffect as _, useMemo as v, useState as y } from "react";
5
+ import { useFilterPanel as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { getCounterpartName as t } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
7
+ import { useCounterpartQuery as n } from "../../../shared/counterpart-management/data-access/dist/index3.js";
8
+ import "../../../shared/counterpart-management/feature/dist/index.js";
9
+ import { isInvoicesDatePreset as r, resolveInvoicesDatePreset as i } from "./index32.js";
10
+ import { INVOICES_FILTER_FIELDS as a, InvoicesFilterChipKey as o, buildInvoicesDatePresetOptions as s, buildInvoicesFilterChips as c, buildInvoicesFilterQuery as l, buildInvoicesStatusOptions as u, clearInvoicesFilter as d, countActiveInvoiceFilters as f, emptyInvoicesFilterState as p } from "./index33.js";
11
+ import { mergeInvoicesFilterLabels as m } from "./index34.js";
12
+ import { useCallback as h, useMemo as g, useState as _ } from "react";
21
13
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js
22
- function b({ auditHistoryLabels: b, counterpartMessageLabels: x, defaultTab: S, embeddedBankName: C, enabledTabs: w, messageLabels: T, onReceivableCreated: E, onReceivableOpened: D, screenLabels: O }) {
23
- let k = e();
24
- _(() => {
25
- k(t.Mounted);
26
- }, [k]);
27
- let A = v(() => ({
28
- ...u,
29
- ...T
30
- }), [T]), j = O?.statusBadge, M = v(() => ({
31
- ...n,
32
- ...j
33
- }), [j]), N = v(() => a(w), [w]), [P, F] = y(() => s({
34
- defaultTab: S,
35
- enabledTabs: N
36
- })), [I, L] = y(), [R, z] = y(!1);
37
- _(() => {
38
- N.includes(P) || F(s({
39
- defaultTab: S,
40
- enabledTabs: N
41
- }));
42
- }, [
43
- P,
44
- S,
45
- N
46
- ]);
47
- let B = g((e, t) => {
48
- F(c(t)), L(e), z(!0), E?.(e, t);
49
- }, [E]), V = f({ messages: A }), H = V.open, U = g((e, t, n) => {
50
- F(c(t));
51
- let r = i(n);
52
- r.openDetails && (L(e), z(!0)), r.actionsModal && H({
53
- action: n.mode,
54
- receivableId: e,
55
- counterpartId: n.counterpartId,
56
- inlineItems: n.inlineItems,
57
- showEmailStep: r.actionsModal.showEmailStep
58
- }), E?.(e, t);
59
- }, [E, H]), W = h({
60
- activeTab: P,
61
- messages: A,
62
- statusLabels: M
63
- }), G = g((e) => {
64
- L(e), z(!0), D?.(e, "invoice");
65
- }, [D]), K = p({
66
- selectedReceivableId: I,
67
- enabled: R,
68
- messages: A,
69
- statusLabels: M,
70
- auditHistoryLabels: b,
71
- onOpenReceivable: G
72
- }), q = m({
73
- messages: A,
74
- counterpartMessageLabels: x,
75
- embeddedBankName: C,
76
- onCreated: U
77
- }), J = g(() => {
78
- let e = l(P);
79
- q.openCreate(e === "quote" ? "quote" : "invoice");
80
- }, [P, q.openCreate]), Y = d({
81
- selectedReceivable: K.receivable,
82
- selectedRecurrence: K.recurrence,
83
- messages: A,
84
- onCreated: B,
85
- onDeleted: (e) => {
86
- e === I && (L(void 0), z(!1));
87
- },
88
- onCompleteBeforeIssue: (e) => {
89
- q.openEdit(e, { highlightForIssue: !0 }), z(!1);
14
+ function v({ initialCounterpartId: v, search: y, onSearchChange: b, onFiltersChange: x, statusLabels: S, labels: C }) {
15
+ let w = g(() => m(C), [C]), [T] = _(v), [E, D] = _(() => p(T)), O = e(), { data: k } = n(E.customerId), A = k ? t(k) : "", j = h((e) => {
16
+ D((t) => ({
17
+ ...t,
18
+ ...e
19
+ })), x();
20
+ }, [x]), M = g(() => l(E), [E]), N = f(E, y), P = g(() => c({
21
+ state: E,
22
+ search: y,
23
+ counterpartName: A,
24
+ labels: w,
25
+ statusLabels: S
26
+ }), [
27
+ A,
28
+ w,
29
+ y,
30
+ E,
31
+ S
32
+ ]), F = g(() => u(S, w), [w, S]), I = g(() => s(w), [w]), L = h((e) => {
33
+ if (e === o.Search) {
34
+ b("");
35
+ return;
90
36
  }
91
- }), X = g((e) => {
92
- r() || (L(e.id), z(!0), D?.(e.id, e.type));
93
- }, [D]);
94
- return {
95
- activeTab: P,
96
- enabledTabs: N,
97
- setActiveTab: F,
98
- table: W,
99
- details: K,
100
- detailsOpen: R,
101
- closeDetails: g(() => {
102
- z(!1), L(void 0);
103
- }, []),
104
- form: q,
105
- openCreate: J,
106
- actions: Y,
107
- actionsModal: V,
108
- handleRowClick: X,
109
- handleActionClick: g((e, t) => {
110
- let n = W.getReceivableById(t.id);
111
- if (e === "edit") {
112
- if (n) {
113
- q.openEdit(n);
114
- return;
37
+ D((t) => d(t, e)), x();
38
+ }, [x, b]), R = h(() => {
39
+ D(p()), b(""), x();
40
+ }, [x, b]), z = h(() => {
41
+ D(p(T));
42
+ }, [T]), B = h((e) => j({ statuses: e === "all" ? [] : [e] }), [j]), V = h((e, t) => {
43
+ D((n) => ({
44
+ ...n,
45
+ dateRanges: {
46
+ ...n.dateRanges,
47
+ [e]: {
48
+ preset: void 0,
49
+ from: t.from,
50
+ to: t.to
115
51
  }
116
- L(t.id), z(!0);
117
- return;
118
52
  }
119
- L(t.id), Y.openAction(e, t, n ?? null);
120
- }, [
121
- Y,
122
- q.openEdit,
123
- W.getReceivableById
124
- ]),
125
- handleDetailsActionClick: g((e, t) => {
126
- if (e === "edit") {
127
- K.receivable && (q.openEdit(K.receivable), z(!1));
128
- return;
53
+ })), x();
54
+ }, [x]), H = h((e, t) => {
55
+ if (!r(t)) return;
56
+ let { from: n, to: a } = i(t);
57
+ D((r) => ({
58
+ ...r,
59
+ dateRanges: {
60
+ ...r.dateRanges,
61
+ [e]: {
62
+ preset: t,
63
+ from: n,
64
+ to: a
65
+ }
129
66
  }
130
- Y.openAction(e, {
131
- id: t.id,
132
- title: K.receivable ? o(K.receivable, A) : t.title,
133
- type: t.type
134
- }, K.receivable ?? null);
135
- }, [
136
- Y,
137
- K.receivable,
138
- q.openEdit,
139
- A
140
- ])
67
+ })), x();
68
+ }, [x]);
69
+ return {
70
+ filterBar: {
71
+ fields: a,
72
+ searchValue: y,
73
+ onSearchChange: b,
74
+ isPopoverOpen: O.isMenuOpen || !!O.activePanelId,
75
+ isMenuOpen: O.isMenuOpen,
76
+ activePanel: O.activePanelId,
77
+ onMenuToggle: O.toggleMenu,
78
+ onPopoverClose: () => {
79
+ O.closeMenu(), O.closePanel();
80
+ },
81
+ onFieldSelect: O.openPanel,
82
+ activeFilterCount: N,
83
+ chips: P,
84
+ showClearAll: N > 0,
85
+ onRemoveChip: L,
86
+ onClearAll: R,
87
+ dateRanges: E.dateRanges,
88
+ datePresets: I,
89
+ onDateRangeChange: V,
90
+ onDatePresetChange: H,
91
+ statusOptions: F,
92
+ selectedStatuses: E.statuses,
93
+ onStatusChange: (e) => j({ statuses: e }),
94
+ amountMode: E.amountMode,
95
+ onAmountModeChange: (e) => j({ amountMode: e }),
96
+ amountMin: E.amountMin,
97
+ amountMax: E.amountMax,
98
+ onAmountMinChange: (e) => j({ amountMin: e }),
99
+ onAmountMaxChange: (e) => j({ amountMax: e }),
100
+ customerName: E.customerName,
101
+ onCustomerNameChange: (e) => j({ customerName: e })
102
+ },
103
+ query: M,
104
+ isFiltering: N > 0,
105
+ cardStatus: E.statuses[0] ?? "all",
106
+ selectStatusCard: B,
107
+ reset: z
141
108
  };
142
109
  }
143
110
  //#endregion
144
- export { b as useReceivablesWidget };
111
+ export { v as useInvoicesFilter };
@@ -1,345 +1,44 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { Calendar as e, Skeleton as t } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { EmbeddedToaster as n } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
7
- import "../../../shared/ui/dist/index.js";
8
- import { useAnalyticsTrack as r } from "../../../shared/feature/dist/lib/analytics/hooks.js";
9
- import { WidgetProvider as i } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
10
- import "../../../shared/feature/dist/index.js";
11
- import { CounterpartFormSheet as a } from "../../../shared/counterpart-management/ui/dist/index9.js";
12
- import { CounterpartSelector as o } from "../../../shared/counterpart-management/feature/dist/lib/CounterpartSelector.js";
13
- import "../../../shared/counterpart-management/feature/dist/index.js";
14
- import { ReceivablesWidgetAnalyticsEvent as s, WIDGET_NAME as c } from "./index2.js";
15
- import { PAGE_SIZE_OPTIONS as l } from "./index4.js";
16
- import { ReceivableActionsModal as u } from "../../ui/dist/index5.js";
17
- import { ReceivableActionDialog as d } from "../../ui/dist/index10.js";
18
- import { ReceivableBankAccountSection as f } from "../../ui/dist/index11.js";
19
- import { ReceivableBillingSection as p } from "../../ui/dist/index16.js";
20
- import { ReceivableDetailsPanel as m } from "../../ui/dist/index30.js";
21
- import { ReceivableFormSheet as h } from "../../ui/dist/index34.js";
22
- import { ReceivablePaymentDialog as g } from "../../ui/dist/index35.js";
23
- import { ReceivableRecurrenceEmailDialog as _ } from "../../ui/dist/index40.js";
24
- import { ReceivableRecurrenceSection as v } from "../../ui/dist/index42.js";
25
- import { ReceivableRemindersSection as y } from "../../ui/dist/index44.js";
26
- import { ReceivableSendDialog as b } from "../../ui/dist/index45.js";
27
- import { ReceivablesScreen as x } from "../../ui/dist/index47.js";
28
- import "../../ui/dist/index.js";
29
- import { ReceivableAttachmentsSection as S } from "./index5.js";
30
- import { MeasureUnitsManagerContainer as C } from "../../../shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js";
31
- import { ProductSelector as w } from "../../../shared/product-catalog/feature/dist/lib/ProductSelector.js";
32
- import "../../../shared/product-catalog/feature/dist/index.js";
33
- import { useReceivablesWidget as T } from "./index35.js";
34
- import { useEffect as ee, useId as E, useState as D } from "react";
35
- import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
1
+ import { formatMoney as e, getStatusTone as t } from "./index13.js";
36
2
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index36.js
37
- function j({ auditHistoryLabels: i, counterpartFormLabels: c, counterpartMessageLabels: j, defaultTab: M, detailsLabels: N, embeddedBankName: P, enabledTabs: F, formLabels: I, measureUnitDeleteLabels: L, measureUnitsLabels: R, messageLabels: z, onReceivableCreated: B, onReceivableOpened: V, onTemplateSettingsClick: te, pageSizeOptions: H = l, paymentLabels: U, productMessageLabels: W, screenLabels: G, sendLabels: K, actionLabels: q, actionsModalLabels: J }) {
38
- let Y = r();
39
- ee(() => {
40
- Y(s.Mounted);
41
- }, [Y]);
42
- let X = T({
43
- auditHistoryLabels: i,
44
- counterpartMessageLabels: j,
45
- defaultTab: M,
46
- embeddedBankName: P,
47
- enabledTabs: F,
48
- messageLabels: z,
49
- onReceivableCreated: B,
50
- onReceivableOpened: V,
51
- screenLabels: G
52
- }), [Z, Q] = D(!1), ne = E(), $ = E(), re = E(), ie = E(), ae = E();
53
- return /* @__PURE__ */ A(O, { children: [
54
- /* @__PURE__ */ k(n, {}),
55
- /* @__PURE__ */ k(x, {
56
- rows: X.table.rows,
57
- activeTab: X.activeTab,
58
- enabledTabs: X.enabledTabs,
59
- onTabChange: X.setActiveTab,
60
- isLoading: X.table.isLoading,
61
- isError: X.table.isError,
62
- sorting: X.table.sorting,
63
- onSortingChange: X.table.onSortingChange,
64
- pageSize: X.table.pageSize,
65
- onPageSizeChange: X.table.onPageSizeChange,
66
- pageSizeOptions: H,
67
- hasNextPage: X.table.hasNextPage,
68
- hasPrevPage: X.table.hasPrevPage,
69
- onNextPage: X.table.onNextPage,
70
- onPrevPage: X.table.onPrevPage,
71
- searchValue: X.table.searchValue,
72
- onSearchChange: X.table.onSearchChange,
73
- statusFilter: X.table.statusFilter,
74
- statusOptions: X.table.statusOptions,
75
- onStatusFilterChange: X.table.onStatusFilterChange,
76
- statusCards: X.table.statusCards,
77
- onStatusCardSelect: X.table.onStatusFilterChange,
78
- isFiltering: X.table.isFiltering,
79
- onCreateClick: X.openCreate,
80
- onTemplateSettingsClick: te,
81
- onRowClick: X.handleRowClick,
82
- onActionClick: X.handleActionClick,
83
- onRetry: X.table.onRetry,
84
- labels: G
85
- }),
86
- /* @__PURE__ */ k(h, {
87
- open: X.form.open,
88
- onOpenChange: (e) => {
89
- e || X.form.close();
90
- },
91
- mode: X.form.mode,
92
- values: X.form.sheetValues,
93
- errors: X.form.errors,
94
- currencyOptions: X.form.currencyOptions,
95
- unitOptions: X.form.lineItemUnitOptions,
96
- currencySymbol: X.form.currencySymbol,
97
- lineItemControls: X.form.lineItemControls,
98
- autoFocusLineItemId: X.form.autoFocusLineItemId,
99
- lineItemsLoading: X.form.lineItemsLoading,
100
- inProgress: X.form.isSubmitting,
101
- customerSelector: /* @__PURE__ */ k(o, {
102
- mode: "customer",
103
- value: X.form.values.customerId || void 0,
104
- invalid: !!X.form.errors.customerId,
105
- onValueChange: (e) => X.form.updateValues({ customerId: e }),
106
- onCreateClick: X.form.openCounterpartCreate
107
- }),
108
- renderProductSelector: (e, t) => /* @__PURE__ */ k(w, {
109
- ...t,
110
- inputValue: e.name,
111
- selectedProductId: X.form.values.lineItems.find((t) => t.id === e.id)?.productId || void 0,
112
- currency: X.form.values.currency,
113
- maxLength: 100,
114
- onInputValueChange: (t) => X.form.updateLineItem(e.id, { name: t }),
115
- onProductSelect: (t) => X.form.selectProduct(e.id, t)
116
- }),
117
- onChange: X.form.updateValues,
118
- onLineItemChange: X.form.updateLineItem,
119
- onLineItemCommit: X.form.commitLineItem,
120
- onLineItemQuantityStep: X.form.stepLineItem,
121
- onTaxRateCommit: X.form.commitTaxRate,
122
- onDiscountFocus: X.form.focusDiscount,
123
- onDiscountCommit: X.form.commitDiscount,
124
- totals: X.form.totalsView,
125
- onManageUnits: () => Q(!0),
126
- onAddLineItem: X.form.addLineItem,
127
- onRemoveLineItem: X.form.removeLineItem,
128
- showDueDateField: X.form.showDueDateField,
129
- billingSection: X.form.showBillingSection && /* @__PURE__ */ k(p, {
130
- idPrefix: ne,
131
- paymentTerms: X.form.paymentTerms.view,
132
- paymentTermsError: X.form.errors.paymentTermsId,
133
- disabled: X.form.isSubmitting,
134
- onPaymentTermsChange: X.form.paymentTerms.select,
135
- onCustomDatePickerOpenChange: X.form.paymentTerms.changeCustomDatePickerOpen,
136
- customDateCalendar: /* @__PURE__ */ k(e, {
137
- mode: "single",
138
- captionLayout: "dropdown",
139
- ...X.form.paymentTerms.calendar,
140
- onSelect: X.form.paymentTerms.selectCustomDate
141
- }),
142
- recurrenceSection: X.form.showRecurrenceSection && (X.form.recurrenceLoading ? /* @__PURE__ */ k(t, { className: "ttw:h-9 ttw:w-full" }) : /* @__PURE__ */ k(v, {
143
- idPrefix: $,
144
- view: X.form.recurrence.view,
145
- disabled: X.form.isSubmitting,
146
- onFrequencyChange: X.form.recurrence.changeFrequency,
147
- onMonthDayChange: X.form.recurrence.changeMonthDay,
148
- onWeekdayChange: X.form.recurrence.changeWeekday,
149
- onStartDateChange: X.form.recurrence.changeStartDate,
150
- onEndModeChange: X.form.recurrence.changeEndMode,
151
- onEndDateChange: X.form.recurrence.changeEndDate,
152
- onMaxOccurrencesChange: X.form.recurrence.changeMaxOccurrences,
153
- onCreationModeChange: X.form.recurrence.changeCreationMode,
154
- onSetUpEmailClick: X.form.recurrence.setUpEmail,
155
- emailDialog: /* @__PURE__ */ k(_, {
156
- idPrefix: $,
157
- view: X.form.recurrence.emailView,
158
- onOpenChange: X.form.recurrence.changeEmailOpen,
159
- onChange: X.form.recurrence.changeEmail,
160
- onSave: X.form.recurrence.saveEmail,
161
- labels: I
162
- }),
163
- labels: I
164
- })),
165
- labels: I
166
- }),
167
- remindersSection: X.form.reminders.view && /* @__PURE__ */ k(y, {
168
- idPrefix: ie,
169
- view: X.form.reminders.view,
170
- onToggle: X.form.reminders.toggle,
171
- onPaymentReminderSelect: X.form.reminders.selectPaymentReminder,
172
- onOverdueReminderSelect: X.form.reminders.selectOverdueReminder,
173
- onBeforeDueInputChange: X.form.reminders.changeBeforeDueInput,
174
- onBeforeDueSave: X.form.reminders.saveBeforeDue,
175
- onOverdueTermChange: X.form.reminders.changeOverdueTerm,
176
- onOverdueAddTerm: X.form.reminders.addOverdueTerm,
177
- onOverdueClear: X.form.reminders.clearOverdueTerms,
178
- onOverdueSave: X.form.reminders.saveOverdue,
179
- labels: I
180
- }),
181
- bankAccountSection: /* @__PURE__ */ k(f, {
182
- idPrefix: re,
183
- view: X.form.bankAccount.view,
184
- error: X.form.errors.bankAccountId,
185
- disabled: X.form.isSubmitting,
186
- onAccountSelect: X.form.bankAccount.selectAccount,
187
- onAddAccountClick: X.form.bankAccount.openAddAccount,
188
- onFormChange: X.form.bankAccount.updateAccountForm,
189
- onFormSave: X.form.bankAccount.saveAccount,
190
- onFormCancel: X.form.bankAccount.cancelAddAccount,
191
- labels: I
192
- }),
193
- attachmentsSection: X.form.attachmentsView && /* @__PURE__ */ k(S, {
194
- view: X.form.attachmentsView,
195
- disabled: X.form.isSubmitting,
196
- onFilesSelect: X.form.selectAttachmentFiles,
197
- onIncludeInEmailChange: X.form.setAttachmentIncludeInEmail,
198
- onRemove: X.form.removeAttachment,
199
- labels: I
200
- }),
201
- cancelDisabled: X.form.isSubmitting || X.form.attachmentsUploading,
202
- draftButtonLabel: X.form.draftButtonLabel,
203
- draftDisabled: X.form.draftDisabled,
204
- primaryButtonLabel: X.form.primaryButtonLabel,
205
- primaryDisabled: X.form.primaryDisabled,
206
- scrollContainerRef: X.form.scrollContainerRef,
207
- onSubmit: X.form.submit,
208
- onDraftClick: X.form.selectDraftMode,
209
- onPrimaryClick: X.form.selectPrimaryMode,
210
- onCancel: X.form.close,
211
- labels: I
212
- }),
213
- /* @__PURE__ */ k(m, {
214
- open: X.detailsOpen,
215
- onOpenChange: (e) => {
216
- e || X.closeDetails();
217
- },
218
- details: X.details.detailsView,
219
- unsupported: X.details.unsupportedView,
220
- isLoading: X.details.isLoading,
221
- isError: X.details.isError,
222
- onActionClick: X.handleDetailsActionClick,
223
- onClose: X.closeDetails,
224
- openSections: X.details.openSections,
225
- onOpenSectionsChange: X.details.setOpenSections,
226
- disabledActions: X.actions.pendingActions,
227
- labels: N
228
- }),
229
- /* @__PURE__ */ k(b, {
230
- open: X.actions.sendOpen,
231
- onOpenChange: (e) => {
232
- e || X.actions.closeSend();
233
- },
234
- values: X.actions.sendValues,
235
- errors: X.actions.sendErrors,
236
- inProgress: X.actions.sendInProgress,
237
- onChange: (e) => X.actions.setSendValues((t) => ({
238
- ...t,
239
- ...e
240
- })),
241
- onSubmit: X.actions.submitSend,
242
- onCancel: X.actions.closeSend,
243
- labels: K
244
- }),
245
- /* @__PURE__ */ k(g, {
246
- open: X.actions.paymentOpen,
247
- onOpenChange: (e) => {
248
- e || X.actions.closePayment();
249
- },
250
- values: X.actions.paymentValues,
251
- errors: X.actions.paymentErrors,
252
- inProgress: X.actions.paymentInProgress,
253
- onChange: (e) => X.actions.setPaymentValues((t) => ({
254
- ...t,
255
- ...e
256
- })),
257
- onSubmit: X.actions.submitPayment,
258
- onCancel: X.actions.closePayment,
259
- labels: U
260
- }),
261
- X.actions.actionDialog && /* @__PURE__ */ k(d, {
262
- open: !!X.actions.actionTarget,
263
- onOpenChange: (e) => {
264
- e || X.actions.closeAction();
265
- },
266
- title: X.actions.actionDialog.title,
267
- description: X.actions.actionDialog.description,
268
- confirmLabel: X.actions.actionDialog.confirmLabel,
269
- cancelLabel: X.actions.actionDialog.cancelLabel,
270
- destructive: X.actions.actionDialog.destructive,
271
- error: X.actions.actionError,
272
- inProgress: X.actions.actionInProgress,
273
- onConfirm: X.actions.confirmAction,
274
- onCancel: X.actions.closeAction,
275
- labels: q
276
- }),
277
- /* @__PURE__ */ k(u, {
278
- idPrefix: ae,
279
- open: X.actionsModal.isOpen,
280
- view: X.actionsModal.view,
281
- onSkip: X.actionsModal.skip,
282
- onSubjectChange: X.actionsModal.changeSubject,
283
- onMessageChange: X.actionsModal.changeMessage,
284
- onSend: X.actionsModal.send,
285
- onToggleItem: X.actionsModal.toggleItem,
286
- onToggleAll: X.actionsModal.toggleAll,
287
- onAllSelectedChange: X.actionsModal.setAllSelected,
288
- onSaveItems: X.actionsModal.saveItems,
289
- labels: J
290
- }),
291
- /* @__PURE__ */ k(a, {
292
- open: X.form.counterpartView === "create",
293
- onOpenChange: (e) => {
294
- e || X.form.counterpartForm.close();
295
- },
296
- mode: "create",
297
- values: X.form.counterpartForm.values,
298
- errors: X.form.counterpartForm.errors,
299
- stateOptions: X.form.stateOptions,
300
- inProgress: X.form.counterpartForm.isSubmitting,
301
- onChange: (e) => X.form.counterpartForm.setValues((t) => ({
302
- ...t,
303
- ...e
304
- })),
305
- onAddressChange: (e) => X.form.counterpartForm.setValues((t) => ({
306
- ...t,
307
- address: {
308
- ...t.address,
309
- ...e
310
- }
311
- })),
312
- onSubmit: X.form.counterpartForm.submit,
313
- onCancel: X.form.counterpartForm.close,
314
- labels: c
315
- }),
316
- /* @__PURE__ */ k(C, {
317
- open: Z,
318
- onClose: () => Q(!1),
319
- managerLabels: R,
320
- deleteLabels: L,
321
- messageLabels: W
322
- })
323
- ] });
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;
324
16
  }
325
- function M({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: a, linkComponent: o, implementation: s, uiFramework: l, errorFallback: u, onError: d, analytics: f, disclosuresAcceptance: p, providerLabels: m, ...h }) {
326
- return /* @__PURE__ */ k(i, {
327
- widgetName: c,
328
- baseUrl: e,
329
- widgetToken: t,
330
- organizationId: n,
331
- configClient: r,
332
- gatewayRouting: a,
333
- linkComponent: o,
334
- implementation: s,
335
- uiFramework: l,
336
- errorFallback: u,
337
- onError: d,
338
- analytics: f,
339
- disclosuresAcceptance: p,
340
- providerLabels: m,
341
- children: /* @__PURE__ */ k(j, { ...h })
342
- });
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);
22
+ return {
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
+ }))
41
+ };
343
42
  }
344
43
  //#endregion
345
- export { M as ReceivablesWidget, M as default };
44
+ export { i as buildReceivableStatusCardsView };
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useReceivablesAnalyticsQuery as e } from "../../data-access/dist/index13.js";
6
+ import "../../data-access/dist/index.js";
7
+ import { buildReceivableStatusCardsView as t } from "./index36.js";
8
+ import { useMemo as n } from "react";
9
+ //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index37.js
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
+ });
32
+ }, [
33
+ u,
34
+ l,
35
+ r,
36
+ d,
37
+ a.notAvailable,
38
+ i,
39
+ o
40
+ ]);
41
+ }
42
+ //#endregion
43
+ export { r as useReceivableStatusCards };