@tesouro/embedded-components-react 0.5.180 → 0.5.182

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 (33) hide show
  1. package/README.md +32 -32
  2. package/dist/index.d.ts +18 -19
  3. package/dist/index.js +2 -2
  4. package/dist/lib/CreditCardsWidget.d.ts +9 -11
  5. package/dist/lib/CreditCardsWidget.js +1 -1
  6. package/dist/lib/DebitCardsWidget.d.ts +14 -15
  7. package/dist/lib/DebitCardsWidget.js +1 -1
  8. package/dist/lib/WidgetSuite.d.ts +13 -15
  9. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index.js +4 -4
  10. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index10.js +87 -8
  11. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index11.js +3 -3
  12. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index12.js +17 -0
  13. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index4.js +17 -24
  14. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index5.js +23 -24
  15. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index6.js +24 -30
  16. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index7.js +28 -55
  17. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index8.js +53 -222
  18. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +219 -87
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +6 -5
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +2 -32
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +23 -190
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +152 -46
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +84 -71
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +80 -2
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +7 -0
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +3 -3
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +1 -1
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +1 -1
  30. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  31. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index9.js +3 -3
  32. package/package.json +1 -1
  33. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index3.js +0 -19
@@ -1,33 +1,27 @@
1
- import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
2
- import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
3
- import "../../../shared/data-access/dist/index.js";
4
- import { CardProgram as n } from "../../../shared/feature/dist/lib/card/cardProgram.js";
5
- import "../../../shared/feature/dist/index.js";
1
+ import { minorExponentForCurrency as e } from "../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
2
+ import { normalizeAmountOutputCurrencyCode as t } from "../../../shared/util/dist/lib/normalizeAmountOutputCurrencyCode.js";
6
3
  //#region ../../libs/tesouro-embedded-components-react/cards-widget/feature/dist/index6.js
7
- var r = {
8
- [n.Credit]: {
9
- read: [t.CreditCardReadOrg],
10
- activate: [t.CreditCardActivateOrg],
11
- create: [t.CreditCardIssueOrg]
12
- },
13
- [n.Debit]: {
14
- read: [t.DebitCardReadOrg],
15
- activate: [t.DebitCardActivateOrg],
16
- create: [t.DebitCardIssueOrg]
17
- }
18
- }, i = [t.BankAccountReadOrg], a = {
19
- users: [t.UserReadOrg],
20
- funding: i
21
- };
22
- function o({ cardProgram: t, scopes: o }) {
23
- let s = new Set(o ?? []), c = r[t];
24
- return {
25
- canRead: e(s, c.read),
26
- canActivate: e(s, c.activate),
27
- canCreate: e(s, c.create),
28
- canReadFundingAccounts: t === n.Debit && e(s, i),
29
- canComposeDebitCreate: t === n.Debit && e(s, a.users) && e(s, a.funding)
30
- };
4
+ function n(e) {
5
+ if (e == null || e === "") return;
6
+ let t = Number(e);
7
+ return Number.isFinite(t) ? t : void 0;
8
+ }
9
+ function r({ limit: r, currencyCode: i }) {
10
+ let a = n(r);
11
+ if (a === void 0) return;
12
+ let o = t(i);
13
+ return new Intl.NumberFormat(void 0, {
14
+ style: "currency",
15
+ currency: o,
16
+ maximumFractionDigits: 0
17
+ }).format(a / 10 ** e(o));
18
+ }
19
+ function i(e) {
20
+ let t = e?.trim().slice(-4);
21
+ return t ? `••••${t}` : void 0;
22
+ }
23
+ function a(e, t) {
24
+ return e?.trim() || t;
31
25
  }
32
26
  //#endregion
33
- export { o as getCardsPermissions };
27
+ export { r as formatCardLimit, i as maskAccountNumber, a as withFallback };
@@ -1,60 +1,33 @@
1
- import { CardProgram as e } from "../../../shared/feature/dist/lib/card/cardProgram.js";
2
- import { CARD_STATUS_TONE as t } from "../../../shared/feature/dist/lib/card/cardPresentation.js";
1
+ import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
2
+ import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
3
+ import "../../../shared/data-access/dist/index.js";
4
+ import { CardProgram as n } from "../../../shared/feature/dist/lib/card/cardProgram.js";
3
5
  import "../../../shared/feature/dist/index.js";
4
- import { formatCardLimit as n, withFallback as r } from "./index5.js";
5
- import { CARD_COLUMN_KEYS as i } from "../../ui/dist/lib/CardsList/types.js";
6
- import "../../ui/dist/index.js";
7
6
  //#region ../../libs/tesouro-embedded-components-react/cards-widget/feature/dist/index7.js
8
- var a = "PENDING_ACTIVATION", o = {
9
- [e.Credit]: i.filter((e) => e !== "fundingAccount" && e !== "limit"),
10
- [e.Debit]: i.filter((e) => e !== "limit")
7
+ var r = {
8
+ [n.Credit]: {
9
+ read: [t.CreditCardReadOrg],
10
+ activate: [t.CreditCardActivateOrg],
11
+ create: [t.CreditCardIssueOrg]
12
+ },
13
+ [n.Debit]: {
14
+ read: [t.DebitCardReadOrg],
15
+ activate: [t.DebitCardActivateOrg],
16
+ create: [t.DebitCardIssueOrg]
17
+ }
18
+ }, i = [t.BankAccountReadOrg], a = {
19
+ users: [t.UserReadOrg],
20
+ funding: i
11
21
  };
12
- function s(e) {
13
- return e.map((e) => ({
14
- id: e.id,
15
- userId: e.userId,
16
- status: e.cardStatus,
17
- type: e.cardType,
18
- cardholderName: e.cardholderName,
19
- nickname: e.nickname,
20
- lastFourDigits: e.lastFourDigits,
21
- limit: e.cardLimit,
22
- limitCurrencyCode: e.currentBalance?.currencyCode
23
- }));
24
- }
25
- function c(e) {
26
- return e.map((e) => ({
27
- id: e.id,
28
- userId: e.userId,
29
- status: e.cardStatus,
30
- type: e.cardType,
31
- cardholderName: e.cardholderName,
32
- nickname: e.nickname,
33
- lastFourDigits: e.lastFourDigits,
34
- fundingAccountId: e.bankAccountId
35
- }));
36
- }
37
- function l(e, { labels: i, fundingAccountNames: o, canActivate: s, onCardSelect: c, onActivateCard: l }) {
38
- return e.map((e) => {
39
- let u = s && e.status === a, d = e.fundingAccountId ? o?.get(e.fundingAccountId) : void 0;
40
- return {
41
- key: e.id,
42
- nickname: r(e.nickname, i.untitledCard),
43
- lastFour: e.lastFourDigits,
44
- typeLabel: i.cardType[e.type] ?? i.emptyValue,
45
- fundingAccount: d?.name ?? i.emptyValue,
46
- fundingAccountLastFour: d?.lastFour,
47
- cardholder: r(e.cardholderName, i.emptyValue),
48
- statusLabel: i.cardStatus[e.status] ?? i.emptyValue,
49
- statusTone: t[e.status] ?? "neutral",
50
- limit: n({
51
- limit: e.limit,
52
- currencyCode: e.limitCurrencyCode
53
- }),
54
- onSelect: c ? () => c(e.id) : void 0,
55
- onActivate: u && l ? () => l(e.id) : void 0
56
- };
57
- });
22
+ function o({ cardProgram: t, scopes: o }) {
23
+ let s = new Set(o ?? []), c = r[t];
24
+ return {
25
+ canRead: e(s, c.read),
26
+ canActivate: e(s, c.activate),
27
+ canCreate: e(s, c.create),
28
+ canReadFundingAccounts: t === n.Debit && e(s, i),
29
+ canComposeDebitCreate: t === n.Debit && e(s, a.users) && e(s, a.funding)
30
+ };
58
31
  }
59
32
  //#endregion
60
- export { o as CARD_COLUMNS_BY_PROGRAM, l as toCardRows, s as toCreditCardListItems, c as toDebitCardListItems };
33
+ export { o as getCardsPermissions };
@@ -1,229 +1,60 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { useAllBankAccountsQuery as e } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
6
- import "../../../shared/data-access/dist/index.js";
7
- import { useAnalyticsTrack as t } from "../../../shared/feature/dist/lib/analytics/hooks.js";
8
- import { useWidgetConfig as n, useWidgetError as ee, useWidgetLoading as te } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
9
- import { CardProgram as r } from "../../../shared/feature/dist/lib/card/cardProgram.js";
1
+ import { CardProgram as e } from "../../../shared/feature/dist/lib/card/cardProgram.js";
2
+ import { CARD_STATUS_TONE as t } from "../../../shared/feature/dist/lib/card/cardPresentation.js";
10
3
  import "../../../shared/feature/dist/index.js";
11
- import { resolveCardsFeatureLabels as ne } from "./index4.js";
12
- import { getCardsPermissions as re } from "./index6.js";
13
- import { CardsWidgetAnalyticsEvent as ie } from "./index2.js";
14
- import { maskAccountNumber as ae } from "./index5.js";
15
- import { CARD_COLUMNS_BY_PROGRAM as oe, toCardRows as se, toCreditCardListItems as ce, toDebitCardListItems as le } from "./index7.js";
16
- import { useCreditCardsQuery as ue } from "../../data-access/dist/index2.js";
17
- import { useDebitCardsQuery as de } from "../../data-access/dist/index3.js";
18
- import "../../data-access/dist/index.js";
19
- import { useCallback as i, useEffect as a, useMemo as o, useRef as fe, useState as s } from "react";
20
- import { useControllableState as pe } from "@radix-ui/react-use-controllable-state";
4
+ import { formatCardLimit as n, withFallback as r } from "./index6.js";
5
+ import { CARD_COLUMN_KEYS as i } from "../../ui/dist/lib/CardsList/types.js";
6
+ import "../../ui/dist/index.js";
21
7
  //#region ../../libs/tesouro-embedded-components-react/cards-widget/feature/dist/index8.js
22
- var me = [
23
- 10,
24
- 25,
25
- 50
26
- ], c = 10, he = "<none>";
27
- function l(e, t) {
28
- return e !== void 0 && t !== void 0 && e !== t;
8
+ var a = "PENDING_ACTIVATION", o = {
9
+ [e.Credit]: i.filter((e) => e !== "fundingAccount" && e !== "limit"),
10
+ [e.Debit]: i.filter((e) => e !== "limit")
11
+ };
12
+ function s(e) {
13
+ return e.map((e) => ({
14
+ id: e.id,
15
+ userId: e.userId,
16
+ status: e.cardStatus,
17
+ type: e.cardType,
18
+ cardholderName: e.cardholderName,
19
+ nickname: e.nickname,
20
+ lastFourDigits: e.lastFourDigits,
21
+ limit: e.cardLimit,
22
+ limitCurrencyCode: e.currentBalance?.currencyCode
23
+ }));
29
24
  }
30
- function u(e) {
31
- let t = Number.isInteger(e?.pageSize) && Number(e?.pageSize) > 0 ? Number(e?.pageSize) : c;
32
- return {
33
- paginationToken: e?.paginationToken,
34
- pageSize: t
35
- };
25
+ function c(e) {
26
+ return e.map((e) => ({
27
+ id: e.id,
28
+ userId: e.userId,
29
+ status: e.cardStatus,
30
+ type: e.cardType,
31
+ cardholderName: e.cardholderName,
32
+ nickname: e.nickname,
33
+ lastFourDigits: e.lastFourDigits,
34
+ fundingAccountId: e.bankAccountId
35
+ }));
36
36
  }
37
- function d({ cardProgram: c, pagination: d, defaultPagination: f, onPaginationChange: p, featureLabels: m, selectedCardId: ge, defaultSelectedCardId: _e, onSelectedCardIdChange: ve, onCreateCard: ye, onActivateCard: be, cardArtSrc: xe }) {
38
- let h = o(() => ne(m), [m]), Se = t();
39
- a(() => {
40
- Se(ie.Mounted);
41
- }, [Se]);
42
- let { organizationId: g, widgetToken: Ce, initResponse: _ } = n(), v = _?.userId ?? void 0, we = te(), y = !!ee(), b = !!(g && Ce), x = o(() => re({
43
- cardProgram: c,
44
- scopes: _?.scopes
45
- }), [c, _?.scopes]), S = b && x.canRead && !!_, Te = o(() => u(d), [d?.pageSize, d?.paginationToken]), C = o(() => u(f), [f?.pageSize, f?.paginationToken]), [w, Ee] = s(v);
46
- v !== void 0 && v !== w && Ee(v);
47
- let [T, De] = s(g);
48
- g !== void 0 && g !== T && De(g);
49
- let E = [
50
- c,
51
- T === null ? he : T ?? "",
52
- w ?? ""
53
- ].join("\0"), D = [
54
- E,
55
- C.paginationToken ?? "",
56
- C.pageSize
57
- ].join("\0"), O = d !== void 0, [k, A] = s(() => ({
58
- resetKey: D,
59
- paginationToken: C.paginationToken,
60
- pageSize: C.pageSize
61
- })), [Oe, j] = s(!1), [ke, M] = pe({
62
- prop: ge,
63
- defaultProp: _e ?? null,
64
- onChange: ve,
65
- caller: "CardsWidget"
66
- }), N = fe({
67
- cardProgram: c,
68
- organizationId: T,
69
- userId: w
70
- }), Ae = N.current.cardProgram !== c || l(N.current.organizationId, T) || l(N.current.userId, w);
71
- a(() => {
72
- let e = N.current;
73
- N.current = {
74
- cardProgram: c,
75
- organizationId: T,
76
- userId: w
77
- }, (e.cardProgram !== c || l(e.organizationId, T) || l(e.userId, w)) && (M(null), j(!1));
78
- }, [
79
- c,
80
- T,
81
- w,
82
- M
83
- ]);
84
- let P = i((e) => {
85
- M(e);
86
- }, [M]), F = Oe && !!v, je = k.resetKey === D;
87
- a(() => {
88
- O || A((e) => e.resetKey === D ? e : {
89
- resetKey: D,
90
- paginationToken: C.paginationToken,
91
- pageSize: C.pageSize
92
- });
93
- }, [
94
- C.pageSize,
95
- C.paginationToken,
96
- O,
97
- D
98
- ]);
99
- let I = O ? Te : je ? k : C, Me = I.paginationToken, L = I.pageSize, R = F ? v : void 0, z = {
100
- limit: L,
101
- paginationToken: Me
102
- }, B = ue({
103
- ...z,
104
- userId: R,
105
- enabled: S && c === r.Credit
106
- }), V = de({
107
- ...z,
108
- cardholderUserId: R,
109
- enabled: S && c === r.Debit
110
- }), H = c === r.Credit ? B : V, U = S && x.canReadFundingAccounts, W = e({ enabled: U }), G = o(() => {
111
- let e = /* @__PURE__ */ new Map();
112
- if (!x.canReadFundingAccounts) return e;
113
- for (let t of W.data?.data ?? []) {
114
- let n = t.nickname?.trim();
115
- e.set(t.id, n ? {
116
- name: n,
117
- lastFour: t.accountNumber?.trim().slice(-4) || void 0
118
- } : { name: ae(t.accountNumber) ?? h.untitledFundingAccount });
119
- }
120
- return e;
121
- }, [
122
- W.data?.data,
123
- h.untitledFundingAccount,
124
- x.canReadFundingAccounts
125
- ]), K = U && W.isError, Ne = U && !K && (W.isLoading || W.isFetchingNextPage || !!W.hasNextPage), q = o(() => S ? c === r.Credit ? ce(B.data?.data ?? []) : le(V.data?.data ?? []) : [], [
126
- S,
127
- c,
128
- B.data?.data,
129
- V.data?.data
130
- ]), Pe = o(() => se(q, {
131
- labels: h,
132
- fundingAccountNames: G,
133
- canActivate: x.canActivate,
134
- onCardSelect: P,
135
- onActivateCard: be
136
- }), [
137
- q,
138
- G,
139
- P,
140
- h,
141
- be,
142
- x.canActivate
143
- ]), J = H.data?.nextPaginationToken ?? void 0, Y = H.data?.prevPaginationToken ?? void 0, Fe = !!H.data, Ie = S && (H.isError || K), [X, Le] = s({
144
- key: E,
145
- value: !1
37
+ function l(e, { labels: i, fundingAccountNames: o, canActivate: s, onCardSelect: c, onActivateCard: l }) {
38
+ return e.map((e) => {
39
+ let u = s && e.status === a, d = e.fundingAccountId ? o?.get(e.fundingAccountId) : void 0;
40
+ return {
41
+ key: e.id,
42
+ nickname: r(e.nickname, i.untitledCard),
43
+ lastFour: e.lastFourDigits,
44
+ typeLabel: i.cardType[e.type] ?? i.emptyValue,
45
+ fundingAccount: d?.name ?? i.emptyValue,
46
+ fundingAccountLastFour: d?.lastFour,
47
+ cardholder: r(e.cardholderName, i.emptyValue),
48
+ statusLabel: i.cardStatus[e.status] ?? i.emptyValue,
49
+ statusTone: t[e.status] ?? "neutral",
50
+ limit: n({
51
+ limit: e.limit,
52
+ currencyCode: e.limitCurrencyCode
53
+ }),
54
+ onSelect: c ? () => c(e.id) : void 0,
55
+ onActivate: u && l ? () => l(e.id) : void 0
56
+ };
146
57
  });
147
- if (S && !F && Fe) {
148
- let e = X.key !== E, t = !!v && q.some((e) => e.userId !== v) || !e && X.value;
149
- (e || X.value !== t) && Le({
150
- key: E,
151
- value: t
152
- });
153
- } else X.key !== E && Le({
154
- key: E,
155
- value: !1
156
- });
157
- let Re = X.value, Z = i((e) => {
158
- O || A({
159
- resetKey: D,
160
- paginationToken: e.paginationToken,
161
- pageSize: e.pageSize
162
- }), p?.(e);
163
- }, [
164
- O,
165
- p,
166
- D
167
- ]), Q = i(() => {
168
- Z({
169
- paginationToken: void 0,
170
- pageSize: L
171
- });
172
- }, [Z, L]), ze = i((e) => {
173
- Z({
174
- paginationToken: void 0,
175
- pageSize: e
176
- });
177
- }, [Z]), Be = i((e) => {
178
- j(e), Q();
179
- }, [Q]), Ve = i(() => {
180
- Z({
181
- paginationToken: Y,
182
- pageSize: L
183
- });
184
- }, [
185
- Z,
186
- L,
187
- Y
188
- ]), He = i(() => {
189
- Z({
190
- paginationToken: J,
191
- pageSize: L
192
- });
193
- }, [
194
- Z,
195
- J,
196
- L
197
- ]), Ue = H.refetch, $ = W.refetch, We = i(() => {
198
- Ue(), U && $();
199
- }, [
200
- U,
201
- Ue,
202
- $
203
- ]);
204
- return {
205
- rows: Pe,
206
- selectedCardId: Ae ? null : ke,
207
- onSelectCard: P,
208
- canReadCards: x.canRead,
209
- columns: oe[c],
210
- isLoading: !y && (!b || we && !_ || S && (H.isLoading || Ne)),
211
- isError: y || Ie,
212
- canToggleShowMyCards: x.canRead && !!v && Re,
213
- isShowingMyCards: F,
214
- onShowMyCardsChange: Be,
215
- canCreateCard: x.canCreate && (!!ye || !!xe && x.canComposeDebitCreate),
216
- onCreateCardClick: ye,
217
- onRetry: We,
218
- isPaginationVisible: S && Fe && !Ie,
219
- pageSize: L,
220
- pageSizeOptions: me,
221
- isPreviousPageDisabled: !Y,
222
- isNextPageDisabled: !J,
223
- onPageSizeChange: ze,
224
- onPreviousPageClick: Ve,
225
- onNextPageClick: He
226
- };
227
58
  }
228
59
  //#endregion
229
- export { d as useCardsWidget };
60
+ export { o as CARD_COLUMNS_BY_PROGRAM, l as toCardRows, s as toCreditCardListItems, c as toDebitCardListItems };