@tesouro/embedded-components-react 0.2.300 → 0.2.301

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
@@ -2182,7 +2182,6 @@ interface CreateCardWidgetLabels {
2182
2182
  cardArtAlt: string;
2183
2183
  setup: {
2184
2184
  sectionTitle: string;
2185
- sectionDescription: string;
2186
2185
  cardholderLabel: string;
2187
2186
  cardholderPlaceholder: string;
2188
2187
  cardFormatLabel: string;
@@ -861,7 +861,6 @@ interface CreateCardWidgetLabels {
861
861
  cardArtAlt: string;
862
862
  setup: {
863
863
  sectionTitle: string;
864
- sectionDescription: string;
865
864
  cardholderLabel: string;
866
865
  cardholderPlaceholder: string;
867
866
  cardFormatLabel: string;
@@ -13,7 +13,6 @@ interface CreateCardWidgetLabels {
13
13
  cardArtAlt: string;
14
14
  setup: {
15
15
  sectionTitle: string;
16
- sectionDescription: string;
17
16
  cardholderLabel: string;
18
17
  cardholderPlaceholder: string;
19
18
  cardFormatLabel: string;
@@ -42,7 +42,8 @@ function l(e, { labels: i, fundingAccountNames: o, canActivate: s, onCardSelect:
42
42
  nickname: r(e.nickname, i.untitledCard),
43
43
  lastFour: e.lastFourDigits,
44
44
  typeLabel: i.cardType[e.type] ?? i.emptyValue,
45
- fundingAccount: d ?? i.emptyValue,
45
+ fundingAccount: d?.name ?? i.emptyValue,
46
+ fundingAccountLastFour: d?.lastFour,
46
47
  cardholder: r(e.cardholderName, i.emptyValue),
47
48
  statusLabel: i.cardStatus[e.status] ?? i.emptyValue,
48
49
  statusTone: t[e.status] ?? "neutral",
@@ -5,204 +5,210 @@
5
5
  import { useAllBankAccountsQuery as e } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
6
6
  import "../../../shared/data-access/dist/index.js";
7
7
  import { useAnalyticsTrack as t } from "../../../shared/feature/dist/lib/analytics/hooks.js";
8
- import { useWidgetConfig as ee, useWidgetError as te, useWidgetLoading as ne } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
9
- import { CardProgram as n } from "../../../shared/feature/dist/lib/card/cardProgram.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";
10
10
  import "../../../shared/feature/dist/index.js";
11
- import { resolveCardsFeatureLabels as re } from "./index3.js";
12
- import { getCardsPermissions as ie } from "./index5.js";
13
- import { CardsWidgetAnalyticsEvent as ae } from "./index2.js";
14
- import { maskAccountNumber as oe, withFallback as se } from "./index4.js";
15
- import { CARD_COLUMNS_BY_PROGRAM as ce, toCardRows as le, toCreditCardListItems as ue, toDebitCardListItems as de } from "./index6.js";
16
- import { useCreditCardsQuery as fe } from "../../data-access/dist/index2.js";
17
- import { useDebitCardsQuery as pe } from "../../data-access/dist/index3.js";
11
+ import { resolveCardsFeatureLabels as ne } from "./index3.js";
12
+ import { getCardsPermissions as re } from "./index5.js";
13
+ import { CardsWidgetAnalyticsEvent as ie } from "./index2.js";
14
+ import { maskAccountNumber as ae } from "./index4.js";
15
+ import { CARD_COLUMNS_BY_PROGRAM as oe, toCardRows as se, toCreditCardListItems as ce, toDebitCardListItems as le } from "./index6.js";
16
+ import { useCreditCardsQuery as ue } from "../../data-access/dist/index2.js";
17
+ import { useDebitCardsQuery as de } from "../../data-access/dist/index3.js";
18
18
  import "../../data-access/dist/index.js";
19
- import { useCallback as r, useEffect as i, useMemo as a, useRef as me, useState as o } from "react";
20
- import { useControllableState as he } from "@radix-ui/react-use-controllable-state";
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";
21
21
  //#region ../../libs/tesouro-embedded-components-react/cards-widget/feature/dist/index7.js
22
- var ge = [
22
+ var me = [
23
23
  10,
24
24
  25,
25
25
  50
26
- ], s = 10, _e = "<none>";
27
- function c(e, t) {
26
+ ], c = 10, he = "<none>";
27
+ function l(e, t) {
28
28
  return e !== void 0 && t !== void 0 && e !== t;
29
29
  }
30
- function l(e) {
31
- let t = Number.isInteger(e?.pageSize) && Number(e?.pageSize) > 0 ? Number(e?.pageSize) : s;
30
+ function u(e) {
31
+ let t = Number.isInteger(e?.pageSize) && Number(e?.pageSize) > 0 ? Number(e?.pageSize) : c;
32
32
  return {
33
33
  paginationToken: e?.paginationToken,
34
34
  pageSize: t
35
35
  };
36
36
  }
37
- function u({ cardProgram: s, pagination: u, defaultPagination: d, onPaginationChange: f, featureLabels: p, selectedCardId: ve, defaultSelectedCardId: ye, onSelectedCardIdChange: be, onCreateCard: m, onActivateCard: h, cardArtSrc: xe }) {
38
- let g = a(() => re(p), [p]), _ = t();
39
- i(() => {
40
- _(ae.Mounted);
41
- }, [_]);
42
- let { organizationId: v, widgetToken: Se, initResponse: y } = ee(), b = y?.userId ?? void 0, Ce = ne(), x = !!te(), S = !!(v && Se), C = a(() => ie({
43
- cardProgram: s,
44
- scopes: y?.scopes
45
- }), [s, y?.scopes]), w = S && C.canRead && !!y, we = a(() => l(u), [u?.pageSize, u?.paginationToken]), T = a(() => l(d), [d?.pageSize, d?.paginationToken]), [E, Te] = o(b);
46
- b !== void 0 && b !== E && Te(b);
47
- let [D, Ee] = o(v);
48
- v !== void 0 && v !== D && Ee(v);
49
- let O = [
37
+ function d({ cardProgram: c, pagination: d, defaultPagination: f, onPaginationChange: p, featureLabels: m, selectedCardId: ge, defaultSelectedCardId: _e, onSelectedCardIdChange: ve, onCreateCard: h, onActivateCard: g, cardArtSrc: ye }) {
38
+ let _ = o(() => ne(m), [m]), v = t();
39
+ a(() => {
40
+ v(ie.Mounted);
41
+ }, [v]);
42
+ let { organizationId: y, widgetToken: be, initResponse: b } = n(), x = b?.userId ?? void 0, xe = te(), S = !!ee(), C = !!(y && be), w = o(() => re({
43
+ cardProgram: c,
44
+ scopes: b?.scopes
45
+ }), [c, b?.scopes]), T = C && w.canRead && !!b, Se = o(() => u(d), [d?.pageSize, d?.paginationToken]), E = o(() => u(f), [f?.pageSize, f?.paginationToken]), [D, Ce] = s(x);
46
+ x !== void 0 && x !== D && Ce(x);
47
+ let [O, we] = s(y);
48
+ y !== void 0 && y !== O && we(y);
49
+ let k = [
50
50
  [
51
- s,
52
- D === null ? _e : D ?? "",
53
- E ?? ""
51
+ c,
52
+ O === null ? he : O ?? "",
53
+ D ?? ""
54
54
  ].join("\0"),
55
- T.paginationToken ?? "",
56
- T.pageSize
57
- ].join("\0"), k = u !== void 0, [A, j] = o(() => ({
58
- resetKey: O,
59
- paginationToken: T.paginationToken,
60
- pageSize: T.pageSize
61
- })), [De, Oe] = o(!0), [ke, M] = he({
62
- prop: ve,
63
- defaultProp: ye ?? null,
64
- onChange: be,
55
+ E.paginationToken ?? "",
56
+ E.pageSize
57
+ ].join("\0"), A = d !== void 0, [j, M] = s(() => ({
58
+ resetKey: k,
59
+ paginationToken: E.paginationToken,
60
+ pageSize: E.pageSize
61
+ })), [Te, Ee] = s(!0), [De, N] = pe({
62
+ prop: ge,
63
+ defaultProp: _e ?? null,
64
+ onChange: ve,
65
65
  caller: "CardsWidget"
66
- }), N = me({
67
- cardProgram: s,
68
- organizationId: D,
69
- userId: E
70
- }), Ae = N.current.cardProgram !== s || c(N.current.organizationId, D) || c(N.current.userId, E);
71
- i(() => {
72
- let e = N.current;
73
- N.current = {
74
- cardProgram: s,
75
- organizationId: D,
76
- userId: E
77
- }, (e.cardProgram !== s || c(e.organizationId, D) || c(e.userId, E)) && M(null);
66
+ }), P = fe({
67
+ cardProgram: c,
68
+ organizationId: O,
69
+ userId: D
70
+ }), Oe = P.current.cardProgram !== c || l(P.current.organizationId, O) || l(P.current.userId, D);
71
+ a(() => {
72
+ let e = P.current;
73
+ P.current = {
74
+ cardProgram: c,
75
+ organizationId: O,
76
+ userId: D
77
+ }, (e.cardProgram !== c || l(e.organizationId, O) || l(e.userId, D)) && N(null);
78
78
  }, [
79
- s,
79
+ c,
80
+ O,
80
81
  D,
81
- E,
82
- M
82
+ N
83
83
  ]);
84
- let P = r((e) => {
85
- M(e);
86
- }, [M]), F = De && !!b, je = A.resetKey === O;
87
- i(() => {
88
- k || j((e) => e.resetKey === O ? e : {
89
- resetKey: O,
90
- paginationToken: T.paginationToken,
91
- pageSize: T.pageSize
84
+ let F = i((e) => {
85
+ N(e);
86
+ }, [N]), I = Te && !!x, ke = j.resetKey === k;
87
+ a(() => {
88
+ A || M((e) => e.resetKey === k ? e : {
89
+ resetKey: k,
90
+ paginationToken: E.paginationToken,
91
+ pageSize: E.pageSize
92
92
  });
93
93
  }, [
94
- T.pageSize,
95
- T.paginationToken,
96
- k,
97
- O
94
+ E.pageSize,
95
+ E.paginationToken,
96
+ A,
97
+ k
98
98
  ]);
99
- let I = k ? we : je ? A : T, Me = I.paginationToken, L = I.pageSize, R = {
100
- limit: L,
101
- paginationToken: Me,
102
- userId: F ? b : void 0
103
- }, z = fe({
104
- ...R,
105
- enabled: w && s === n.Credit
106
- }), B = pe({
107
- ...R,
108
- enabled: w && s === n.Debit
109
- }), V = s === n.Credit ? z : B, H = w && C.canReadFundingAccounts, U = e({ enabled: H }), W = a(() => {
99
+ let L = A ? Se : ke ? j : E, Ae = L.paginationToken, R = L.pageSize, z = {
100
+ limit: R,
101
+ paginationToken: Ae,
102
+ userId: I ? x : void 0
103
+ }, B = ue({
104
+ ...z,
105
+ enabled: T && c === r.Credit
106
+ }), V = de({
107
+ ...z,
108
+ enabled: T && c === r.Debit
109
+ }), H = c === r.Credit ? B : V, U = T && w.canReadFundingAccounts, W = e({ enabled: U }), G = o(() => {
110
110
  let e = /* @__PURE__ */ new Map();
111
- if (!C.canReadFundingAccounts) return e;
112
- for (let t of U.data?.data ?? []) e.set(t.id, se(t.nickname, oe(t.accountNumber) ?? g.untitledFundingAccount));
111
+ if (!w.canReadFundingAccounts) return e;
112
+ for (let t of W.data?.data ?? []) {
113
+ let n = t.nickname?.trim();
114
+ e.set(t.id, n ? {
115
+ name: n,
116
+ lastFour: t.accountNumber?.trim().slice(-4) || void 0
117
+ } : { name: ae(t.accountNumber) ?? _.untitledFundingAccount });
118
+ }
113
119
  return e;
114
120
  }, [
115
- U.data?.data,
116
- g.untitledFundingAccount,
117
- C.canReadFundingAccounts
118
- ]), G = H && U.isError, Ne = H && !G && (U.isLoading || U.isFetchingNextPage || !!U.hasNextPage), K = a(() => w ? s === n.Credit ? ue(z.data?.data ?? []) : de(B.data?.data ?? []) : [], [
119
- w,
120
- s,
121
- z.data?.data,
122
- B.data?.data
123
- ]), Pe = a(() => le(K, {
124
- labels: g,
125
- fundingAccountNames: W,
126
- canActivate: C.canActivate,
127
- onCardSelect: P,
128
- onActivateCard: h
121
+ W.data?.data,
122
+ _.untitledFundingAccount,
123
+ w.canReadFundingAccounts
124
+ ]), K = U && W.isError, je = U && !K && (W.isLoading || W.isFetchingNextPage || !!W.hasNextPage), q = o(() => T ? c === r.Credit ? ce(B.data?.data ?? []) : le(V.data?.data ?? []) : [], [
125
+ T,
126
+ c,
127
+ B.data?.data,
128
+ V.data?.data
129
+ ]), Me = o(() => se(q, {
130
+ labels: _,
131
+ fundingAccountNames: G,
132
+ canActivate: w.canActivate,
133
+ onCardSelect: F,
134
+ onActivateCard: g
129
135
  }), [
130
- K,
131
- W,
132
- P,
136
+ q,
137
+ G,
138
+ F,
139
+ _,
133
140
  g,
134
- h,
135
- C.canActivate
136
- ]), q = V.data?.nextPaginationToken ?? void 0, J = V.data?.prevPaginationToken ?? void 0, Fe = !!V.data, Y = w && (V.isError || G), X = r((e) => {
137
- k || j({
138
- resetKey: O,
141
+ w.canActivate
142
+ ]), J = H.data?.nextPaginationToken ?? void 0, Y = H.data?.prevPaginationToken ?? void 0, Ne = !!H.data, X = T && (H.isError || K), Z = i((e) => {
143
+ A || M({
144
+ resetKey: k,
139
145
  paginationToken: e.paginationToken,
140
146
  pageSize: e.pageSize
141
- }), f?.(e);
147
+ }), p?.(e);
142
148
  }, [
143
- k,
144
- f,
145
- O
146
- ]), Z = r(() => {
147
- X({
149
+ A,
150
+ p,
151
+ k
152
+ ]), Q = i(() => {
153
+ Z({
148
154
  paginationToken: void 0,
149
- pageSize: L
155
+ pageSize: R
150
156
  });
151
- }, [X, L]), Ie = r((e) => {
152
- X({
157
+ }, [Z, R]), Pe = i((e) => {
158
+ Z({
153
159
  paginationToken: void 0,
154
160
  pageSize: e
155
161
  });
156
- }, [X]), Le = r((e) => {
157
- Oe(e), Z();
158
- }, [Z]), Re = r(() => {
159
- X({
160
- paginationToken: J,
161
- pageSize: L
162
+ }, [Z]), Fe = i((e) => {
163
+ Ee(e), Q();
164
+ }, [Q]), Ie = i(() => {
165
+ Z({
166
+ paginationToken: Y,
167
+ pageSize: R
162
168
  });
163
169
  }, [
164
- X,
165
- L,
166
- J
167
- ]), ze = r(() => {
168
- X({
169
- paginationToken: q,
170
- pageSize: L
170
+ Z,
171
+ R,
172
+ Y
173
+ ]), Le = i(() => {
174
+ Z({
175
+ paginationToken: J,
176
+ pageSize: R
171
177
  });
172
178
  }, [
173
- X,
174
- q,
175
- L
176
- ]), Q = V.refetch, $ = U.refetch, Be = r(() => {
177
- Q(), H && $();
179
+ Z,
180
+ J,
181
+ R
182
+ ]), $ = H.refetch, Re = W.refetch, ze = i(() => {
183
+ $(), U && Re();
178
184
  }, [
179
- H,
180
- Q,
181
- $
185
+ U,
186
+ $,
187
+ Re
182
188
  ]);
183
189
  return {
184
- rows: Pe,
185
- selectedCardId: Ae ? null : ke,
186
- onSelectCard: P,
187
- canReadCards: C.canRead,
188
- columns: ce[s],
189
- isLoading: !x && (!S || Ce && !y || w && (V.isLoading || Ne)),
190
- isError: x || Y,
191
- canToggleShowMyCards: C.canRead && !!b,
192
- isShowingMyCards: F,
193
- onShowMyCardsChange: Le,
194
- canCreateCard: C.canCreate && (!!m || !!xe && C.canComposeDebitCreate),
195
- onCreateCardClick: m,
196
- onRetry: Be,
197
- isPaginationVisible: w && Fe && !Y,
198
- pageSize: L,
199
- pageSizeOptions: ge,
200
- isPreviousPageDisabled: !J,
201
- isNextPageDisabled: !q,
202
- onPageSizeChange: Ie,
203
- onPreviousPageClick: Re,
204
- onNextPageClick: ze
190
+ rows: Me,
191
+ selectedCardId: Oe ? null : De,
192
+ onSelectCard: F,
193
+ canReadCards: w.canRead,
194
+ columns: oe[c],
195
+ isLoading: !S && (!C || xe && !b || T && (H.isLoading || je)),
196
+ isError: S || X,
197
+ canToggleShowMyCards: w.canRead && !!x,
198
+ isShowingMyCards: I,
199
+ onShowMyCardsChange: Fe,
200
+ canCreateCard: w.canCreate && (!!h || !!ye && w.canComposeDebitCreate),
201
+ onCreateCardClick: h,
202
+ onRetry: ze,
203
+ isPaginationVisible: T && Ne && !X,
204
+ pageSize: R,
205
+ pageSizeOptions: me,
206
+ isPreviousPageDisabled: !Y,
207
+ isNextPageDisabled: !J,
208
+ onPageSizeChange: Pe,
209
+ onPreviousPageClick: Ie,
210
+ onNextPageClick: Le
205
211
  };
206
212
  }
207
213
  //#endregion
208
- export { u as useCardsWidget };
214
+ export { d as useCardsWidget };
@@ -28,7 +28,7 @@ function c({ row: e, labels: t }) {
28
28
  })
29
29
  ]
30
30
  }), /* @__PURE__ */ o("span", {
31
- className: "ttw:truncate ttw:text-xs ttw:leading-none ttw:text-muted-foreground",
31
+ className: "ttw:truncate ttw:text-xs ttw:text-muted-foreground",
32
32
  children: e.typeLabel
33
33
  })]
34
34
  })] });
@@ -42,9 +42,19 @@ function l({ row: i, columns: a, labels: l }) {
42
42
  labels: l
43
43
  })
44
44
  }),
45
- fundingAccount: /* @__PURE__ */ o("span", {
46
- className: "ttw:text-sm ttw:text-foreground",
47
- children: i.fundingAccount
45
+ fundingAccount: /* @__PURE__ */ s("span", {
46
+ className: "ttw:flex ttw:min-w-0 ttw:items-baseline ttw:gap-1 ttw:text-sm",
47
+ children: [/* @__PURE__ */ o("span", {
48
+ className: "ttw:truncate ttw:text-foreground",
49
+ children: i.fundingAccount
50
+ }), i.fundingAccountLastFour && /* @__PURE__ */ s("span", {
51
+ className: "ttw:shrink-0 ttw:text-muted-foreground",
52
+ children: [
53
+ l.cardNameSeparator,
54
+ " ",
55
+ i.fundingAccountLastFour
56
+ ]
57
+ })]
48
58
  }),
49
59
  cardholder: /* @__PURE__ */ o("span", {
50
60
  className: "ttw:text-sm ttw:text-foreground",
@@ -21,7 +21,7 @@ var t = {
21
21
  noLimit: "No limit",
22
22
  loadingLabel: "Loading cards",
23
23
  emptyTitle: "No cards created yet",
24
- emptyDescription: "No cards have been created yet. Click the Create card button to create your first physical or digital, debit or credit card.",
24
+ emptyDescription: "No cards have been created yet. Click the Create card button to create your first physical or virtual, debit or credit card.",
25
25
  errorTitle: "Unable to load cards",
26
26
  errorDescription: "Something went wrong while fetching your cards. Please try again.",
27
27
  retryButton: "Try again",
@@ -22,15 +22,9 @@ function _({ cardArtSrc: _, labels: v, cardholderOptions: y, selectedCardholder:
22
22
  children: [/* @__PURE__ */ g("section", {
23
23
  className: "ttw:flex ttw:flex-col ttw:gap-4",
24
24
  children: [
25
- /* @__PURE__ */ g("div", {
26
- className: "ttw:flex ttw:flex-col ttw:gap-1",
27
- children: [/* @__PURE__ */ h("h3", {
28
- className: "ttw:text-base ttw:font-semibold ttw:text-foreground",
29
- children: v.setup.sectionTitle
30
- }), /* @__PURE__ */ h("p", {
31
- className: "ttw:text-sm ttw:text-muted-foreground",
32
- children: v.setup.sectionDescription
33
- })]
25
+ /* @__PURE__ */ h("h3", {
26
+ className: "ttw:text-base ttw:font-semibold ttw:text-foreground",
27
+ children: v.setup.sectionTitle
34
28
  }),
35
29
  /* @__PURE__ */ g("div", {
36
30
  className: "ttw:flex ttw:flex-col ttw:gap-1.5",
@@ -7,7 +7,6 @@ var e = {
7
7
  cardArtAlt: "Card preview",
8
8
  setup: {
9
9
  sectionTitle: "Set up your card",
10
- sectionDescription: "Please select an enrolled employee to issue a card to. To invite an employee to enroll, please navigate to the Team Members menu.",
11
10
  cardholderLabel: "Cardholder",
12
11
  cardholderPlaceholder: "Select team member",
13
12
  cardFormatLabel: "Card format",
@@ -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.2.300", n = "986204d04df1d87a219a5953e8c66f7129b9c947", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.2.301", n = "3745b6c37a62bf69fca31e244d989621f1882a80", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -10,7 +10,7 @@ var e = {
10
10
  LOCKED: "Frozen",
11
11
  CLOSED: "Closed"
12
12
  }, n = {
13
- DIGITAL: "Digital",
13
+ DIGITAL: "Virtual",
14
14
  PHYSICAL: "Physical"
15
15
  };
16
16
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.2.300",
3
+ "version": "0.2.301",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {