@tesouro/embedded-components-react 0.7.14 → 0.7.16

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
@@ -1990,10 +1990,12 @@ interface BankAccountOnboardingWidgetLabels {
1990
1990
  personalReviewSubtitle: string;
1991
1991
  /** Accessible title for the onboarding modal. */
1992
1992
  modalTitle: string;
1993
- /** Thrown when submit returns without an application id. */
1993
+ /** Shown when submitting the application fails. */
1994
1994
  submitFailedError: string;
1995
- /** Fallback when an API error has no extractable message. */
1995
+ /** Shown when saving the application fails. */
1996
1996
  genericRetryError: string;
1997
+ /** Shown when deleting the application fails. */
1998
+ deleteFailedError?: string;
1997
1999
  /** Shown when the close prompt's "Save changes" has nothing valid to write. */
1998
2000
  saveDraftNothingValidError: string;
1999
2001
  /** Used when init has no bank name for disclaimers / result branding. */
@@ -4149,6 +4151,12 @@ interface AcceptDisclosuresWidgetLabels {
4149
4151
  agreementCheckboxAriaLabel: string;
4150
4152
  /** Fallback when the accept API fails without a usable message. */
4151
4153
  acceptErrorFallback: string;
4154
+ /**
4155
+ * Shown when acceptance succeeded but the host could not continue to its
4156
+ * next step. Kept distinct from `acceptErrorFallback` because the disclosure
4157
+ * operation has already completed.
4158
+ */
4159
+ continuationErrorFallback?: string;
4152
4160
  /**
4153
4161
  * Use `{bankName}` for the bank display name and `{documents}` for the
4154
4162
  * conjunction list of titles the backend returned (same order as the links).
@@ -4204,6 +4212,7 @@ declare const ACCEPT_DISCLOSURES_WIDGET_LABELS_EN: {
4204
4212
  acceptButton: string;
4205
4213
  agreementCheckboxAriaLabel: string;
4206
4214
  acceptErrorFallback: string;
4215
+ continuationErrorFallback: string;
4207
4216
  agreementTextTemplate: string;
4208
4217
  providerAttributionPrefix: string;
4209
4218
  providerAttributionMiddle: string;
@@ -9,6 +9,12 @@ interface AcceptDisclosuresWidgetLabels {
9
9
  agreementCheckboxAriaLabel: string;
10
10
  /** Fallback when the accept API fails without a usable message. */
11
11
  acceptErrorFallback: string;
12
+ /**
13
+ * Shown when acceptance succeeded but the host could not continue to its
14
+ * next step. Kept distinct from `acceptErrorFallback` because the disclosure
15
+ * operation has already completed.
16
+ */
17
+ continuationErrorFallback?: string;
12
18
  /**
13
19
  * Use `{bankName}` for the bank display name and `{documents}` for the
14
20
  * conjunction list of titles the backend returned (same order as the links).
@@ -64,6 +70,7 @@ declare const ACCEPT_DISCLOSURES_WIDGET_LABELS_EN: {
64
70
  acceptButton: string;
65
71
  agreementCheckboxAriaLabel: string;
66
72
  acceptErrorFallback: string;
73
+ continuationErrorFallback: string;
67
74
  agreementTextTemplate: string;
68
75
  providerAttributionPrefix: string;
69
76
  providerAttributionMiddle: string;
@@ -1058,10 +1058,12 @@ interface BankAccountOnboardingWidgetLabels {
1058
1058
  personalReviewSubtitle: string;
1059
1059
  /** Accessible title for the onboarding modal. */
1060
1060
  modalTitle: string;
1061
- /** Thrown when submit returns without an application id. */
1061
+ /** Shown when submitting the application fails. */
1062
1062
  submitFailedError: string;
1063
- /** Fallback when an API error has no extractable message. */
1063
+ /** Shown when saving the application fails. */
1064
1064
  genericRetryError: string;
1065
+ /** Shown when deleting the application fails. */
1066
+ deleteFailedError?: string;
1065
1067
  /** Shown when the close prompt's "Save changes" has nothing valid to write. */
1066
1068
  saveDraftNothingValidError: string;
1067
1069
  /** Used when init has no bank name for disclaimers / result branding. */
@@ -1107,10 +1107,12 @@ interface BankAccountOnboardingWidgetLabels {
1107
1107
  personalReviewSubtitle: string;
1108
1108
  /** Accessible title for the onboarding modal. */
1109
1109
  modalTitle: string;
1110
- /** Thrown when submit returns without an application id. */
1110
+ /** Shown when submitting the application fails. */
1111
1111
  submitFailedError: string;
1112
- /** Fallback when an API error has no extractable message. */
1112
+ /** Shown when saving the application fails. */
1113
1113
  genericRetryError: string;
1114
+ /** Shown when deleting the application fails. */
1115
+ deleteFailedError?: string;
1114
1116
  /** Shown when the close prompt's "Save changes" has nothing valid to write. */
1115
1117
  saveDraftNothingValidError: string;
1116
1118
  /** Used when init has no bank name for disclaimers / result branding. */
@@ -2,153 +2,153 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { extractApiErrorMessage as e } from "../../../../../shared/util/dist/lib/apiErrors.js";
6
- import { personDisclosure as t } from "../../../../../shared/data-access/dist/lib/disclosures/personDisclosure.js";
7
- import { useAcceptWidgetDisclosures as n } from "../../../../../shared/data-access/dist/lib/disclosures/useAcceptWidgetDisclosures.js";
8
- import { useDisclosuresQuery as r } from "../../../../../shared/data-access/dist/lib/disclosures/useDisclosuresQuery.js";
9
- import { ErrorState as i } from "../../../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
5
+ import { personDisclosure as e } from "../../../../../shared/data-access/dist/lib/disclosures/personDisclosure.js";
6
+ import { useAcceptWidgetDisclosures as t } from "../../../../../shared/data-access/dist/lib/disclosures/useAcceptWidgetDisclosures.js";
7
+ import { useDisclosuresQuery as n } from "../../../../../shared/data-access/dist/lib/disclosures/useDisclosuresQuery.js";
8
+ import { ErrorState as r } from "../../../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
10
9
  import "../../../../../shared/ui/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 s, useWidgetConfig as c, useWidgetInitStaleForToken as l } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import { useAnalyticsTrack as i } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
11
+ import { WidgetProvider as a } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
12
+ import { useRefetchWidget as o, useWidgetConfig as s, useWidgetInitStaleForToken as c } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
14
13
  import "../../../../../shared/feature/dist/index.js";
15
- import { AcceptDisclosuresWidgetAnalyticsEvent as u, WIDGET_NAME as d } from "../analytics/events.js";
16
- import { mergeAcceptDisclosuresWidgetLabels as f } from "../../../../ui/dist/lib/AcceptDisclosuresWidget/labels.js";
17
- import { AcceptDisclosuresWidget as p } from "../../../../ui/dist/lib/AcceptDisclosuresWidget/AcceptDisclosuresWidget.js";
14
+ import { AcceptDisclosuresWidgetAnalyticsEvent as l, WIDGET_NAME as u } from "../analytics/events.js";
15
+ import { mergeAcceptDisclosuresWidgetLabels as d } from "../../../../ui/dist/lib/AcceptDisclosuresWidget/labels.js";
16
+ import { AcceptDisclosuresWidget as f } from "../../../../ui/dist/lib/AcceptDisclosuresWidget/AcceptDisclosuresWidget.js";
18
17
  import "../../../../ui/dist/index.js";
19
- import { resolveAcceptDisclosuresContent as m } from "./resolveAcceptDisclosuresContent.js";
20
- import { acceptDisclosuresWidgetTestIds as h } from "./testIds.js";
18
+ import { resolveAcceptDisclosuresContent as p } from "./resolveAcceptDisclosuresContent.js";
19
+ import { acceptDisclosuresWidgetTestIds as m } from "./testIds.js";
21
20
  import "../../../../data-access/dist/index.js";
22
- import { useCallback as g, useEffect as _, useRef as v, useState as y } from "react";
23
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
21
+ import { useCallback as h, useEffect as g, useRef as _, useState as v } from "react";
22
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
24
23
  //#region ../../libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/lib/AcceptDisclosuresWidget/AcceptDisclosuresWidget.js
25
- function C(e, t, n) {
26
- return /* @__PURE__ */ S(b, { children: [
24
+ function S(e, t, n) {
25
+ return /* @__PURE__ */ x(y, { children: [
27
26
  n.providerAttributionPrefix,
28
- /* @__PURE__ */ x("strong", { children: e }),
27
+ /* @__PURE__ */ b("strong", { children: e }),
29
28
  n.providerAttributionMiddle,
30
29
  t,
31
30
  n.providerAttributionSuffix
32
31
  ] });
33
32
  }
34
- function w({ labels: n, onAccepted: o }) {
35
- let s = a(), { initResponse: d } = c(), p = l(), h = f(n), { data: g, isError: v, error: y, refetch: b } = r({ userId: d?.userId ?? void 0 });
36
- if (_(() => {
37
- s(u.Mounted);
38
- }, [s]), v) return /* @__PURE__ */ x(i, {
39
- title: h.loadErrorTitle,
40
- description: e(y) ?? h.loadErrorFallback,
41
- retryLabel: h.loadErrorRetryLabel,
33
+ function C({ labels: t, onAccepted: a }) {
34
+ let o = i(), { initResponse: u } = s(), f = c(), m = d(t), { data: h, isError: _, refetch: v } = n({ userId: u?.userId ?? void 0 });
35
+ if (g(() => {
36
+ o(l.Mounted);
37
+ }, [o]), _) return /* @__PURE__ */ b(r, {
38
+ title: m.loadErrorTitle,
39
+ description: m.loadErrorFallback,
40
+ retryLabel: m.loadErrorRetryLabel,
42
41
  onRetry: () => {
43
- b();
42
+ v();
44
43
  },
45
44
  testId: "accept-disclosures-load-error"
46
45
  });
47
- let S = t(g), C = m({
48
- documents: g ? S?.documents ?? [] : void 0,
49
- vspName: d?.vspName,
50
- bankName: d?.bankName,
51
- labels: n
46
+ let y = e(h), x = p({
47
+ documents: h ? y?.documents ?? [] : void 0,
48
+ vspName: u?.vspName,
49
+ bankName: u?.bankName,
50
+ labels: t
52
51
  });
53
- if (!C) return null;
54
- let w = S?.disclosureId ?? null;
55
- if (p) return null;
56
- let E = `${`user:${d?.userId ?? ""}`}:${w}:${C.vspName}:${C.bankName}:${C.agreementText}:${C.disclosureLinks.map((e) => e.href).join("|")}`;
57
- return /* @__PURE__ */ x(T, {
58
- displayedVersion: w,
59
- labelOverrides: n,
60
- content: C,
61
- labels: h,
62
- onAccepted: o,
63
- onDisclosuresVersionChanged: b
64
- }, E);
52
+ if (!x) return null;
53
+ let S = y?.disclosureId ?? null;
54
+ if (f) return null;
55
+ let C = `${`user:${u?.userId ?? ""}`}:${S}:${x.vspName}:${x.bankName}:${x.agreementText}:${x.disclosureLinks.map((e) => e.href).join("|")}`;
56
+ return /* @__PURE__ */ b(w, {
57
+ displayedVersion: S,
58
+ labelOverrides: t,
59
+ content: x,
60
+ labels: m,
61
+ onAccepted: a,
62
+ onDisclosuresVersionChanged: v
63
+ }, C);
65
64
  }
66
- function T({ displayedVersion: t, labelOverrides: r, content: i, labels: a, onAccepted: o, onDisclosuresVersionChanged: c }) {
67
- let [l, u] = y(!1), [d, f] = y(), [m, _] = y(!1), [b, S] = y(!1), w = v(!1), { mutateAsync: T } = n(), E = s(), D = g((e) => {
68
- f(void 0), u(e);
69
- }, []), O = g(async () => {
70
- if (!(!l || m || b)) {
71
- f(void 0), _(!0);
65
+ function w({ displayedVersion: e, labelOverrides: n, content: r, labels: i, onAccepted: a, onDisclosuresVersionChanged: s }) {
66
+ let [c, l] = v(!1), [u, d] = v(), [p, g] = v(!1), [y, x] = v(!1), C = _(!1), { mutateAsync: w } = t(), T = o(), E = h((e) => {
67
+ d(void 0), l(e);
68
+ }, []), D = h(async () => {
69
+ if (!(!c || p || y)) {
70
+ d(void 0), g(!0);
72
71
  try {
73
- if (!w.current) try {
74
- await T({ displayedVersion: t }), w.current = !0;
75
- } catch (t) {
76
- if (t instanceof Error && t.name === "DisclosuresVersionChangedError") {
77
- f(a.disclosuresUpdatedFallback), c();
72
+ if (!C.current) try {
73
+ await w({ displayedVersion: e }), C.current = !0;
74
+ } catch (e) {
75
+ if (e instanceof Error && e.name === "DisclosuresVersionChangedError") {
76
+ d(i.disclosuresUpdatedFallback), s();
78
77
  return;
79
78
  }
80
- f(e(t) ?? a.acceptErrorFallback);
79
+ d(i.acceptErrorFallback);
81
80
  return;
82
81
  }
83
82
  try {
84
- await o?.();
85
- } catch (t) {
86
- f(e(t) ?? a.acceptErrorFallback);
83
+ await a?.();
84
+ } catch {
85
+ d(i.continuationErrorFallback);
87
86
  return;
88
87
  }
89
- E(), S(!0);
88
+ T(), x(!0);
90
89
  } finally {
91
- _(!1);
90
+ g(!1);
92
91
  }
93
92
  }
94
93
  }, [
95
- T,
96
- t,
97
- b,
98
- l,
99
- m,
100
- a.acceptErrorFallback,
101
- a.disclosuresUpdatedFallback,
102
- o,
94
+ w,
95
+ e,
96
+ y,
103
97
  c,
104
- E
98
+ p,
99
+ i.acceptErrorFallback,
100
+ i.continuationErrorFallback,
101
+ i.disclosuresUpdatedFallback,
102
+ a,
103
+ s,
104
+ T
105
105
  ]);
106
- return /* @__PURE__ */ x(p, {
106
+ return /* @__PURE__ */ b(f, {
107
107
  labels: {
108
- ...r,
109
- title: i.title,
110
- agreementCheckboxAriaLabel: i.agreementCheckboxAriaLabel
108
+ ...n,
109
+ title: r.title,
110
+ agreementCheckboxAriaLabel: r.agreementCheckboxAriaLabel
111
111
  },
112
- providerAttribution: C(i.vspName, i.bankName, a),
113
- agreementText: i.agreementText,
114
- disclosureLinks: i.disclosureLinks,
115
- isAgreed: l,
116
- onAgreedChange: D,
112
+ providerAttribution: S(r.vspName, r.bankName, i),
113
+ agreementText: r.agreementText,
114
+ disclosureLinks: r.disclosureLinks,
115
+ isAgreed: c,
116
+ onAgreedChange: E,
117
117
  onAccept: () => {
118
- O();
118
+ D();
119
119
  },
120
- isSubmitting: m,
121
- isAccepted: b,
122
- errorMessage: d,
120
+ isSubmitting: p,
121
+ isAccepted: y,
122
+ errorMessage: u,
123
123
  testIds: {
124
- root: h.root,
125
- providerAttribution: h.providerAttribution,
126
- disclosureLinks: h.disclosureLinks,
127
- agreeCheckbox: h.agreeCheckbox,
128
- agreementText: h.agreementText,
129
- acceptButton: h.acceptButton,
130
- error: h.error
124
+ root: m.root,
125
+ providerAttribution: m.providerAttribution,
126
+ disclosureLinks: m.disclosureLinks,
127
+ agreeCheckbox: m.agreeCheckbox,
128
+ agreementText: m.agreementText,
129
+ acceptButton: m.acceptButton,
130
+ error: m.error
131
131
  }
132
132
  });
133
133
  }
134
- function E({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: i, linkComponent: a, implementation: s, uiFramework: c, errorFallback: l, onError: u, analytics: f, disclosuresAcceptance: p, providerLabels: m, ...h }) {
135
- return /* @__PURE__ */ x(o, {
136
- widgetName: d,
134
+ function T({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: i, linkComponent: o, implementation: s, uiFramework: c, errorFallback: l, onError: d, analytics: f, disclosuresAcceptance: p, providerLabels: m, ...h }) {
135
+ return /* @__PURE__ */ b(a, {
136
+ widgetName: u,
137
137
  baseUrl: e,
138
138
  widgetToken: t,
139
139
  organizationId: n,
140
140
  configClient: r,
141
141
  gatewayRouting: i,
142
- linkComponent: a,
142
+ linkComponent: o,
143
143
  implementation: s,
144
144
  uiFramework: c,
145
145
  errorFallback: l,
146
- onError: u,
146
+ onError: d,
147
147
  analytics: f,
148
148
  disclosuresAcceptance: p,
149
149
  providerLabels: m,
150
- children: /* @__PURE__ */ x(w, { ...h })
150
+ children: /* @__PURE__ */ b(C, { ...h })
151
151
  });
152
152
  }
153
153
  //#endregion
154
- export { E as AcceptDisclosuresWidget };
154
+ export { T as AcceptDisclosuresWidget };
@@ -4,6 +4,7 @@ var e = {
4
4
  acceptButton: "Accept",
5
5
  agreementCheckboxAriaLabel: "Agree to banking disclosures",
6
6
  acceptErrorFallback: "Failed to accept disclosures",
7
+ continuationErrorFallback: "Disclosures accepted, but we could not continue. Please try again.",
7
8
  agreementTextTemplate: "I agree to {bankName}'s {documents}.",
8
9
  providerAttributionPrefix: "Banking services for ",
9
10
  providerAttributionMiddle: " are provided by ",