@tesouro/embedded-components-react 0.11.167 → 0.11.168
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 +3 -0
- package/dist/lib/BankAccountsWidget.d.ts +1 -0
- package/dist/lib/CreditCardsWidget.d.ts +1 -0
- package/dist/lib/DebitCardsWidget.d.ts +1 -0
- package/dist/lib/LinkedAccountsWidget.d.ts +1 -0
- package/dist/lib/WidgetSuite.d.ts +3 -0
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/lib/BankAccountsWidget/BankAccountsWidget.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/lib/useBankAccountsWidget.js +122 -121
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/lib/BankAccountsWidgetUi.js +63 -59
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/lib/labels.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/lib/testIds.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/lib/useCardsWidget.js +161 -160
- package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsList.js +126 -122
- package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/labels.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/lib/useLinkedAccountsWidget.js +192 -191
- package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/ui/dist/index13.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/ui/dist/index14.js +100 -96
- package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/ui/dist/index6.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/lib/useCardsWidget.js
CHANGED
|
@@ -7,25 +7,25 @@ import { useEmbedApi as n } from "../../../../shared/data-access/dist/lib/EmbedA
|
|
|
7
7
|
import { useAllBankAccountsQuery as ee } from "../../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
|
|
8
8
|
import "../../../../shared/data-access/dist/index.js";
|
|
9
9
|
import { useAnalyticsTrack as te } from "../../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
10
|
-
import { useWidgetConfig as ne, useWidgetError as re,
|
|
10
|
+
import { useWidgetConfig as ne, useWidgetError as re, useWidgetInitStaleForToken as ie, useWidgetLoading as ae } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
11
11
|
import { CardProgram as r } from "../../../../shared/feature/dist/lib/card/cardProgram.js";
|
|
12
12
|
import "../../../../shared/feature/dist/index.js";
|
|
13
|
-
import { resolveCardsFeatureLabels as
|
|
14
|
-
import { getCardsPermissions as
|
|
15
|
-
import { CardsWidgetAnalyticsEvent as
|
|
16
|
-
import { maskAccountNumber as
|
|
17
|
-
import { toCardRows as
|
|
18
|
-
import { useCreditCardsQuery as
|
|
19
|
-
import { useDebitCardsQuery as
|
|
13
|
+
import { resolveCardsFeatureLabels as oe } from "./labels.js";
|
|
14
|
+
import { getCardsPermissions as se } from "./permissions.js";
|
|
15
|
+
import { CardsWidgetAnalyticsEvent as ce } from "./analytics/events.js";
|
|
16
|
+
import { maskAccountNumber as le } from "./formatters.js";
|
|
17
|
+
import { toCardRows as ue, toCreditCardListItems as de, toDebitCardListItems as fe, visibleCardColumns as pe } from "./rows.js";
|
|
18
|
+
import { useCreditCardsQuery as me } from "../../../data-access/dist/index2.js";
|
|
19
|
+
import { useDebitCardsQuery as he } from "../../../data-access/dist/index3.js";
|
|
20
20
|
import "../../../data-access/dist/index.js";
|
|
21
|
-
import { useCallback as i, useEffect as a, useMemo as o, useRef as
|
|
22
|
-
import { useControllableState as
|
|
21
|
+
import { useCallback as i, useEffect as a, useMemo as o, useRef as ge, useState as s } from "react";
|
|
22
|
+
import { useControllableState as _e } from "@radix-ui/react-use-controllable-state";
|
|
23
23
|
// ../../libs/tesouro-embedded-components-react/cards-widget/feature/dist/lib/useCardsWidget.js
|
|
24
|
-
var
|
|
24
|
+
var ve = [
|
|
25
25
|
10,
|
|
26
26
|
25,
|
|
27
27
|
50
|
|
28
|
-
], c = 10,
|
|
28
|
+
], c = 10, ye = "<none>";
|
|
29
29
|
function l(e, t) {
|
|
30
30
|
return e !== void 0 && t !== void 0 && e !== t;
|
|
31
31
|
}
|
|
@@ -36,212 +36,213 @@ function u(e) {
|
|
|
36
36
|
pageSize: t
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function d({ cardProgram: c, pagination: d, defaultPagination: f, onPaginationChange:
|
|
40
|
-
let
|
|
39
|
+
function d({ cardProgram: c, pagination: d, defaultPagination: f, onPaginationChange: be, featureLabels: xe, selectedCardId: Se, defaultSelectedCardId: Ce, onSelectedCardIdChange: we, onCreateCard: Te, onActivateCard: Ee }) {
|
|
40
|
+
let p = o(() => oe(xe), [xe]), De = te();
|
|
41
41
|
a(() => {
|
|
42
|
-
|
|
43
|
-
}, [
|
|
44
|
-
let { organizationId:
|
|
42
|
+
De(ce.Mounted);
|
|
43
|
+
}, [De]);
|
|
44
|
+
let { organizationId: m, widgetToken: Oe, initResponse: h } = ne(), g = h?.userId ?? void 0, ke = ae(), Ae = ie(), { organizationStatus: je } = n(), Me = t(je), _ = !!re(), Ne = !!(m && Oe) || !!Oe && je === e.Rotating, v = o(() => se({
|
|
45
45
|
cardProgram: c,
|
|
46
|
-
scopes:
|
|
47
|
-
}), [c,
|
|
48
|
-
|
|
49
|
-
let [
|
|
50
|
-
|
|
51
|
-
let
|
|
46
|
+
scopes: h?.scopes
|
|
47
|
+
}), [c, h?.scopes]), Pe = Ae && !v.canRead, y = !_ && !Ae && !!h && !v.canRead, b = Ne && v.canRead && !!h, Fe = o(() => u(d), [d?.pageSize, d?.paginationToken]), x = o(() => u(f), [f?.pageSize, f?.paginationToken]), [S, Ie] = s(g);
|
|
48
|
+
g !== void 0 && g !== S && Ie(g);
|
|
49
|
+
let [C, Le] = s(m);
|
|
50
|
+
m !== void 0 && m !== C && Le(m);
|
|
51
|
+
let w = [
|
|
52
52
|
c,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
].join("\0"),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
].join("\0"),
|
|
60
|
-
resetKey:
|
|
61
|
-
paginationToken:
|
|
62
|
-
pageSize:
|
|
63
|
-
})), [
|
|
64
|
-
prop:
|
|
65
|
-
defaultProp:
|
|
66
|
-
onChange:
|
|
53
|
+
C === null ? ye : C ?? "",
|
|
54
|
+
S ?? ""
|
|
55
|
+
].join("\0"), T = [
|
|
56
|
+
w,
|
|
57
|
+
x.paginationToken ?? "",
|
|
58
|
+
x.pageSize
|
|
59
|
+
].join("\0"), E = d !== void 0, [D, O] = s(() => ({
|
|
60
|
+
resetKey: T,
|
|
61
|
+
paginationToken: x.paginationToken,
|
|
62
|
+
pageSize: x.pageSize
|
|
63
|
+
})), [Re, k] = s(!1), [ze, Be] = s(() => /* @__PURE__ */ new Map()), [Ve, A] = _e({
|
|
64
|
+
prop: Se,
|
|
65
|
+
defaultProp: Ce ?? null,
|
|
66
|
+
onChange: we,
|
|
67
67
|
caller: "CardsWidget"
|
|
68
|
-
}),
|
|
68
|
+
}), j = ge({
|
|
69
69
|
cardProgram: c,
|
|
70
|
-
organizationId:
|
|
71
|
-
userId:
|
|
72
|
-
}),
|
|
70
|
+
organizationId: C,
|
|
71
|
+
userId: S
|
|
72
|
+
}), He = j.current.cardProgram !== c || l(j.current.organizationId, C) || l(j.current.userId, S);
|
|
73
73
|
a(() => {
|
|
74
|
-
let e =
|
|
75
|
-
|
|
74
|
+
let e = j.current;
|
|
75
|
+
j.current = {
|
|
76
76
|
cardProgram: c,
|
|
77
|
-
organizationId:
|
|
78
|
-
userId:
|
|
79
|
-
}, (e.cardProgram !== c || l(e.organizationId,
|
|
77
|
+
organizationId: C,
|
|
78
|
+
userId: S
|
|
79
|
+
}, (e.cardProgram !== c || l(e.organizationId, C) || l(e.userId, S)) && (A(null), k(!1));
|
|
80
80
|
}, [
|
|
81
81
|
c,
|
|
82
|
-
w,
|
|
83
82
|
C,
|
|
84
|
-
|
|
83
|
+
S,
|
|
84
|
+
A
|
|
85
85
|
]);
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
}, [
|
|
86
|
+
let M = i((e) => {
|
|
87
|
+
A(e);
|
|
88
|
+
}, [A]), N = Re && !!g, Ue = D.resetKey === T;
|
|
89
89
|
a(() => {
|
|
90
|
-
|
|
91
|
-
resetKey:
|
|
92
|
-
paginationToken:
|
|
93
|
-
pageSize:
|
|
90
|
+
E || O((e) => e.resetKey === T ? e : {
|
|
91
|
+
resetKey: T,
|
|
92
|
+
paginationToken: x.paginationToken,
|
|
93
|
+
pageSize: x.pageSize
|
|
94
94
|
});
|
|
95
95
|
}, [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
x.pageSize,
|
|
97
|
+
x.paginationToken,
|
|
98
|
+
E,
|
|
99
|
+
T
|
|
100
100
|
]);
|
|
101
|
-
let
|
|
102
|
-
limit:
|
|
103
|
-
paginationToken:
|
|
104
|
-
},
|
|
105
|
-
...
|
|
106
|
-
userId:
|
|
107
|
-
enabled:
|
|
108
|
-
}),
|
|
109
|
-
...
|
|
110
|
-
cardholderUserId:
|
|
111
|
-
enabled:
|
|
112
|
-
}),
|
|
101
|
+
let P = E ? Fe : Ue ? D : x, F = P.paginationToken, I = P.pageSize, L = N ? g : void 0, We = {
|
|
102
|
+
limit: I,
|
|
103
|
+
paginationToken: F
|
|
104
|
+
}, R = me({
|
|
105
|
+
...We,
|
|
106
|
+
userId: L,
|
|
107
|
+
enabled: b && c === r.Credit
|
|
108
|
+
}), z = he({
|
|
109
|
+
...We,
|
|
110
|
+
cardholderUserId: L,
|
|
111
|
+
enabled: b && c === r.Debit
|
|
112
|
+
}), B = c === r.Credit ? R : z, V = b && v.canReadFundingAccounts, H = ee({ enabled: V }), Ge = o(() => {
|
|
113
113
|
let e = /* @__PURE__ */ new Map();
|
|
114
|
-
if (!
|
|
115
|
-
for (let t of
|
|
114
|
+
if (!v.canReadFundingAccounts) return e;
|
|
115
|
+
for (let t of H.data?.data ?? []) {
|
|
116
116
|
let n = t.nickname?.trim();
|
|
117
117
|
e.set(t.id, n ? {
|
|
118
118
|
name: n,
|
|
119
119
|
lastFour: t.accountNumber?.trim().slice(-4) || void 0
|
|
120
|
-
} : { name:
|
|
120
|
+
} : { name: le(t.accountNumber) ?? p.untitledFundingAccount });
|
|
121
121
|
}
|
|
122
122
|
return e;
|
|
123
123
|
}, [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
]),
|
|
128
|
-
|
|
124
|
+
H.data?.data,
|
|
125
|
+
p.untitledFundingAccount,
|
|
126
|
+
v.canReadFundingAccounts
|
|
127
|
+
]), Ke = V && H.isError, qe = V && !Ke && (H.isLoading || H.isFetchingNextPage || !!H.hasNextPage), U = o(() => b ? c === r.Credit ? de(R.data?.data ?? []) : fe(z.data?.data ?? []) : [], [
|
|
128
|
+
b,
|
|
129
129
|
c,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
]),
|
|
130
|
+
R.data?.data,
|
|
131
|
+
z.data?.data
|
|
132
|
+
]), Je = o(() => pe({
|
|
133
133
|
cardProgram: c,
|
|
134
|
-
canReadFundingAccounts:
|
|
135
|
-
}), [c,
|
|
136
|
-
labels:
|
|
137
|
-
fundingAccountNames:
|
|
138
|
-
canActivate:
|
|
139
|
-
onCardSelect:
|
|
140
|
-
onActivateCard:
|
|
134
|
+
canReadFundingAccounts: v.canReadFundingAccounts
|
|
135
|
+
}), [c, v.canReadFundingAccounts]), Ye = o(() => ue(U, {
|
|
136
|
+
labels: p,
|
|
137
|
+
fundingAccountNames: Ge,
|
|
138
|
+
canActivate: v.canActivate,
|
|
139
|
+
onCardSelect: M,
|
|
140
|
+
onActivateCard: Ee
|
|
141
141
|
}), [
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
]),
|
|
149
|
-
key:
|
|
142
|
+
U,
|
|
143
|
+
Ge,
|
|
144
|
+
M,
|
|
145
|
+
p,
|
|
146
|
+
Ee,
|
|
147
|
+
v.canActivate
|
|
148
|
+
]), W = !B.isPlaceholderData, G = W ? B.data?.nextPaginationToken ?? void 0 : void 0, K = W ? B.data?.prevPaginationToken ?? void 0 : void 0, Xe = !!B.data, q = b && (B.isError || Ke), [J, Ze] = s({
|
|
149
|
+
key: w,
|
|
150
150
|
value: !1
|
|
151
151
|
});
|
|
152
|
-
if (
|
|
153
|
-
let e = J.key !==
|
|
154
|
-
(e || J.value !== t) &&
|
|
155
|
-
key:
|
|
152
|
+
if (b && !N && Xe) {
|
|
153
|
+
let e = J.key !== w, t = !!g && U.some((e) => e.userId !== g) || !e && J.value;
|
|
154
|
+
(e || J.value !== t) && Ze({
|
|
155
|
+
key: w,
|
|
156
156
|
value: t
|
|
157
157
|
});
|
|
158
|
-
} else J.key !==
|
|
159
|
-
key:
|
|
158
|
+
} else J.key !== w && Ze({
|
|
159
|
+
key: w,
|
|
160
160
|
value: !1
|
|
161
161
|
});
|
|
162
|
-
let
|
|
163
|
-
|
|
164
|
-
resetKey:
|
|
162
|
+
let Qe = J.value, Y = i((e) => {
|
|
163
|
+
E || O({
|
|
164
|
+
resetKey: T,
|
|
165
165
|
paginationToken: e.paginationToken,
|
|
166
166
|
pageSize: e.pageSize
|
|
167
|
-
}),
|
|
167
|
+
}), be?.(e);
|
|
168
168
|
}, [
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
]),
|
|
169
|
+
E,
|
|
170
|
+
be,
|
|
171
|
+
T
|
|
172
|
+
]), $e = i(() => {
|
|
173
173
|
Y({
|
|
174
174
|
paginationToken: void 0,
|
|
175
|
-
pageSize:
|
|
175
|
+
pageSize: I
|
|
176
176
|
});
|
|
177
|
-
}, [Y,
|
|
177
|
+
}, [Y, I]), et = i((e) => {
|
|
178
178
|
Y({
|
|
179
179
|
paginationToken: void 0,
|
|
180
180
|
pageSize: e
|
|
181
181
|
});
|
|
182
|
-
}, [Y]),
|
|
183
|
-
|
|
184
|
-
}, [
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
].join("\0"), Z =
|
|
189
|
-
t !== void 0 &&
|
|
190
|
-
}, []),
|
|
191
|
-
|
|
192
|
-
paginationToken:
|
|
193
|
-
pageSize:
|
|
182
|
+
}, [Y]), tt = i((e) => {
|
|
183
|
+
k(e), $e();
|
|
184
|
+
}, [$e]), X = [
|
|
185
|
+
T,
|
|
186
|
+
L ?? "",
|
|
187
|
+
I
|
|
188
|
+
].join("\0"), Z = F === void 0 ? 0 : ze.get(`${X}\u0000${F}`), Q = i((e, t) => {
|
|
189
|
+
t !== void 0 && Be((n) => new Map(n).set(e, t));
|
|
190
|
+
}, []), nt = i(() => {
|
|
191
|
+
K && (Q(`${X}\u0000${K ?? ""}`, Z === void 0 ? void 0 : Math.max(0, Z - I)), Y({
|
|
192
|
+
paginationToken: K,
|
|
193
|
+
pageSize: I
|
|
194
194
|
}));
|
|
195
195
|
}, [
|
|
196
196
|
Y,
|
|
197
197
|
Z,
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
I,
|
|
199
|
+
K,
|
|
200
200
|
Q,
|
|
201
201
|
X
|
|
202
|
-
]),
|
|
203
|
-
|
|
204
|
-
paginationToken:
|
|
205
|
-
pageSize:
|
|
202
|
+
]), rt = i(() => {
|
|
203
|
+
G && (Q(`${X}\u0000${G ?? ""}`, Z === void 0 ? void 0 : Z + U.length), Y({
|
|
204
|
+
paginationToken: G,
|
|
205
|
+
pageSize: I
|
|
206
206
|
}));
|
|
207
207
|
}, [
|
|
208
|
-
|
|
208
|
+
U.length,
|
|
209
209
|
Y,
|
|
210
210
|
Z,
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
G,
|
|
212
|
+
I,
|
|
213
213
|
Q,
|
|
214
214
|
X
|
|
215
|
-
]),
|
|
216
|
-
|
|
215
|
+
]), it = B.refetch, $ = H.refetch, at = i(() => {
|
|
216
|
+
it(), V && $();
|
|
217
217
|
}, [
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
V,
|
|
219
|
+
it,
|
|
220
220
|
$
|
|
221
221
|
]);
|
|
222
222
|
return {
|
|
223
|
-
rows:
|
|
224
|
-
selectedCardId:
|
|
225
|
-
onSelectCard:
|
|
226
|
-
canReadCards:
|
|
227
|
-
columns:
|
|
228
|
-
isLoading: !
|
|
229
|
-
isError:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
223
|
+
rows: Ye,
|
|
224
|
+
selectedCardId: He || y ? null : Ve,
|
|
225
|
+
onSelectCard: M,
|
|
226
|
+
canReadCards: v.canRead,
|
|
227
|
+
columns: Je,
|
|
228
|
+
isLoading: !_ && (Pe || Me && !B.data || ke && !h || b && (B.isLoading || qe)),
|
|
229
|
+
isError: _ || q,
|
|
230
|
+
isAccessRestricted: y,
|
|
231
|
+
canToggleShowMyCards: v.canRead && !!g && Qe,
|
|
232
|
+
isShowingMyCards: N,
|
|
233
|
+
onShowMyCardsChange: tt,
|
|
234
|
+
canCreateCard: !y && v.canCreate && (!!Te || v.canComposeDebitCreate),
|
|
235
|
+
onCreateCardClick: Te,
|
|
236
|
+
onRetry: at,
|
|
237
|
+
isPaginationVisible: b && Xe && !q,
|
|
238
|
+
pageSize: I,
|
|
239
|
+
pageSizeOptions: ve,
|
|
240
|
+
rangeLabel: !W || Z === void 0 || U.length === 0 ? "" : p.pageRange.replace("{from}", String(Z + 1)).replace("{to}", String(Z + U.length)),
|
|
241
|
+
isPreviousPageDisabled: !K,
|
|
242
|
+
isNextPageDisabled: !G,
|
|
243
|
+
onPageSizeChange: et,
|
|
244
|
+
onPreviousPageClick: nt,
|
|
245
|
+
onNextPageClick: rt
|
|
245
246
|
};
|
|
246
247
|
}
|
|
247
248
|
export { d as useCardsWidget };
|