@tesouro/embedded-components-react 0.5.84 → 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.
Files changed (18) hide show
  1. package/dist/index.d.ts +5 -1
  2. package/dist/lib/BalancesWidget.d.ts +2 -0
  3. package/dist/lib/InsightsWidget.d.ts +2 -0
  4. package/dist/lib/InvoicingWidget.d.ts +1 -1
  5. package/dist/lib/WidgetSuite.d.ts +4 -0
  6. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index3.js +38 -32
  7. package/dist/libs/tesouro-embedded-components-react/balances-widget/ui/dist/lib/BalancesWidget/BalancesWidget.js +12 -5
  8. package/dist/libs/tesouro-embedded-components-react/balances-widget/ui/dist/lib/BalancesWidget/labels.js +1 -0
  9. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index10.js +7 -19
  10. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index6.js +68 -77
  11. package/dist/libs/tesouro-embedded-components-react/expense-requirements-widget/feature/dist/lib/ExpenseRequirementsWidget.js +4 -13
  12. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index5.js +23 -22
  13. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index8.js +1 -1
  14. package/dist/libs/tesouro-embedded-components-react/insights-widget/ui/dist/lib/InsightsWidget/InsightsWidget.js +12 -5
  15. package/dist/libs/tesouro-embedded-components-react/insights-widget/ui/dist/lib/InsightsWidget/labels.js +1 -0
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index3.js +3 -2
  17. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  18. package/package.json +1 -1
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;
@@ -4232,7 +4236,7 @@ declare function ExpenseManagementWidget({ baseUrl, widgetToken, organizationId,
4232
4236
  type ReceivablesWidgetMoniteProps = MoniteRegionProviderProps & Omit<ReceivablesProps, 'pageTitleComponent' | 'initialView' | 'initialCounterpartId'> & {
4233
4237
  pageTitleComponent?: ReceivablesProps['pageTitleComponent'];
4234
4238
  };
4235
- declare function ReceivablesWidgetMonite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, errorFallback, onError, finopsThemeColors, analytics, disclosuresAcceptance, providerLabels, pageTitleComponent, uiFramework, ...receivablesProps }: ReceivablesWidgetMoniteProps): React.JSX.Element;
4239
+ declare function ReceivablesWidgetMonite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, errorFallback, onError, finopsThemeColors, analytics, disclosuresAcceptance, providerLabels, pageTitleComponent, uiFramework, implementation, ...receivablesProps }: ReceivablesWidgetMoniteProps): React.JSX.Element;
4236
4240
 
4237
4241
  interface ProductFormSheetLabels {
4238
4242
  createTitle: 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;
@@ -662,7 +662,7 @@ type MoniteRegionProviderProps = WidgetProviderProps & MoniteWrapperProps;
662
662
  type ReceivablesWidgetMoniteProps = MoniteRegionProviderProps & Omit<ReceivablesProps, 'pageTitleComponent' | 'initialView' | 'initialCounterpartId'> & {
663
663
  pageTitleComponent?: ReceivablesProps['pageTitleComponent'];
664
664
  };
665
- declare function ReceivablesWidgetMonite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, errorFallback, onError, finopsThemeColors, analytics, disclosuresAcceptance, providerLabels, pageTitleComponent, uiFramework, ...receivablesProps }: ReceivablesWidgetMoniteProps): React.JSX.Element;
665
+ declare function ReceivablesWidgetMonite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, errorFallback, onError, finopsThemeColors, analytics, disclosuresAcceptance, providerLabels, pageTitleComponent, uiFramework, implementation, ...receivablesProps }: ReceivablesWidgetMoniteProps): React.JSX.Element;
666
666
 
667
667
  export { ReceivablesWidgetMonite as InvoicingWidget };
668
668
  export type { ReceivablesWidgetMoniteProps as InvoicingWidgetProps };
@@ -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"
@@ -46,28 +46,16 @@ function m({ isOpen: e, onClose: t, ...n }) {
46
46
  ...n
47
47
  }) : null;
48
48
  }
49
- function h({ baseUrl: e, widgetToken: t, organizationId: r, configClient: i, gatewayRouting: a, linkComponent: s, implementation: c, uiFramework: l, errorFallback: u, onError: f, analytics: p, disclosuresAcceptance: h, providerLabels: g, isOpen: _, preSelectedReceiptIds: v, onClose: y, targetTransactionId: b, onSingleTransactionUpdate: x }) {
49
+ function h({ isOpen: e, preSelectedReceiptIds: t, onClose: r, targetTransactionId: i, onSingleTransactionUpdate: a, ...s }) {
50
50
  return /* @__PURE__ */ d(n, {
51
+ ...s,
51
52
  widgetName: o,
52
- baseUrl: e,
53
- widgetToken: t,
54
- organizationId: r,
55
- configClient: i,
56
- gatewayRouting: a,
57
- linkComponent: s,
58
- implementation: c,
59
- uiFramework: l,
60
- errorFallback: u,
61
- onError: f,
62
- analytics: p,
63
- disclosuresAcceptance: h,
64
- providerLabels: g,
65
53
  children: /* @__PURE__ */ d(m, {
66
- isOpen: _,
67
- preSelectedReceiptIds: v,
68
- onClose: y,
69
- targetTransactionId: b,
70
- onSingleTransactionUpdate: x
54
+ isOpen: e,
55
+ preSelectedReceiptIds: t,
56
+ onClose: r,
57
+ targetTransactionId: i,
58
+ onSingleTransactionUpdate: a
71
59
  })
72
60
  });
73
61
  }
@@ -17,31 +17,31 @@ import { ApproverOptionLabels as l, PermissionErrorLabels as u, ValidationErrorL
17
17
  import { ExpenseApprovalPoliciesAnalyticsEvent as f, WIDGET_NAME as p } from "./index2.js";
18
18
  import { AmountConditionType as m, ApprovalOutcomeType as h } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/types.js";
19
19
  import { ApprovalRuleToastLabels as g } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/labels.js";
20
- import { ExpenseApprovalsPage as ee } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ExpenseApprovalsPage.js";
20
+ import { ExpenseApprovalsPage as _ } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ExpenseApprovalsPage.js";
21
21
  import "../../ui/dist/index.js";
22
- import { useApprovalPolicies as _ } from "./index3.js";
23
- import { expenseApprovalPoliciesTestIds as v } from "./index5.js";
24
- import { useEffect as y, useMemo as b, useState as x } from "react";
25
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
22
+ import { useApprovalPolicies as v } from "./index3.js";
23
+ import { expenseApprovalPoliciesTestIds as y } from "./index5.js";
24
+ import { useEffect as b, useMemo as x, useState as S } from "react";
25
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
26
26
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index6.js
27
- var T = {
27
+ var E = {
28
28
  minAmount: "",
29
29
  maxAmount: "",
30
30
  outcome: h.AutoApprove,
31
31
  approvers: []
32
32
  };
33
- function E(e, t) {
33
+ function D(e, t) {
34
34
  let n = (e ?? "").trim().toLowerCase();
35
35
  return n === t || n === `embedded:${t}`;
36
36
  }
37
- function D(e, t) {
37
+ function O(e, t) {
38
38
  return (e ?? "").toLowerCase().split(":").map((e) => e.trim()).filter(Boolean).some((e) => e === t);
39
39
  }
40
- function O(e) {
41
- return E(e, "cfo") || E(e, "finance_admin") || E(e, "finance-admin");
42
- }
43
40
  function k(e) {
44
- let t = e.find((e) => e.isSystemRole === !0 && E(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && O(e.key)), r = e.filter((e) => e.isSystemRole === !0 && e !== t && e !== n && !D(e.key, "employee") && !D(e.key, "bookkeeper")).map((e) => ({
41
+ return D(e, "cfo") || D(e, "finance_admin") || D(e, "finance-admin");
42
+ }
43
+ function A(e) {
44
+ let t = e.find((e) => e.isSystemRole === !0 && D(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && k(e.key)), r = e.filter((e) => e.isSystemRole === !0 && e !== t && e !== n && !O(e.key, "employee") && !O(e.key, "bookkeeper")).map((e) => ({
45
45
  id: e.id,
46
46
  label: e.name
47
47
  })), i = e.filter((e) => !e.isSystemRole && e.status?.toLowerCase() === "active").map((e) => ({
@@ -68,16 +68,16 @@ function k(e) {
68
68
  ...i
69
69
  ];
70
70
  }
71
- function A(e) {
71
+ function j(e) {
72
72
  let t = e.minAmount.trim() !== "", n = e.maxAmount.trim() !== "";
73
73
  return t && n ? m.InRange : t ? m.GreaterThanOrEqual : n ? m.LessThan : m.All;
74
74
  }
75
- function j(e) {
75
+ function M(e) {
76
76
  return [e.conditionType === m.LessThan || e.conditionType === m.All ? 0 : e.minAmount ?? 0, e.conditionType === m.GreaterThanOrEqual || e.conditionType === m.All ? Infinity : e.maxAmount ?? 0];
77
77
  }
78
- function te(e) {
78
+ function N(e) {
79
79
  if (e.length === 0) return !1;
80
- let t = e.map(j).sort((e, t) => e[0] - t[0]);
80
+ let t = e.map(M).sort((e, t) => e[0] - t[0]);
81
81
  if (t[0][0] > 0) return !1;
82
82
  let n = 0;
83
83
  for (let [e, r] of t) {
@@ -86,9 +86,9 @@ function te(e) {
86
86
  }
87
87
  return n === Infinity;
88
88
  }
89
- function M(e) {
89
+ function P(e) {
90
90
  if (e.length === 0) return [];
91
- let t = e.map(j).sort((e, t) => e[0] - t[0]), n = [], r = 0;
91
+ let t = e.map(M).sort((e, t) => e[0] - t[0]), n = [], r = 0;
92
92
  for (let [e, i] of t) e > r && n.push({
93
93
  from: r,
94
94
  to: e
@@ -98,23 +98,23 @@ function M(e) {
98
98
  to: null
99
99
  }), n;
100
100
  }
101
- function N(e) {
102
- let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = A(e);
101
+ function F(e) {
102
+ let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = j(e);
103
103
  return [r === m.LessThan || r === m.All ? 0 : t, r === m.GreaterThanOrEqual || r === m.All ? Infinity : n];
104
104
  }
105
- function P(e, t, n) {
106
- let [r, i] = N(e);
105
+ function I(e, t, n) {
106
+ let [r, i] = F(e);
107
107
  return t.filter((e) => e.id !== n).some((e) => {
108
- let [t, n] = j(e);
108
+ let [t, n] = M(e);
109
109
  return r < n && t < i;
110
110
  });
111
111
  }
112
- function F(e, t, n) {
112
+ function L(e, t, n) {
113
113
  let r = {}, i = e.minAmount.trim() !== "", a = e.maxAmount.trim() !== "", o = Number(e.minAmount.trim()), s = Number(e.maxAmount.trim());
114
- return i && (!Number.isFinite(o) || o < 0) && (r.minAmount = d.InvalidMinAmount), a && (!Number.isFinite(s) || s <= 0) && (r.maxAmount = d.InvalidMaxAmount), i && a && !r.minAmount && !r.maxAmount && o >= s && (r.maxAmount = d.MaxLessThanOrEqualToMin), e.outcome === h.RequireApproval && e.approvers.length === 0 && (r.approvers = d.ApproversRequired), !r.minAmount && !r.maxAmount && P(e, t, n) && (a ? r.maxAmount = d.ConflictsWithAnotherRule : r.minAmount = d.ConflictsWithAnotherRule), r;
114
+ return i && (!Number.isFinite(o) || o < 0) && (r.minAmount = d.InvalidMinAmount), a && (!Number.isFinite(s) || s <= 0) && (r.maxAmount = d.InvalidMaxAmount), i && a && !r.minAmount && !r.maxAmount && o >= s && (r.maxAmount = d.MaxLessThanOrEqualToMin), e.outcome === h.RequireApproval && e.approvers.length === 0 && (r.approvers = d.ApproversRequired), !r.minAmount && !r.maxAmount && I(e, t, n) && (a ? r.maxAmount = d.ConflictsWithAnotherRule : r.minAmount = d.ConflictsWithAnotherRule), r;
115
115
  }
116
- function I(e, t) {
117
- let n = A(t);
116
+ function R(e, t) {
117
+ let n = j(t);
118
118
  return {
119
119
  id: e,
120
120
  conditionType: n,
@@ -124,7 +124,7 @@ function I(e, t) {
124
124
  approvers: t.outcome === h.RequireApproval ? t.approvers : []
125
125
  };
126
126
  }
127
- function L(e) {
127
+ function z(e) {
128
128
  return {
129
129
  minAmount: e.minAmount == null ? "" : String(e.minAmount),
130
130
  maxAmount: e.maxAmount == null ? "" : String(e.maxAmount),
@@ -132,67 +132,67 @@ function L(e) {
132
132
  approvers: e.approvers
133
133
  };
134
134
  }
135
- function R() {
135
+ function B() {
136
136
  let o = a();
137
- y(() => {
137
+ b(() => {
138
138
  o(f.Mounted);
139
139
  }, [o]);
140
- let { initResponse: d } = s(), p = c(), m = d?.scopes?.includes(t.RoleReadOrg) ?? !1, { data: h, isResolving: D, isError: A } = n({ enabled: m }), j = b(() => k(h?.data ?? []), [h]), N = b(() => {
141
- let e = h?.data ?? [], t = e.find((e) => e.isSystemRole === !0 && E(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && O(e.key)), r = { reporting_manager: l.ReportingManagerLabel };
140
+ let { initResponse: d } = s(), p = c(), m = d?.scopes?.includes(t.RoleReadOrg) ?? !1, { data: h, isResolving: O, isError: j } = n({ enabled: m }), M = x(() => A(h?.data ?? []), [h]), F = x(() => {
141
+ let e = h?.data ?? [], t = e.find((e) => e.isSystemRole === !0 && D(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && k(e.key)), r = { reporting_manager: l.ReportingManagerLabel };
142
142
  t && (r[t.id] = l.AdminLabel), n && (r[n.id] = l.CfoLabel);
143
143
  for (let t of e) r[t.id] || (r[t.id] = t.name);
144
144
  return r;
145
- }, [h]), { rules: P, isLoading: R, saveStatus: z, createRule: B, updateRule: V, deleteRule: H } = _(N), [U, W] = x(!1), [G, K] = x(T), [q, J] = x(null), [Y, X] = x(null);
146
- y(() => {
147
- z === "success" && e.success(g.Saved), z === "error" && e.error(g.FailedToSave);
148
- }, [z]);
149
- let Z = R || p && !d, ne = te(P), re = M(P), Q = Z || D || z === "saving", $ = U ? F(G, P) : {}, ie = Y && q ? F(Y, P, q) : {}, ae = () => {
150
- W(!0), K(T);
151
- }, oe = () => {
145
+ }, [h]), { rules: I, isLoading: B, saveStatus: V, createRule: ee, updateRule: te, deleteRule: H } = v(F), [U, W] = S(!1), [G, K] = S(E), [q, J] = S(null), [Y, X] = S(null);
146
+ b(() => {
147
+ V === "success" && e.success(g.Saved), V === "error" && e.error(g.FailedToSave);
148
+ }, [V]);
149
+ let Z = B || p && !d, ne = N(I), re = P(I), Q = Z || O || V === "saving", ie = U ? L(G, I) : {}, ae = Y && q ? L(Y, I, q) : {}, oe = () => {
150
+ W(!0), K(E);
151
+ }, se = () => {
152
152
  W(!1);
153
- }, se = async () => {
154
- let e = F(G, P);
153
+ }, $ = async () => {
154
+ let e = L(G, I);
155
155
  if (Object.keys(e).length > 0) return;
156
156
  let t = crypto.randomUUID();
157
- await B(I(t, G)) && (W(!1), K(T));
157
+ await ee(R(t, G)) && (W(!1), K(E));
158
158
  }, ce = (e) => {
159
159
  K(e);
160
160
  }, le = (e) => {
161
- let t = P.find((t) => t.id === e);
162
- t && (W(!1), K(T), J(e), X(L(t)));
161
+ let t = I.find((t) => t.id === e);
162
+ t && (W(!1), K(E), J(e), X(z(t)));
163
163
  }, ue = () => {
164
164
  J(null), X(null);
165
165
  }, de = async () => {
166
166
  if (!q || !Y) return;
167
- let e = F(Y, P, q);
168
- Object.keys(e).length > 0 || await V(q, I(q, Y)) && (J(null), X(null));
167
+ let e = L(Y, I, q);
168
+ Object.keys(e).length > 0 || await te(q, R(q, Y)) && (J(null), X(null));
169
169
  }, fe = (e) => {
170
170
  X(e);
171
171
  }, pe = async (e) => {
172
172
  await H(e), q === e && (J(null), X(null));
173
173
  };
174
- return d !== void 0 && !m ? /* @__PURE__ */ C(i, {
174
+ return d !== void 0 && !m ? /* @__PURE__ */ w(i, {
175
175
  title: u.MissingRolePermissionTitle,
176
176
  description: u.MissingRolePermissionDescription
177
- }) : A ? /* @__PURE__ */ C(i, {
177
+ }) : j ? /* @__PURE__ */ w(i, {
178
178
  title: u.RolesUnavailableTitle,
179
179
  description: u.RolesUnavailableDescription
180
- }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(r, {}), /* @__PURE__ */ C(ee, {
181
- rules: P,
180
+ }) : /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(r, {}), /* @__PURE__ */ w(_, {
181
+ rules: I,
182
182
  isBusy: Q,
183
183
  isLoading: Z,
184
184
  isAddingRule: U,
185
185
  newRuleFormValues: G,
186
- newRuleValidationErrors: $,
186
+ newRuleValidationErrors: ie,
187
187
  editingRuleId: q,
188
188
  editingRuleFormValues: Y,
189
- editingRuleValidationErrors: ie,
190
- approverOptions: Q ? [] : j,
189
+ editingRuleValidationErrors: ae,
190
+ approverOptions: Q ? [] : M,
191
191
  allExpensesAreCovered: ne,
192
192
  gapIntervals: re,
193
- onAddRuleClick: ae,
194
- onCancelAddRule: oe,
195
- onSaveNewRule: () => void se(),
193
+ onAddRuleClick: oe,
194
+ onCancelAddRule: se,
195
+ onSaveNewRule: () => void $(),
196
196
  onNewRuleFormChange: ce,
197
197
  onEditRule: le,
198
198
  onCancelEditRule: ue,
@@ -200,33 +200,24 @@ function R() {
200
200
  onEditRuleFormChange: fe,
201
201
  onDeleteRule: (e) => void pe(e),
202
202
  testIds: {
203
- ruleCard: { root: v.ruleCard },
203
+ ruleCard: { root: y.ruleCard },
204
204
  ruleForm: {
205
- root: v.ruleForm,
206
- saveButton: v.ruleFormSaveButton,
207
- minAmountInput: v.ruleFormMinAmountInput,
208
- maxAmountInput: v.ruleFormMaxAmountInput
205
+ root: y.ruleForm,
206
+ saveButton: y.ruleFormSaveButton,
207
+ minAmountInput: y.ruleFormMinAmountInput,
208
+ maxAmountInput: y.ruleFormMaxAmountInput
209
209
  }
210
210
  }
211
211
  })] });
212
212
  }
213
- function z({ token: e, orgId: t, widgetToken: n, organizationId: r, baseUrl: i, configClient: a, gatewayRouting: s, linkComponent: c, implementation: l, uiFramework: u, errorFallback: d, onError: f, disclosuresAcceptance: m, providerLabels: h } = {}) {
214
- return /* @__PURE__ */ C(o, {
213
+ function V({ token: e, orgId: t, widgetToken: n, organizationId: r, ...i } = {}) {
214
+ return /* @__PURE__ */ w(o, {
215
+ ...i,
215
216
  widgetName: p,
216
- baseUrl: i,
217
- widgetToken: n ?? e,
218
- organizationId: r ?? t,
219
- configClient: a,
220
- gatewayRouting: s,
221
- linkComponent: c,
222
- implementation: l,
223
- uiFramework: u,
224
- errorFallback: d,
225
- onError: f,
226
- disclosuresAcceptance: m,
227
- providerLabels: h,
228
- children: /* @__PURE__ */ C(R, {})
217
+ widgetToken: n === void 0 ? e : n,
218
+ organizationId: r === void 0 ? t : r,
219
+ children: /* @__PURE__ */ w(B, {})
229
220
  });
230
221
  }
231
222
  //#endregion
232
- export { z as ExpenseApprovalPoliciesWidget, z as default, k as buildApproverOptions, E as isEmbeddedSystemRoleKey, D as roleKeyHasSegment };
223
+ export { V as ExpenseApprovalPoliciesWidget, V as default, A as buildApproverOptions, D as isEmbeddedSystemRoleKey, O as roleKeyHasSegment };
@@ -63,21 +63,12 @@ function x() {
63
63
  })]
64
64
  })] });
65
65
  }
66
- function S({ token: e, orgId: t, widgetToken: n, organizationId: r, baseUrl: a, configClient: o, gatewayRouting: s, linkComponent: c, implementation: u, uiFramework: d, errorFallback: f, onError: p, disclosuresAcceptance: m, providerLabels: g } = {}) {
66
+ function S({ token: e, orgId: t, widgetToken: n, organizationId: r, ...a } = {}) {
67
67
  return /* @__PURE__ */ h(i, {
68
+ ...a,
68
69
  widgetName: l,
69
- baseUrl: a,
70
- widgetToken: n ?? e,
71
- organizationId: r ?? t,
72
- configClient: o,
73
- gatewayRouting: s,
74
- linkComponent: c,
75
- implementation: u,
76
- uiFramework: d,
77
- errorFallback: f,
78
- onError: p,
79
- disclosuresAcceptance: m,
80
- providerLabels: g,
70
+ widgetToken: n === void 0 ? e : n,
71
+ organizationId: r === void 0 ? t : r,
81
72
  children: /* @__PURE__ */ h(x, {})
82
73
  });
83
74
  }
@@ -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"
@@ -19,7 +19,7 @@ function c(n) {
19
19
  i(r.Mounted);
20
20
  }, [i]), /* @__PURE__ */ o(t, { ...n });
21
21
  }
22
- function l({ baseUrl: e, widgetToken: t, organizationId: r, configClient: a, gatewayRouting: l, linkComponent: u, errorFallback: d, onError: f, finopsThemeColors: p, analytics: m, disclosuresAcceptance: h, providerLabels: g, pageTitleComponent: _ = s, uiFramework: v, ...y }) {
22
+ function l({ baseUrl: e, widgetToken: t, organizationId: r, configClient: a, gatewayRouting: l, linkComponent: u, errorFallback: d, onError: f, finopsThemeColors: p, analytics: m, disclosuresAcceptance: h, providerLabels: g, pageTitleComponent: _ = s, uiFramework: v, implementation: y, ...b }) {
23
23
  return /* @__PURE__ */ o(n, {
24
24
  widgetName: i,
25
25
  baseUrl: e,
@@ -35,8 +35,9 @@ function l({ baseUrl: e, widgetToken: t, organizationId: r, configClient: a, gat
35
35
  disclosuresAcceptance: h,
36
36
  providerLabels: g,
37
37
  uiFramework: v,
38
+ implementation: y,
38
39
  children: /* @__PURE__ */ o(c, {
39
- ...y,
40
+ ...b,
40
41
  pageTitleComponent: _
41
42
  })
42
43
  });
@@ -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.84", n = "7cfd4f4027097f08bd71300e75898565395239f2", 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.84",
3
+ "version": "0.5.86",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {