@tesouro/embedded-components-react 0.5.85 → 0.5.86

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.
package/dist/index.d.ts CHANGED
@@ -1787,6 +1787,8 @@ interface BalancesWidgetLabels {
1787
1787
  viewAllAccounts: string;
1788
1788
  /** Shown when there are no balances to list */
1789
1789
  noBalancesFound: string;
1790
+ /** Screen-reader only: names the wait while balances load. */
1791
+ loadingLabel: string;
1790
1792
  /** Shown when the bank account request failed */
1791
1793
  loadErrorTitle: string;
1792
1794
  loadErrorDescription: string;
@@ -2759,6 +2761,8 @@ interface InsightsWidgetLabels {
2759
2761
  activeTab: string;
2760
2762
  dismissedTab: string;
2761
2763
  noInsightsFound: string;
2764
+ /** Screen-reader only: names the wait while insights load. */
2765
+ loadingLabel: string;
2762
2766
  loadErrorTitle: string;
2763
2767
  loadErrorDescription: string;
2764
2768
  loadErrorRetry: string;
@@ -15,6 +15,8 @@ interface BalancesWidgetLabels {
15
15
  viewAllAccounts: string;
16
16
  /** Shown when there are no balances to list */
17
17
  noBalancesFound: string;
18
+ /** Screen-reader only: names the wait while balances load. */
19
+ loadingLabel: string;
18
20
  /** Shown when the bank account request failed */
19
21
  loadErrorTitle: string;
20
22
  loadErrorDescription: string;
@@ -7,6 +7,8 @@ interface InsightsWidgetLabels {
7
7
  activeTab: string;
8
8
  dismissedTab: string;
9
9
  noInsightsFound: string;
10
+ /** Screen-reader only: names the wait while insights load. */
11
+ loadingLabel: string;
10
12
  loadErrorTitle: string;
11
13
  loadErrorDescription: string;
12
14
  loadErrorRetry: string;
@@ -1090,6 +1090,8 @@ interface BalancesWidgetLabels {
1090
1090
  viewAllAccounts: string;
1091
1091
  /** Shown when there are no balances to list */
1092
1092
  noBalancesFound: string;
1093
+ /** Screen-reader only: names the wait while balances load. */
1094
+ loadingLabel: string;
1093
1095
  /** Shown when the bank account request failed */
1094
1096
  loadErrorTitle: string;
1095
1097
  loadErrorDescription: string;
@@ -2016,6 +2018,8 @@ interface InsightsWidgetLabels {
2016
2018
  activeTab: string;
2017
2019
  dismissedTab: string;
2018
2020
  noInsightsFound: string;
2021
+ /** Screen-reader only: names the wait while insights load. */
2022
+ loadingLabel: string;
2019
2023
  loadErrorTitle: string;
2020
2024
  loadErrorDescription: string;
2021
2025
  loadErrorRetry: string;
@@ -9,12 +9,12 @@ import { formatMoneyExact as n } from "../../../shared/util/dist/lib/formatMoney
9
9
  import { normalizeAmountOutputCurrencyCode as r } from "../../../shared/util/dist/lib/normalizeAmountOutputCurrencyCode.js";
10
10
  import { parseAmountOutputMajorUnits as i } from "../../../shared/util/dist/lib/parseAmountOutputMajorUnits.js";
11
11
  import { sumAmountOutputsMajorUnits as a } from "../../../shared/util/dist/lib/sumAmountOutputsMajorUnits.js";
12
- import { useWidgetConfig as o } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
+ import { useRefetchWidget as o, useWidgetConfig as s, useWidgetError as c, useWidgetLoading as l } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
13
13
  import "../../../shared/feature/dist/index.js";
14
- import { createContext as s, useCallback as c, useContext as l, useMemo as u } from "react";
15
- import { jsx as d } from "react/jsx-runtime";
14
+ import { createContext as u, useCallback as d, useContext as f, useMemo as p } from "react";
15
+ import { jsx as m } from "react/jsx-runtime";
16
16
  //#region ../../libs/tesouro-embedded-components-react/balances-widget/feature/dist/index3.js
17
- var f = s({
17
+ var h = u({
18
18
  accountRows: [],
19
19
  isLoading: !1,
20
20
  isError: !1,
@@ -24,8 +24,14 @@ var f = s({
24
24
  shouldShowViewAllAccounts: !1,
25
25
  isRowClickable: !1,
26
26
  onViewAllAccountsClicked: () => {}
27
- }), p = () => l(f), m = ({ children: s, maxAccounts: l, onBalanceRowClick: p, onViewAllAccountsClick: m }) => {
28
- let { data: h, isLoading: g, isError: _, refetch: v, hasNextPage: y, isFetchingNextPage: b } = t(), { initResponse: x } = o(), S = h?.data ?? [], C = u(() => S.map((e) => {
27
+ }), g = () => f(h), _ = ({ children: u, maxAccounts: f, onBalanceRowClick: g, onViewAllAccountsClick: _ }) => {
28
+ let { data: v, isLoading: y, isError: b, refetch: x, hasNextPage: S, isFetchingNextPage: C } = t(), { initResponse: w } = s(), T = l(), E = c(), D = o(), O = T || y, k = !!E || b, A = d(() => {
29
+ D(), E || x();
30
+ }, [
31
+ D,
32
+ x,
33
+ E
34
+ ]), j = v?.data ?? [], M = p(() => j.map((e) => {
29
35
  let t = e.accountNumber.slice(-4), r = i(e.balance);
30
36
  return {
31
37
  accountId: e.id,
@@ -38,38 +44,38 @@ var f = s({
38
44
  })
39
45
  }
40
46
  };
41
- }), [S]), w = u(() => {
42
- let e = r(S[0]?.balance?.currencyCode), t = a(S.map((e) => e.balance), e);
47
+ }), [j]), N = p(() => {
48
+ let e = r(j[0]?.balance?.currencyCode), t = a(j.map((e) => e.balance), e);
43
49
  return n(t, {
44
50
  currencyCode: e,
45
51
  includeSpaceAfterCurrencySymbol: !1
46
52
  });
47
- }, [S]), T = u(() => S.length > 1 && (x?.scopes?.includes(e.BankAccountReadOrg) ?? !1) && !y && !b, [
48
- S.length,
49
- x?.scopes,
50
- y,
51
- b
52
- ]), E = u(() => S.length > l && !!m, [
53
- S.length,
54
- l,
55
- m
56
- ]), D = c(() => {
57
- m?.();
58
- }, [m]), O = u(() => !!p, [p]);
59
- return /* @__PURE__ */ d(f.Provider, {
53
+ }, [j]), P = p(() => j.length > 1 && (w?.scopes?.includes(e.BankAccountReadOrg) ?? !1) && !S && !C, [
54
+ j.length,
55
+ w?.scopes,
56
+ S,
57
+ C
58
+ ]), F = p(() => j.length > f && !!_, [
59
+ j.length,
60
+ f,
61
+ _
62
+ ]), I = d(() => {
63
+ _?.();
64
+ }, [_]), L = p(() => !!g, [g]);
65
+ return /* @__PURE__ */ m(h.Provider, {
60
66
  value: {
61
- accountRows: C,
62
- isLoading: g,
63
- isError: _,
64
- refetch: v,
65
- totalBalance: w,
66
- shouldTotalBalanceDisplay: T,
67
- shouldShowViewAllAccounts: E,
68
- isRowClickable: O,
69
- onViewAllAccountsClicked: D
67
+ accountRows: M,
68
+ isLoading: O,
69
+ isError: k,
70
+ refetch: A,
71
+ totalBalance: N,
72
+ shouldTotalBalanceDisplay: P,
73
+ shouldShowViewAllAccounts: F,
74
+ isRowClickable: L,
75
+ onViewAllAccountsClicked: I
70
76
  },
71
- children: s
77
+ children: u
72
78
  });
73
79
  };
74
80
  //#endregion
75
- export { m as BalancesWidgetContextProvider, p as useBalancesWidgetContext };
81
+ export { _ as BalancesWidgetContextProvider, g as useBalancesWidgetContext };
@@ -13,11 +13,18 @@ var p = ({ accountRows: p, children: m, isLoading: h, isError: g, onRetry: _, to
13
13
  return /* @__PURE__ */ l(s, {
14
14
  title: w.widgetTitle,
15
15
  showHeaderDivider: !1,
16
- children: h ? /* @__PURE__ */ l(t, {
17
- "data-testid": C?.skeleton,
18
- height: 80,
19
- width: "100%",
20
- className: "ttw:rounded-md"
16
+ children: h ? /* @__PURE__ */ u("div", {
17
+ role: "status",
18
+ "aria-busy": !0,
19
+ children: [/* @__PURE__ */ l("span", {
20
+ className: "ttw:sr-only",
21
+ children: w.loadingLabel
22
+ }), /* @__PURE__ */ l(t, {
23
+ "data-testid": C?.skeleton,
24
+ height: 80,
25
+ width: "100%",
26
+ className: "ttw:rounded-md"
27
+ })]
21
28
  }) : g ? /* @__PURE__ */ u("div", {
22
29
  className: "ttw:flex ttw:flex-col ttw:gap-3",
23
30
  "data-testid": C?.error,
@@ -6,6 +6,7 @@ var e = {
6
6
  totalAvailableBalanceInfoAriaLabel: "About total available balance",
7
7
  viewAllAccounts: "View all accounts",
8
8
  noBalancesFound: "No balances found",
9
+ loadingLabel: "Loading accounts",
9
10
  loadErrorTitle: "Could not load accounts",
10
11
  loadErrorDescription: "Something went wrong while loading balances. Please try again.",
11
12
  loadErrorRetry: "Retry"
@@ -18,49 +18,50 @@ function u(e, t) {
18
18
  return !0;
19
19
  }
20
20
  function d() {
21
- let { organizationId: d } = e(), f = r(d), { data: p, isLoading: m, isError: h, refetch: g } = t({
21
+ let { organizationId: d } = e(), f = r(d), { data: p, dataUpdatedAt: m, isLoading: h, isError: g, refetch: _ } = t({
22
22
  key: f,
23
23
  defaultWhenNotFound: []
24
- }), { mutateAsync: _ } = n(), v = o(() => f ? p?.value === void 0 ? h ? [] : null : l(p.value) : null, [
24
+ }), { mutateAsync: v } = n(), y = o(() => f ? p?.value === void 0 ? g ? [] : null : l(p.value) : null, [
25
25
  p,
26
- h,
26
+ m,
27
+ g,
27
28
  f
28
- ]), [y, b] = c([]), x = s([]), S = s(f);
29
- S.current = f;
30
- let C = s(f);
29
+ ]), [b, x] = c([]), S = s([]), C = s(f);
30
+ C.current = f;
31
+ let w = s(f);
31
32
  a(() => {
32
33
  if (!f) {
33
- b((e) => e.length === 0 ? e : []), x.current = [], C.current = f;
34
+ x((e) => e.length === 0 ? e : []), S.current = [], w.current = f;
34
35
  return;
35
36
  }
36
- C.current !== f && (C.current = f, b([]), x.current = []), !(m || v === null) && (b((e) => u(e, v) ? e : v), x.current = v);
37
+ w.current !== f && (w.current = f, x([]), S.current = []), !(h || y === null) && (x((e) => u(e, y) ? e : y), S.current = y);
37
38
  }, [
38
39
  f,
39
- m,
40
- v
40
+ h,
41
+ y
41
42
  ]);
42
- let w = h, T = i((e) => {
43
+ let T = g, E = i((e) => {
43
44
  if (!f) return;
44
- let t = y, n = t.includes(e) ? t : [...t, e], r = f;
45
- b(n), _({
45
+ let t = b, n = t.includes(e) ? t : [...t, e], r = f;
46
+ x(n), v({
46
47
  path: { key: r },
47
48
  body: { value: n }
48
49
  }).then(() => {
49
- r === S.current && (x.current = n);
50
+ r === C.current && (S.current = n);
50
51
  }).catch((e) => {
51
- r === S.current && (b(x.current), console.error("Error persisting dismissed insight id", e));
52
+ r === C.current && (x(S.current), console.error("Error persisting dismissed insight id", e));
52
53
  });
53
54
  }, [
54
- y,
55
+ b,
55
56
  f,
56
- _
57
+ v
57
58
  ]);
58
59
  return {
59
- dismissedIds: y,
60
- isLoading: f ? m : !1,
61
- isError: w,
62
- refetch: g,
63
- dismissInsight: T
60
+ dismissedIds: b,
61
+ isLoading: f ? h : !1,
62
+ isError: T,
63
+ refetch: _,
64
+ dismissInsight: E
64
65
  };
65
66
  }
66
67
  //#endregion
@@ -28,7 +28,7 @@ var g = u({
28
28
  let { initResponse: b } = r(), x = a(), S = i(), C = n(), w = p(() => c(b?.scopes), [b?.scopes]), { canReadBankAccounts: T, canReadExternalBankAccounts: E } = p(() => l(b?.scopes), [b?.scopes]), D = p(() => ({
29
29
  ...o,
30
30
  ...y
31
- }), [y]), [O, k] = m("active"), [A, j] = m(!1), M = _ !== void 0, N = M ? f : A, P = M ? _ : j, { dismissedIds: F, isLoading: I, refetch: L, dismissInsight: R } = s(), { data: z, isLoading: B, isError: V, refetch: H } = e({ enabled: T }), { data: U, isLoading: W, isError: G, refetch: K } = t({ enabled: E }), q = z?.data, J = U?.data, Y = x || B || W || I || !((!T || q !== void 0) && (!E || J !== void 0)) && !(V || G) && !S, X = !!S || V || G, Z = d(() => (C(), Promise.all([
31
+ }), [y]), [O, k] = m("active"), [A, j] = m(!1), M = _ !== void 0, N = M ? f : A, P = M ? _ : j, { dismissedIds: F, isLoading: I, refetch: L, dismissInsight: R } = s(), { data: z, isLoading: B, isError: V, refetch: H } = e({ enabled: T }), { data: U, isLoading: W, isError: G, refetch: K } = t({ enabled: E }), q = z?.data, J = U?.data, Y = x || B || W || I || !((!T || q !== void 0 || V) && (!E || J !== void 0 || G)) && !S, X = !!S || (T || E) && !(T && !V) && !(E && !G), Z = d(() => (C(), Promise.all([
32
32
  T ? H() : void 0,
33
33
  E ? K() : void 0,
34
34
  L()
@@ -16,11 +16,18 @@ var u = ({ hasInsights: u, children: d, activeFilter: f, setActiveFilter: p, isL
16
16
  "aria-hidden": !0
17
17
  }),
18
18
  title: y.widgetTitle,
19
- children: m ? /* @__PURE__ */ s(t, {
20
- "data-testid": v?.skeleton,
21
- height: 80,
22
- width: "100%",
23
- className: "ttw:rounded-md"
19
+ children: m ? /* @__PURE__ */ c("div", {
20
+ role: "status",
21
+ "aria-busy": !0,
22
+ children: [/* @__PURE__ */ s("span", {
23
+ className: "ttw:sr-only",
24
+ children: y.loadingLabel
25
+ }), /* @__PURE__ */ s(t, {
26
+ "data-testid": v?.skeleton,
27
+ height: 80,
28
+ width: "100%",
29
+ className: "ttw:rounded-md"
30
+ })]
24
31
  }) : h ? /* @__PURE__ */ c("div", {
25
32
  className: "ttw:flex ttw:flex-col ttw:gap-3",
26
33
  "data-testid": v?.error,
@@ -4,6 +4,7 @@ var e = {
4
4
  activeTab: "Active",
5
5
  dismissedTab: "Dismissed",
6
6
  noInsightsFound: "No insights found",
7
+ loadingLabel: "Loading insights",
7
8
  loadErrorTitle: "Could not load insights",
8
9
  loadErrorDescription: "Something went wrong while loading account data. Please try again.",
9
10
  loadErrorRetry: "Retry"
@@ -1,5 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.5.85", n = "68fc96a752f86bf0bf9db00b4c901ab85e52d0de", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.5.86", n = "50b771fdbebe37bf779dd804aeed2054543880e7", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.5.85",
3
+ "version": "0.5.86",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {