@tesouro/embedded-components-react 0.11.109 → 0.11.113

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 (28) hide show
  1. package/dist/experimental/BalanceHistoryWidget.d.ts +702 -0
  2. package/dist/experimental/BalanceHistoryWidget.js +5 -0
  3. package/dist/experimental/index.d.ts +93 -2
  4. package/dist/experimental/index.js +7 -4
  5. package/dist/index.css +9 -0
  6. package/dist/index.d.ts +84 -2
  7. package/dist/lib/WidgetSuite.d.ts +84 -2
  8. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/data-access/dist/index.js +3 -0
  9. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/data-access/dist/index2.js +89 -0
  10. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/data-access/dist/index3.js +19 -0
  11. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/index.js +4 -0
  12. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/BalanceHistoryWidgetFeature.js +159 -0
  13. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/labels.js +31 -0
  14. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/testIds.js +12 -0
  15. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/analytics/events.js +3 -0
  16. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/balanceHistoryView/balanceHistoryRange.js +39 -0
  17. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/balanceHistoryView/buildBalanceHistoryView.js +70 -0
  18. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index.js +3 -0
  19. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index2.js +93 -0
  20. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index3.js +19 -0
  21. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index4.js +176 -0
  22. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +43 -43
  23. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +115 -115
  24. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +199 -175
  25. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  26. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/WidgetFrame/WidgetFrame.js +2 -2
  27. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/DashboardSection.js +28 -19
  28. package/package.json +2 -1
@@ -0,0 +1,159 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { amountOutputToMajorUnits as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
6
+ import "../../../../../shared/util/dist/index.js";
7
+ import { OrganizationStatus as t, isOrganizationOnItsWay as n } from "../../../../../shared/data-access/dist/lib/organizationStatus.js";
8
+ import { useEmbedApi as r } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
9
+ import { Scope as i } from "../../../../../shared/data-access/dist/lib/scopes.js";
10
+ import "../../../../../shared/data-access/dist/index.js";
11
+ import { useAnalyticsTrack as a } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
12
+ import { WidgetProvider as o } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
13
+ import { useRefetchWidget as ee, useWidgetConfig as te, useWidgetError as ne, useWidgetInitStaleForToken as re, useWidgetLoading as ie } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
14
+ import { useLocalCalendarDay as ae } from "../../../../../shared/feature/dist/lib/calendar/useLocalCalendarDay.js";
15
+ import "../../../../../shared/feature/dist/index.js";
16
+ import { BALANCE_HISTORY_RANGES as oe, BalanceHistoryRange as s, balanceHistoryFetchDates as c, isBalanceHistoryRange as l, isRangeOldEnough as se, localIsoDate as u } from "../balanceHistoryView/balanceHistoryRange.js";
17
+ import { BalanceHistoryCard as ce } from "../../../../ui/dist/index4.js";
18
+ import "../../../../ui/dist/index.js";
19
+ import { BALANCE_HISTORY_WIDGET_LABELS_EN as d } from "./labels.js";
20
+ import { buildBalanceHistoryView as le, moneyFormatter as f, shortCalendarDate as ue } from "../balanceHistoryView/buildBalanceHistoryView.js";
21
+ import { BalanceHistoryWidgetAnalyticsEvent as de, WIDGET_NAME as p } from "../analytics/events.js";
22
+ import { balanceHistoryWidgetTestIds as fe } from "./testIds.js";
23
+ import { useBalanceHistoryQuery as pe } from "../../../../data-access/dist/index2.js";
24
+ import { useBalanceHistoryAccountsQuery as me } from "../../../../data-access/dist/index3.js";
25
+ import "../../../../data-access/dist/index.js";
26
+ import { useCallback as m, useEffect as h, useMemo as g, useState as _ } from "react";
27
+ import { jsx as v } from "react/jsx-runtime";
28
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/BalanceHistoryWidgetFeature.js
29
+ var y = "all", he = [];
30
+ function b({ labels: o, defaultRange: p = s.Days30, onTransferFromExternalClick: b, className: x, style: ge }) {
31
+ let S = g(() => ({
32
+ ...d,
33
+ ...o,
34
+ ranges: {
35
+ ...d.ranges,
36
+ ...o?.ranges
37
+ },
38
+ rangeSpans: {
39
+ ...d.rangeSpans,
40
+ ...o?.rangeSpans
41
+ },
42
+ rangeTooYoung: {
43
+ ...d.rangeTooYoung,
44
+ ...o?.rangeTooYoung
45
+ }
46
+ }), [o]), C = a();
47
+ h(() => {
48
+ C(de.Mounted);
49
+ }, [C]);
50
+ let [w, _e] = _(p), [T, ve] = _({}), { initResponse: E } = te(), ye = ie(), be = ne(), D = ee(), { organizationId: O, organizationStatus: k } = r(), A = k === t.Rotating, j = A && O == null, M = m((e) => ve((t) => ({
51
+ organizationId: j ? t.organizationId : O,
52
+ account: e || y
53
+ })), [O, j]), xe = n(k), N = E?.scopes?.includes(i.BankAccountReadOrg) ?? !1, P = re(), F = N && !P, I = me({ enabled: F }), L = I.accounts, R = L?.length === 1 ? L[0].id : y, z = T.organizationId === O || j ? T.account ?? R : R, B = z === y ? void 0 : z, V = L?.find(({ id: e }) => e === B), H = ae() ?? u(/* @__PURE__ */ new Date()), U = g(() => {
54
+ let e = (V ? [V.createdDateTime] : (L ?? []).map(({ createdDateTime: e }) => e)).map((e) => u(new Date(e)));
55
+ return e.length ? e.reduce((e, t) => e < t ? e : t) : void 0;
56
+ }, [V, L]), W = U ? c({
57
+ range: w,
58
+ openedDate: U,
59
+ today: H
60
+ }) : void 0, G = pe({
61
+ accountId: B,
62
+ startDate: W?.startDate ?? H,
63
+ endDate: W?.endDate ?? H,
64
+ enabled: F && !!W
65
+ }), K = W ? G.rows : U ? he : void 0, q = ye && !E || xe && !K || P && !K || I.isLoading || I.isResolving && !(A && L) || G.isLoading || G.isResolving && !(A && K), J = !!be && !K || I.isError || G.isError, Y = I.refetch, X = G.refetch, Se = m(() => {
66
+ D(), F && O && (Y(), X());
67
+ }, [
68
+ D,
69
+ Y,
70
+ X,
71
+ F,
72
+ O
73
+ ]), Ce = g(() => {
74
+ if (!L) return [];
75
+ let t = f(L[0]?.balance.currencyCode || "USD"), n = L.reduce((t, { balance: n }) => t + e(n), 0);
76
+ return [{
77
+ value: y,
78
+ label: S.allAccounts,
79
+ description: t(n)
80
+ }, ...L.map((t) => ({
81
+ value: t.id,
82
+ label: S.accountOption(t.nickname || t.nameOnAccount, t.accountNumber.slice(-4)),
83
+ description: f(t.balance.currencyCode || "USD")(e(t.balance))
84
+ }))];
85
+ }, [L, S]), Z = g(() => K && U ? le({
86
+ rows: K,
87
+ openedDate: U,
88
+ today: H,
89
+ range: w,
90
+ currencyCode: (V ?? L?.[0])?.balance.currencyCode || "USD",
91
+ holdsMoneyToday: (V ? [V] : L ?? []).some(({ balance: t }) => e(t) !== 0)
92
+ }) : void 0, [
93
+ K,
94
+ U,
95
+ H,
96
+ w,
97
+ V,
98
+ L
99
+ ]), we = oe.map((e) => {
100
+ let t = Z !== void 0 && !se(e, Z.historyDays), n = Z?.isUnfunded === !0;
101
+ return {
102
+ value: e,
103
+ label: S.ranges[e],
104
+ disabled: t || n,
105
+ disabledReason: t ? S.rangeTooYoung[e] : n ? S.rangeNeedsMoney : void 0
106
+ };
107
+ }), Q = b ? {
108
+ label: S.transferFromExternal,
109
+ onClick: b
110
+ } : void 0, Te = Z?.isUnfunded ? Z.range === void 0 ? {
111
+ title: S.addMoney,
112
+ action: Q
113
+ } : {
114
+ title: S.accountReady,
115
+ action: Q
116
+ } : void 0, $ = Z ? Z.isSinceOpened && U ? S.sinceOpened(ue(U)) : Z.range ? S.rangeSpans[Z.range] : "" : "", Ee = Z ? Z.isUnfunded ? $ : S.changeDescription($, Z.firstBalance, Z.lastBalance) : "";
117
+ return E && !N || k === t.None || !q && !J && L?.length === 0 ? null : /* @__PURE__ */ v(ce, {
118
+ accountOptions: Ce,
119
+ selectedAccount: z,
120
+ onAccountChange: M,
121
+ rangeOptions: we,
122
+ selectedRange: Z ? Z.isUnfunded ? "" : Z.range ?? "" : w,
123
+ onRangeChange: (e) => {
124
+ l(e) && _e(e);
125
+ },
126
+ change: Z?.change ?? "",
127
+ changeSpokenLabel: Z?.isChangeNegative ? S.negativeAmount(Z.changeMagnitude) : void 0,
128
+ changeDescription: Ee,
129
+ points: Z?.points ?? [],
130
+ xDomain: Z?.xDomain ?? [0, 0],
131
+ xTicks: Z?.xTicks ?? [],
132
+ yDomain: Z?.yDomain,
133
+ yTicks: Z?.yTicks,
134
+ yTickLabel: Z?.yTickLabel ?? String,
135
+ markFirstPoint: Z?.isUnfunded,
136
+ emptyNotice: Te,
137
+ isLoading: q,
138
+ isError: J,
139
+ onRetry: J ? Se : void 0,
140
+ labels: S,
141
+ testIds: fe,
142
+ className: x,
143
+ style: ge
144
+ });
145
+ }
146
+ function x({ labels: e, defaultRange: t, onTransferFromExternalClick: n, className: r, style: i, ...a }) {
147
+ return /* @__PURE__ */ v(o, {
148
+ ...a,
149
+ widgetName: p,
150
+ children: /* @__PURE__ */ v(b, {
151
+ labels: e,
152
+ defaultRange: t,
153
+ onTransferFromExternalClick: n,
154
+ className: r,
155
+ style: i
156
+ })
157
+ });
158
+ }
159
+ export { x as BalanceHistoryWidget, b as BalanceHistoryWidgetWithContext };
@@ -0,0 +1,31 @@
1
+ import { BALANCE_HISTORY_CARD_LABELS_EN as e } from "../../../../ui/dist/index3.js";
2
+ import "../../../../ui/dist/index.js";
3
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/labels.js
4
+ var t = {
5
+ ...e,
6
+ allAccounts: "All accounts",
7
+ accountOption: (e, t) => `${e} - ${t}`,
8
+ ranges: {
9
+ "30d": "30D",
10
+ "90d": "90D",
11
+ "1y": "1Y"
12
+ },
13
+ rangeSpans: {
14
+ "30d": "in the last 30 days",
15
+ "90d": "in the last 90 days",
16
+ "1y": "in the last year"
17
+ },
18
+ rangeTooYoung: {
19
+ "30d": "Available after 30 days of history",
20
+ "90d": "Available after 90 days of history",
21
+ "1y": "Available after 1 year of history"
22
+ },
23
+ rangeNeedsMoney: "Available once money is added",
24
+ sinceOpened: (e) => `since account opened ${e}`,
25
+ changeDescription: (e, t, n) => `${e} · ${t} → ${n}`,
26
+ accountReady: "This account is ready",
27
+ addMoney: "Add money to start your balance history",
28
+ transferFromExternal: "Transfer from an external account",
29
+ negativeAmount: (e) => `negative ${e}`
30
+ };
31
+ export { t as BALANCE_HISTORY_WIDGET_LABELS_EN };
@@ -0,0 +1,12 @@
1
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/testIds.js
2
+ var e = {
3
+ root: "balance-history-widget",
4
+ accountSelect: "balance-history-widget-account-select",
5
+ rangeTabs: "balance-history-widget-range-tabs",
6
+ change: "balance-history-widget-change",
7
+ chart: "balance-history-widget-chart",
8
+ skeleton: "balance-history-widget-skeleton",
9
+ error: "balance-history-widget-error",
10
+ emptyNotice: "balance-history-widget-empty-notice"
11
+ };
12
+ export { e as balanceHistoryWidgetTestIds };
@@ -0,0 +1,3 @@
1
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/analytics/events.js
2
+ var e = "balance_history_widget", t = { Mounted: `${e}.mounted` };
3
+ export { t as BalanceHistoryWidgetAnalyticsEvent, e as WIDGET_NAME };
@@ -0,0 +1,39 @@
1
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/balanceHistoryView/balanceHistoryRange.js
2
+ var e = {
3
+ Days30: "30d",
4
+ Days90: "90d",
5
+ Year: "1y"
6
+ }, t = [
7
+ e.Days30,
8
+ e.Days90,
9
+ e.Year
10
+ ], n = {
11
+ [e.Days30]: 30,
12
+ [e.Days90]: 90,
13
+ [e.Year]: 365
14
+ }, r = n[e.Year];
15
+ function i(e) {
16
+ return t.includes(e);
17
+ }
18
+ var a = 864e5, o = (e) => Date.parse(`${e}T00:00:00Z`);
19
+ function s(e, t) {
20
+ return new Date(o(e) + t * a).toISOString().slice(0, 10);
21
+ }
22
+ function c(e, t) {
23
+ return Math.round((o(t) - o(e)) / a);
24
+ }
25
+ function l(e) {
26
+ let t = String(e.getMonth() + 1).padStart(2, "0"), n = String(e.getDate()).padStart(2, "0");
27
+ return `${e.getFullYear()}-${t}-${n}`;
28
+ }
29
+ function u(t, r) {
30
+ return t === e.Days30 || r >= n[t];
31
+ }
32
+ function d({ range: e, openedDate: t, today: i }) {
33
+ let a = s(i, -1), o = c(t, i) < r ? t : s(a, 1 - n[e]);
34
+ return o <= a ? {
35
+ startDate: o,
36
+ endDate: a
37
+ } : void 0;
38
+ }
39
+ export { t as BALANCE_HISTORY_RANGES, e as BalanceHistoryRange, r as LONGEST_RANGE_DAYS, n as RANGE_DAYS, s as addDays, d as balanceHistoryFetchDates, c as daysBetween, i as isBalanceHistoryRange, u as isRangeOldEnough, l as localIsoDate };
@@ -0,0 +1,70 @@
1
+ import { amountOutputToMajorUnits as e, minorExponentForCurrency as t } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
2
+ import { formatCalendarDate as n } from "../../../../../shared/util/dist/lib/formatCalendarDate.js";
3
+ import { formatAccountingAmount as r } from "../../../../../shared/util/dist/lib/formatAccountingAmount.js";
4
+ import { formatMoneyExact as i } from "../../../../../shared/util/dist/lib/formatMoneyExact.js";
5
+ import "../../../../../shared/util/dist/index.js";
6
+ import { BalanceHistoryRange as a, LONGEST_RANGE_DAYS as o, RANGE_DAYS as s, addDays as c, daysBetween as l, isRangeOldEnough as u } from "./balanceHistoryRange.js";
7
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/balanceHistoryView/buildBalanceHistoryView.js
8
+ var d = 14, f = s[a.Days90];
9
+ function p(e, t) {
10
+ if (t < f) return Array.from({ length: Math.floor(t / d) + 1 }, (e, t) => t * d);
11
+ let n = [];
12
+ for (let r = 0; r <= t; r++) c(e, r).endsWith("-01") && n.push(r);
13
+ return n;
14
+ }
15
+ var m = [0, 1e3];
16
+ function h(e) {
17
+ let n = t(e);
18
+ return (t) => i(t, {
19
+ currencyCode: e,
20
+ includeSpaceAfterCurrencySymbol: !1,
21
+ minimumFractionDigits: n,
22
+ maximumFractionDigits: n
23
+ });
24
+ }
25
+ var g = (e) => n(e).replace(/, \d{4}$/, "");
26
+ function _({ rows: t, openedDate: i, today: d, range: f, currencyCode: _, holdsMoneyToday: v }) {
27
+ let y = c(d, -1), b = Math.max(0, l(i, d)), x = b < o && !v && t.every((t) => e(t.balance) === 0), S = x && b > s[a.Days30] ? void 0 : x || !u(f, b) ? a.Days30 : f, C, w;
28
+ S === void 0 ? (C = i, w = y) : b < s[S] ? (C = i, w = c(i, s[S] - 1)) : (C = c(y, 1 - s[S]), w = y);
29
+ let T = C <= i, E = t[0]?.balance.currencyCode || _, D = t.filter((e) => e.asOfDate >= C && e.asOfDate <= w), O = D[0]?.asOfDate === i && e(D[0].balance) === 0, k = T && !O ? [{
30
+ asOfDate: i,
31
+ balance: {
32
+ value: 0,
33
+ currencyCode: E
34
+ }
35
+ }, ...D] : D, A = h(E), j = k.map((t) => {
36
+ let r = e(t.balance);
37
+ return {
38
+ x: l(C, t.asOfDate),
39
+ tooltipTitle: n(t.asOfDate),
40
+ value: r,
41
+ valueLabel: A(r)
42
+ };
43
+ }), M = l(C, w), N = p(C, M).map((e) => ({
44
+ value: e,
45
+ label: g(c(C, e))
46
+ })), P = j[0]?.value ?? 0, F = j[j.length - 1]?.value ?? 0, I = F - P, L = r(I, E), R = I > 0 && L.magnitude !== r(0, E).text, z = new Intl.NumberFormat("en-US", {
47
+ style: "currency",
48
+ currency: E,
49
+ notation: "compact",
50
+ maximumFractionDigits: 1
51
+ }), B = j.every((e) => e.value === 0);
52
+ return {
53
+ range: S,
54
+ historyDays: b,
55
+ isUnfunded: x,
56
+ isSinceOpened: T,
57
+ points: j,
58
+ xDomain: [0, M],
59
+ xTicks: N,
60
+ yDomain: B ? m : void 0,
61
+ yTicks: B ? [...m] : void 0,
62
+ change: R ? `+${L.text}` : L.text,
63
+ isChangeNegative: L.isNegative,
64
+ changeMagnitude: L.magnitude,
65
+ firstBalance: A(P),
66
+ lastBalance: A(F),
67
+ yTickLabel: (e) => e < 0 ? `(${z.format(-e)})` : z.format(e)
68
+ };
69
+ }
70
+ export { _ as buildBalanceHistoryView, h as moneyFormatter, g as shortCalendarDate };
@@ -0,0 +1,3 @@
1
+ import { BALANCE_HISTORY_CARD_LABELS_EN as e } from "./index3.js";
2
+ import { BalanceHistoryCard as t } from "./index4.js";
3
+ export { e as BALANCE_HISTORY_CARD_LABELS_EN, t as BalanceHistoryCard };
@@ -0,0 +1,93 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import { Area as n, AreaChart as r, CartesianGrid as i, ResponsiveContainer as a, Tooltip as o, XAxis as s, YAxis as c } from "recharts";
3
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index2.js
4
+ function l({ points: l, seriesName: u, tooltipSeparator: d, xDomain: f, xTicks: p, yDomain: m, yTicks: h, yTickLabel: g, markFirstPoint: _ = !1 }) {
5
+ let v = l.length - 1, y = new Map(p.map((e) => [e.value, e.label]));
6
+ return /* @__PURE__ */ e(a, {
7
+ width: "100%",
8
+ height: "100%",
9
+ children: /* @__PURE__ */ t(r, {
10
+ data: l,
11
+ margin: {
12
+ top: 8,
13
+ right: 16,
14
+ bottom: 0,
15
+ left: 0
16
+ },
17
+ children: [
18
+ /* @__PURE__ */ e(i, {
19
+ vertical: !1,
20
+ stroke: "var(--ttw-border)"
21
+ }),
22
+ /* @__PURE__ */ e(s, {
23
+ dataKey: "x",
24
+ type: "number",
25
+ domain: f,
26
+ ticks: p.map((e) => e.value),
27
+ tickFormatter: (e) => y.get(e) ?? "",
28
+ interval: "preserveStartEnd",
29
+ stroke: "var(--ttw-border)",
30
+ tick: { fill: "var(--ttw-muted-foreground)" },
31
+ tickLine: !1,
32
+ tickMargin: 8,
33
+ className: "ttw:text-xs"
34
+ }),
35
+ /* @__PURE__ */ e(c, {
36
+ dataKey: "value",
37
+ stroke: "var(--ttw-border)",
38
+ tick: { fill: "var(--ttw-muted-foreground)" },
39
+ tickLine: !1,
40
+ axisLine: !1,
41
+ tickFormatter: g,
42
+ domain: m ?? ["auto", "auto"],
43
+ ticks: h,
44
+ tickCount: 3,
45
+ width: "auto",
46
+ className: "ttw:text-xs"
47
+ }),
48
+ /* @__PURE__ */ e(o, {
49
+ isAnimationActive: !1,
50
+ cursor: { stroke: "var(--ttw-border)" },
51
+ content: ({ active: n, payload: r }) => {
52
+ let i = r?.[0]?.payload;
53
+ return !n || !i ? null : /* @__PURE__ */ t("div", {
54
+ className: "ttw:flex ttw:flex-col ttw:gap-1 ttw:rounded-md ttw:border ttw:border-border ttw:bg-popover ttw:px-3 ttw:py-2 ttw:text-xs ttw:text-popover-foreground ttw:shadow-md",
55
+ children: [/* @__PURE__ */ e("span", {
56
+ className: "ttw:font-medium",
57
+ children: i.tooltipTitle
58
+ }), /* @__PURE__ */ t("span", { children: [
59
+ u,
60
+ d,
61
+ /* @__PURE__ */ e("span", {
62
+ className: "ttw:tabular-nums",
63
+ children: i.valueLabel
64
+ })
65
+ ] })]
66
+ });
67
+ }
68
+ }),
69
+ /* @__PURE__ */ e(n, {
70
+ type: "monotone",
71
+ dataKey: "value",
72
+ name: u,
73
+ stroke: "var(--ttw-primary)",
74
+ strokeWidth: 2,
75
+ fill: "var(--ttw-primary)",
76
+ fillOpacity: .08,
77
+ isAnimationActive: !1,
78
+ dot: (t) => (t.index === v || _ && t.index === 0) && t.cx != null && t.cy != null ? /* @__PURE__ */ e("circle", {
79
+ cx: t.cx,
80
+ cy: t.cy,
81
+ r: 4,
82
+ fill: "var(--ttw-primary)"
83
+ }, t.index) : /* @__PURE__ */ e("g", {}, t.index),
84
+ activeDot: {
85
+ r: 4,
86
+ fill: "var(--ttw-primary)"
87
+ }
88
+ })
89
+ ]
90
+ })
91
+ });
92
+ }
93
+ export { l as BalanceHistoryChart };
@@ -0,0 +1,19 @@
1
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index3.js
2
+ var e = {
3
+ title: "Balance history",
4
+ accountSelect: "Account",
5
+ accountSearchPlaceholder: "Search accounts",
6
+ accountSearchEmpty: "No matching accounts",
7
+ accountSearchClear: "Show all accounts",
8
+ rangeTabs: "Time range",
9
+ chart: "Balance over time",
10
+ seriesName: "Balance",
11
+ tooltipSeparator: ": ",
12
+ dataTable: "Balance by day",
13
+ dateColumn: "Date",
14
+ loading: "Loading balance history",
15
+ errorTitle: "Couldn’t load balance history",
16
+ errorDescription: "Check your connection and try again.",
17
+ retry: "Try again"
18
+ };
19
+ export { e as BALANCE_HISTORY_CARD_LABELS_EN };
@@ -0,0 +1,176 @@
1
+ import { Button as e, Combobox as t, DisplayAmount as n, Select as r, SelectContent as i, SelectItem as a, SelectTrigger as o, SelectValue as s, Skeleton as c, Tabs as l, TabsList as u, TabsTrigger as d } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { WidgetFrame as f } from "../../../shared/ui/dist/lib/WidgetFrame/WidgetFrame.js";
3
+ import { StatePanel as p } from "../../../shared/ui/dist/lib/StatePanel/StatePanel.js";
4
+ import { ErrorState as m } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
5
+ import { LoadingRegion as h } from "../../../shared/ui/dist/lib/LoadingRegion/LoadingRegion.js";
6
+ import "../../../shared/ui/dist/index.js";
7
+ import { BALANCE_HISTORY_CARD_LABELS_EN as g } from "./index3.js";
8
+ import { BalanceHistoryChart as _ } from "./index2.js";
9
+ import { useId as v } from "react";
10
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
11
+ import { ChartLineIcon as S } from "lucide-react";
12
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index4.js
13
+ var C = "ttw:h-56", ee = 10;
14
+ function w({ accountOptions: w, selectedAccount: T, onAccountChange: E, rangeOptions: D, selectedRange: O, onRangeChange: k, change: A, changeSpokenLabel: j, changeDescription: M, points: N, xDomain: P, xTicks: F, yDomain: I, yTicks: L, yTickLabel: R, markFirstPoint: z, emptyNotice: B, isLoading: V = !1, isError: H = !1, onRetry: U, labels: W, testIds: G, className: K, style: q }) {
15
+ let J = {
16
+ ...g,
17
+ ...W
18
+ }, Y = v(), X = v(), Z = v(), Q = w.length > 0 && !H ? w.length > ee ? /* @__PURE__ */ x("div", {
19
+ className: "ttw:w-64",
20
+ children: [/* @__PURE__ */ b("label", {
21
+ htmlFor: Y,
22
+ className: "ttw:sr-only",
23
+ children: J.accountSelect
24
+ }), /* @__PURE__ */ b(t, {
25
+ inputId: Y,
26
+ items: w,
27
+ value: T,
28
+ onValueChange: (e) => E(String(e)),
29
+ labels: {
30
+ placeholder: J.accountSearchPlaceholder,
31
+ emptyMessage: J.accountSearchEmpty,
32
+ clearAriaLabel: J.accountSearchClear
33
+ },
34
+ "data-testid": G?.accountSelect
35
+ })]
36
+ }) : /* @__PURE__ */ x(r, {
37
+ value: T,
38
+ onValueChange: E,
39
+ children: [/* @__PURE__ */ b(o, {
40
+ size: "sm",
41
+ "aria-label": J.accountSelect,
42
+ "data-testid": G?.accountSelect,
43
+ children: /* @__PURE__ */ b(s, {})
44
+ }), /* @__PURE__ */ b(i, {
45
+ position: "popper",
46
+ align: "end",
47
+ children: w.map((e) => /* @__PURE__ */ b(a, {
48
+ value: e.value,
49
+ description: e.description,
50
+ children: e.label
51
+ }, e.value))
52
+ })]
53
+ }) : null, $ = H ? null : /* @__PURE__ */ b(l, {
54
+ value: O,
55
+ onValueChange: k,
56
+ children: /* @__PURE__ */ b(u, {
57
+ variant: "pills",
58
+ "aria-label": J.rangeTabs,
59
+ "data-testid": G?.rangeTabs,
60
+ children: D.map((e) => {
61
+ let t = `${X}-${e.value}`, n = e.disabled && e.disabledReason;
62
+ return /* @__PURE__ */ x(d, {
63
+ value: e.value,
64
+ disabled: e.disabled,
65
+ "aria-describedby": n ? t : void 0,
66
+ children: [e.label, n ? /* @__PURE__ */ b("span", {
67
+ id: t,
68
+ className: "ttw:sr-only",
69
+ children: e.disabledReason
70
+ }) : null]
71
+ }, e.value);
72
+ })
73
+ })
74
+ });
75
+ return /* @__PURE__ */ b(f, {
76
+ title: J.title,
77
+ action: Q || $ ? /* @__PURE__ */ x(y, { children: [Q, $] }) : null,
78
+ className: K,
79
+ style: q,
80
+ "data-testid": G?.root,
81
+ children: H ? /* @__PURE__ */ b(m, {
82
+ title: J.errorTitle,
83
+ description: J.errorDescription,
84
+ retryLabel: J.retry,
85
+ onRetry: U,
86
+ testId: G?.error
87
+ }) : /* @__PURE__ */ b(h, {
88
+ isLoading: V,
89
+ loadingLabel: J.loading,
90
+ className: "ttw:flex ttw:flex-col ttw:gap-4",
91
+ children: V ? /* @__PURE__ */ x("div", {
92
+ className: "ttw:flex ttw:flex-col ttw:gap-4",
93
+ "data-testid": G?.skeleton,
94
+ children: [/* @__PURE__ */ x("div", {
95
+ className: "ttw:flex ttw:flex-wrap ttw:items-end ttw:gap-3",
96
+ children: [/* @__PURE__ */ b(c, { className: "ttw:h-9 ttw:w-40" }), /* @__PURE__ */ b(c, { className: "ttw:h-4 ttw:w-64" })]
97
+ }), /* @__PURE__ */ b(c, { className: `${C} ttw:w-full` })]
98
+ }) : /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ x("div", {
99
+ id: Z,
100
+ className: "ttw:flex ttw:min-w-0 ttw:flex-wrap ttw:items-baseline ttw:gap-x-3 ttw:gap-y-1",
101
+ "data-testid": G?.change,
102
+ children: [
103
+ /* @__PURE__ */ b(n, {
104
+ "aria-hidden": j ? !0 : void 0,
105
+ children: A
106
+ }),
107
+ j ? /* @__PURE__ */ b("span", {
108
+ className: "ttw:sr-only",
109
+ children: j
110
+ }) : null,
111
+ /* @__PURE__ */ b("p", {
112
+ className: "ttw:text-sm ttw:text-muted-foreground",
113
+ children: M
114
+ })
115
+ ]
116
+ }), /* @__PURE__ */ x("div", {
117
+ className: `ttw:relative ${C} ttw:w-full`,
118
+ children: [
119
+ /* @__PURE__ */ b("div", {
120
+ role: "img",
121
+ "aria-label": J.chart,
122
+ "aria-describedby": Z,
123
+ className: "ttw:size-full",
124
+ "data-testid": G?.chart,
125
+ children: /* @__PURE__ */ b(_, {
126
+ points: N,
127
+ seriesName: J.seriesName,
128
+ tooltipSeparator: J.tooltipSeparator,
129
+ xDomain: P,
130
+ xTicks: F,
131
+ yDomain: I,
132
+ yTicks: L,
133
+ yTickLabel: R,
134
+ markFirstPoint: z
135
+ })
136
+ }),
137
+ /* @__PURE__ */ x("table", {
138
+ className: "ttw:sr-only",
139
+ children: [
140
+ /* @__PURE__ */ b("caption", { children: J.dataTable }),
141
+ /* @__PURE__ */ b("thead", { children: /* @__PURE__ */ x("tr", { children: [/* @__PURE__ */ b("th", {
142
+ scope: "col",
143
+ children: J.dateColumn
144
+ }), /* @__PURE__ */ b("th", {
145
+ scope: "col",
146
+ children: J.seriesName
147
+ })] }) }),
148
+ /* @__PURE__ */ b("tbody", { children: N.map((e, t) => /* @__PURE__ */ x("tr", { children: [/* @__PURE__ */ b("th", {
149
+ scope: "row",
150
+ children: e.tooltipTitle
151
+ }), /* @__PURE__ */ b("td", { children: e.valueLabel })] }, t)) })
152
+ ]
153
+ }),
154
+ B ? /* @__PURE__ */ b("div", {
155
+ className: "ttw:absolute ttw:inset-0 ttw:flex ttw:items-center ttw:justify-center ttw:pb-6 ttw:pl-14",
156
+ children: /* @__PURE__ */ b(p, {
157
+ kind: "empty",
158
+ icon: /* @__PURE__ */ b(S, {}),
159
+ title: B.title,
160
+ description: B.description,
161
+ action: B.action ? /* @__PURE__ */ b(e, {
162
+ variant: "link",
163
+ size: "sm",
164
+ onClick: B.action.onClick,
165
+ children: B.action.label
166
+ }) : void 0,
167
+ className: "ttw:rounded-lg ttw:bg-card ttw:py-4",
168
+ testId: G?.emptyNotice
169
+ })
170
+ }) : null
171
+ ]
172
+ })] })
173
+ })
174
+ });
175
+ }
176
+ export { w as BalanceHistoryCard };