@tesouro/embedded-components-react 0.7.70 → 0.7.72

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 (22) hide show
  1. package/README.md +14 -11
  2. package/dist/index.css +15 -6
  3. package/dist/index.d.ts +64 -2
  4. package/dist/lib/LinkedAccountsWidget.d.ts +9 -0
  5. package/dist/lib/TransfersWidget.d.ts +55 -2
  6. package/dist/lib/WidgetSuite.d.ts +63 -1
  7. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/lib/LinkedAccountsWidget.js +6 -4
  8. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/lib/useLinkedAccountsWidget.js +199 -182
  9. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  10. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetFeature.js +4 -3
  11. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetInner.js +99 -108
  12. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/testIds.js +2 -0
  13. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/transferViews.js +135 -0
  14. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/useTransferMoneyModalController.js +140 -153
  15. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransferAccountTile.js +15 -0
  16. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransferDetailSheet.js +111 -0
  17. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransferStatusBadge.js +18 -0
  18. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransfersWidget.js +181 -126
  19. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/labels.js +33 -0
  20. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/TransfersSection.js +16 -8
  21. package/dist/packages/shared-ui-shadcn/dist/index.js +328 -327
  22. package/package.json +1 -1
@@ -1,143 +1,198 @@
1
- import { Button as e, Skeleton as t, Typography as n } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { PaginationFooter as r } from "../../../../../shared/ui/dist/lib/PaginationFooter/PaginationFooter.js";
3
- import { WidgetTitleWithIconAndChildren as i } from "../../../../../shared/ui/dist/lib/WidgetTitleWithIconAndChildren/WidgetTitleWithIconAndChildren.js";
1
+ import { Badge as e, Button as t, DataTable as n, Skeleton as r, Typography as i, cn as a } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { PaginationFooter as o } from "../../../../../shared/ui/dist/lib/PaginationFooter/PaginationFooter.js";
3
+ import { WidgetTitleWithIconAndChildren as s } from "../../../../../shared/ui/dist/lib/WidgetTitleWithIconAndChildren/WidgetTitleWithIconAndChildren.js";
4
4
  import "../../../../../shared/ui/dist/index.js";
5
- import { TRANSFERS_WIDGET_LABELS_EN as a } from "./labels.js";
6
- import { TransferMoneyModal as o } from "../TransferMoneyModal/TransferMoneyModal.js";
7
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
8
- import { ArrowDownToLine as u, ArrowDownUp as d, ArrowUpFromLine as f } from "lucide-react";
5
+ import { TRANSFERS_WIDGET_LABELS_EN as c } from "./labels.js";
6
+ import { TransferMoneyModal as l } from "../TransferMoneyModal/TransferMoneyModal.js";
7
+ import { TransferStatusBadge as u } from "./TransferStatusBadge.js";
8
+ import { TransferDetailSheet as d } from "./TransferDetailSheet.js";
9
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
10
+ import { ArrowDownToLine as h, ArrowDownUp as g } from "lucide-react";
9
11
  //#region ../../libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransfersWidget.js
10
- function p({ transferRows: p, isLoading: m, isError: h, onRetry: g, showTransferMoneyCta: _, isTransferMoneyCtaDisabled: v = !1, onTransferMoneyClick: y, transferMoneyModal: b, pagination: x, labels: S, testIds: C }) {
11
- let w = {
12
- ...a,
13
- ...S
14
- }, T = x ? /* @__PURE__ */ c(r, {
15
- ...x,
12
+ var _ = [], v = () => void 0;
13
+ function y({ transferRows: e, isLoading: y, isError: x, onRetry: S, showTransferMoneyCta: C, isTransferMoneyCtaDisabled: w = !1, onTransferMoneyClick: T, transferMoneyModal: E, pagination: D, selectedRowKey: O, onRowClick: k, transferDetail: A, onTransferDetailClose: j, onLinkAccountClick: M, labels: N, testIds: P }) {
14
+ let F = {
15
+ ...c,
16
+ ...N
17
+ }, I = [
18
+ {
19
+ id: "date",
20
+ header: F.tableHeaderDate,
21
+ cell: ({ row: e }) => /* @__PURE__ */ p("span", {
22
+ className: "ttw:font-normal ttw:text-muted-foreground",
23
+ children: e.original.dateLabel
24
+ })
25
+ },
26
+ {
27
+ id: "from",
28
+ header: F.transferFromLabel,
29
+ cell: ({ row: e }) => /* @__PURE__ */ p(b, { account: e.original.from })
30
+ },
31
+ {
32
+ id: "to",
33
+ header: F.transferToLabel,
34
+ cell: ({ row: e }) => /* @__PURE__ */ p(b, { account: e.original.to })
35
+ },
36
+ {
37
+ id: "status",
38
+ header: F.tableHeaderStatus,
39
+ cell: ({ row: e }) => /* @__PURE__ */ m("div", {
40
+ className: "ttw:flex ttw:flex-col ttw:items-start ttw:gap-1",
41
+ children: [/* @__PURE__ */ p(u, {
42
+ label: e.original.statusLabel,
43
+ tone: e.original.statusTone
44
+ }), e.original.statusReasonLabel ? /* @__PURE__ */ p("span", {
45
+ className: "ttw:text-xs ttw:font-normal ttw:text-muted-foreground",
46
+ children: e.original.statusReasonLabel
47
+ }) : null]
48
+ })
49
+ },
50
+ {
51
+ id: "amount",
52
+ header: () => /* @__PURE__ */ p("span", {
53
+ className: "ttw:block ttw:text-right",
54
+ children: F.tableHeaderAmount
55
+ }),
56
+ cell: ({ row: e }) => /* @__PURE__ */ p("span", {
57
+ className: a("ttw:block ttw:text-right ttw:font-semibold ttw:tabular-nums", e.original.isAmountStruckThrough && "ttw:line-through"),
58
+ children: e.original.amountLabel
59
+ })
60
+ }
61
+ ], L = k ? {
62
+ onRowClick: (e) => k(e.rowKey),
63
+ rowAriaLabel: (e) => e.ariaLabel
64
+ } : {}, R = D ? /* @__PURE__ */ p(o, {
65
+ ...D,
16
66
  labels: {
17
- rowsPerPageLabel: w.paginationRowsPerPage,
18
- previousPageButton: w.paginationPreviousPage,
19
- nextPageButton: w.paginationNextPage
67
+ rowsPerPageLabel: F.paginationRowsPerPage,
68
+ previousPageButton: F.paginationPreviousPage,
69
+ nextPageButton: F.paginationNextPage
20
70
  }
21
- }) : null, E = _ && !m ? /* @__PURE__ */ c("span", {
71
+ }) : null, z = C && !y ? /* @__PURE__ */ p("span", {
22
72
  className: "ttw:inline-flex ttw:shrink-0",
23
- title: v ? w.transferMoneyCtaDisabledTooltip : void 0,
24
- children: /* @__PURE__ */ l(e, {
73
+ title: w ? F.transferMoneyCtaDisabledTooltip : void 0,
74
+ children: /* @__PURE__ */ m(t, {
25
75
  type: "button",
26
76
  size: "sm",
27
77
  variant: "default",
28
78
  className: "ttw:inline-flex ttw:shrink-0 ttw:gap-2 ttw:whitespace-nowrap",
29
- disabled: v,
30
- onClick: v ? void 0 : y,
31
- "data-testid": C?.transferMoneyButton,
32
- children: [/* @__PURE__ */ c(u, {
79
+ disabled: w,
80
+ onClick: w ? void 0 : T,
81
+ "data-testid": P?.transferMoneyButton,
82
+ children: [/* @__PURE__ */ p(h, {
33
83
  className: "ttw:size-4",
34
84
  "aria-hidden": !0
35
- }), w.transferMoneyCta]
85
+ }), F.transferMoneyCta]
36
86
  })
37
87
  }) : void 0;
38
- return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(i, {
39
- icon: /* @__PURE__ */ c(d, {
40
- className: "ttw:size-[18px] ttw:shrink-0 ttw:text-primary",
41
- "aria-hidden": !0
88
+ return /* @__PURE__ */ m(f, { children: [
89
+ /* @__PURE__ */ p(s, {
90
+ icon: /* @__PURE__ */ p(g, {
91
+ className: "ttw:size-[18px] ttw:shrink-0 ttw:text-primary",
92
+ "aria-hidden": !0
93
+ }),
94
+ title: F.widgetTitle,
95
+ headerActions: z,
96
+ children: y ? /* @__PURE__ */ p(r, {
97
+ "data-testid": P?.skeleton,
98
+ height: 120,
99
+ width: "100%",
100
+ className: "ttw:rounded-md"
101
+ }) : x ? /* @__PURE__ */ m("div", {
102
+ className: "ttw:flex ttw:flex-col ttw:gap-3",
103
+ "data-testid": P?.error,
104
+ children: [
105
+ /* @__PURE__ */ p(i, {
106
+ component: "p",
107
+ variant: "body1",
108
+ className: "ttw:font-semibold",
109
+ children: F.loadErrorTitle
110
+ }),
111
+ /* @__PURE__ */ p(i, {
112
+ component: "p",
113
+ variant: "body2",
114
+ color: "muted",
115
+ children: F.loadErrorDescription
116
+ }),
117
+ S ? /* @__PURE__ */ p(t, {
118
+ type: "button",
119
+ variant: "outline",
120
+ size: "sm",
121
+ className: "ttw:self-start ttw:cursor-pointer",
122
+ onClick: S,
123
+ "data-testid": P?.retry,
124
+ children: F.loadErrorRetry
125
+ }) : null
126
+ ]
127
+ }) : e.length === 0 ? /* @__PURE__ */ m("div", {
128
+ className: "ttw:flex ttw:flex-col ttw:gap-2",
129
+ "data-testid": P?.empty,
130
+ children: [
131
+ /* @__PURE__ */ p(i, {
132
+ variant: "body1",
133
+ className: "ttw:font-semibold",
134
+ children: F.emptyTitle
135
+ }),
136
+ /* @__PURE__ */ p(i, {
137
+ variant: "body2",
138
+ color: "muted",
139
+ component: "p",
140
+ children: F.emptyDescription
141
+ }),
142
+ D && !D.isPreviousDisabled ? R : null
143
+ ]
144
+ }) : /* @__PURE__ */ m("div", {
145
+ className: "ttw:flex ttw:flex-col",
146
+ children: [/* @__PURE__ */ p(n, {
147
+ columns: I,
148
+ data: e,
149
+ getRowId: (e) => e.rowKey,
150
+ rowTestId: P?.transferRow,
151
+ rowClassName: (e) => e.rowKey === O ? "ttw:bg-muted ttw:shadow-[inset_3px_0_0_var(--color-primary)]" : void 0,
152
+ ...L,
153
+ showPagination: !1,
154
+ sorting: _,
155
+ onSortingChange: v,
156
+ pageSize: e.length,
157
+ pageSizeOptions: D?.pageSizeOptions ?? [],
158
+ onPageSizeChange: v,
159
+ onNextPage: v,
160
+ onPrevPage: v
161
+ }), R]
162
+ })
42
163
  }),
43
- title: w.widgetTitle,
44
- headerActions: E,
45
- children: m ? /* @__PURE__ */ c(t, {
46
- "data-testid": C?.skeleton,
47
- height: 120,
48
- width: "100%",
49
- className: "ttw:rounded-md"
50
- }) : h ? /* @__PURE__ */ l("div", {
51
- className: "ttw:flex ttw:flex-col ttw:gap-3",
52
- "data-testid": C?.error,
53
- children: [
54
- /* @__PURE__ */ c(n, {
55
- component: "p",
56
- variant: "body1",
57
- className: "ttw:font-semibold",
58
- children: w.loadErrorTitle
59
- }),
60
- /* @__PURE__ */ c(n, {
61
- component: "p",
62
- variant: "body2",
63
- color: "muted",
64
- children: w.loadErrorDescription
65
- }),
66
- g ? /* @__PURE__ */ c(e, {
67
- type: "button",
68
- variant: "outline",
69
- size: "sm",
70
- className: "ttw:self-start ttw:cursor-pointer",
71
- onClick: g,
72
- "data-testid": C?.retry,
73
- children: w.loadErrorRetry
74
- }) : null
75
- ]
76
- }) : p.length === 0 ? /* @__PURE__ */ l("div", {
77
- className: "ttw:flex ttw:flex-col ttw:gap-2",
78
- "data-testid": C?.empty,
79
- children: [
80
- /* @__PURE__ */ c(n, {
81
- variant: "body1",
82
- className: "ttw:font-semibold",
83
- children: w.emptyTitle
84
- }),
85
- /* @__PURE__ */ c(n, {
86
- variant: "body2",
87
- color: "muted",
88
- component: "p",
89
- children: w.emptyDescription
90
- }),
91
- x && !x.isPreviousDisabled ? T : null
92
- ]
93
- }) : /* @__PURE__ */ l("div", {
94
- className: "ttw:max-w-full ttw:overflow-x-auto ttw:rounded-md ttw:border ttw:border-border",
95
- children: [/* @__PURE__ */ c("div", {
96
- className: "ttw:min-w-[24rem] ttw:max-h-96 ttw:overflow-y-auto",
97
- children: /* @__PURE__ */ c("ul", {
98
- className: "ttw:m-0 ttw:list-none ttw:divide-y ttw:divide-border ttw:p-0",
99
- children: p.map((e) => /* @__PURE__ */ l("li", {
100
- title: e.detailLabel,
101
- "data-testid": C?.transferRow,
102
- className: "ttw:grid ttw:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] ttw:items-center ttw:gap-3 ttw:px-4 ttw:py-4",
103
- children: [
104
- /* @__PURE__ */ l("div", {
105
- className: "ttw:flex ttw:min-w-0 ttw:items-center ttw:gap-3",
106
- children: [/* @__PURE__ */ c("div", {
107
- className: "ttw:flex ttw:size-9 ttw:shrink-0 ttw:items-center ttw:justify-center ttw:rounded-full ttw:bg-primary/10",
108
- children: /* @__PURE__ */ c(f, {
109
- className: "ttw:size-4 ttw:text-primary",
110
- "aria-hidden": !0
111
- })
112
- }), /* @__PURE__ */ c(n, {
113
- variant: "body2",
114
- component: "p",
115
- className: "ttw:min-w-0 ttw:truncate ttw:font-medium",
116
- children: e.accountsRouteLabel
117
- })]
118
- }),
119
- /* @__PURE__ */ c(n, {
120
- variant: "body2",
121
- component: "p",
122
- color: "muted",
123
- className: "ttw:shrink-0 ttw:text-center",
124
- children: e.dateLabel
125
- }),
126
- /* @__PURE__ */ c(n, {
127
- variant: "body2",
128
- component: "p",
129
- className: "ttw:justify-self-end ttw:shrink-0 ttw:font-semibold ttw:tabular-nums",
130
- children: e.amountLabel
131
- })
132
- ]
133
- }, e.rowKey))
134
- })
135
- }), T]
164
+ /* @__PURE__ */ p(l, {
165
+ ...E,
166
+ labels: F
167
+ }),
168
+ /* @__PURE__ */ p(d, {
169
+ detail: A,
170
+ onClose: j,
171
+ onLinkAccountClick: M,
172
+ labels: F,
173
+ testIds: P?.transferDetail
136
174
  })
137
- }), /* @__PURE__ */ c(o, {
138
- ...b,
139
- labels: w
140
- })] });
175
+ ] });
176
+ }
177
+ function b({ account: t }) {
178
+ return /* @__PURE__ */ m("div", {
179
+ title: t.kindLabel,
180
+ className: "ttw:flex ttw:min-w-0 ttw:items-center ttw:gap-2",
181
+ children: [
182
+ /* @__PURE__ */ p("span", {
183
+ className: "ttw:truncate",
184
+ children: t.name
185
+ }),
186
+ t.maskLabel ? /* @__PURE__ */ p("span", {
187
+ className: "ttw:shrink-0 ttw:font-normal ttw:text-muted-foreground",
188
+ children: t.maskLabel
189
+ }) : null,
190
+ t.badgeLabel ? /* @__PURE__ */ p(e, {
191
+ variant: "secondary",
192
+ children: t.badgeLabel
193
+ }) : null
194
+ ]
195
+ });
141
196
  }
142
197
  //#endregion
143
- export { a as TRANSFERS_WIDGET_LABELS_EN, p as TransfersWidget };
198
+ export { c as TRANSFERS_WIDGET_LABELS_EN, y as TransfersWidget };
@@ -7,6 +7,38 @@ var e = {
7
7
  embeddedAccountMaskPrefix: "••••",
8
8
  modalReviewAccountNumberPrefix: "Account #:",
9
9
  listAccountsSeparator: " → ",
10
+ tableHeaderDate: "Date",
11
+ tableHeaderStatus: "Status",
12
+ tableHeaderAmount: "Amount",
13
+ transferFromLabel: "From",
14
+ transferToLabel: "To",
15
+ rowAriaLabel: "View transfer of {amount} from {from} to {to}",
16
+ accountKindInternal: "Bank account",
17
+ accountKindExternal: "External account",
18
+ externalAccountBadge: "External",
19
+ externalAccountFallbackName: "External account",
20
+ accountMaskTemplate: "- {last4}",
21
+ detailTitle: "Transfer details",
22
+ detailClose: "Close",
23
+ detailInitiatedByLabel: "Initiated by",
24
+ detailInitiatedOnLabel: "Initiated on",
25
+ returnShortReasonAccountClosed: "Account closed",
26
+ returnShortReasonInvalidAccountDetails: "Account details don't match",
27
+ returnShortReasonAccountCannotReceive: "Account can't receive transfers",
28
+ returnShortReasonRefusedByReceiver: "Declined by recipient",
29
+ returnedTitleAccountClosed: "Returned: account closed",
30
+ returnedTitleInvalidAccountDetails: "Returned: account details don't match",
31
+ returnedTitleAccountCannotReceive: "Returned: account can't receive transfers",
32
+ returnedTitleRefusedByReceiver: "Returned: declined by recipient",
33
+ returnedTitleGeneric: "Returned",
34
+ returnedExplanationAccountClosed: "The receiving bank reported that this account is closed.",
35
+ returnedExplanationInvalidAccountDetails: "The receiving bank couldn't find an account matching the routing or account number provided.",
36
+ returnedExplanationAccountCannotReceive: "The receiving bank reported that this account isn't set up to accept this type of transfer.",
37
+ returnedExplanationRefusedByReceiver: "The recipient's bank declined this transfer at the account holder's request.",
38
+ returnedExplanationGeneric: "The receiving bank returned this transfer.",
39
+ returnedRefundSentence: "{amount} has been refunded to {account}.",
40
+ returnedPausedSentence: "Transfers to {account} are paused. To keep sending money here, link the account again.",
41
+ returnedLinkAccountCta: "Link a new account",
10
42
  loadErrorTitle: "We could not load transfers",
11
43
  loadErrorDescription: "Check your connection and try again. If the problem continues, contact support.",
12
44
  loadErrorRetry: "Try again",
@@ -50,6 +82,7 @@ var e = {
50
82
  rowStatusCompleted: "Completed",
51
83
  rowStatusPending: "Pending",
52
84
  rowStatusFailed: "Failed",
85
+ rowStatusReturned: "Returned",
53
86
  rowTypeInternal: "Internal",
54
87
  rowTypeToExternal: "To external",
55
88
  rowTypeFromExternal: "From external",
@@ -10,18 +10,26 @@ import { LinkedAccountsWidget as r } from "../../../../../../linked-accounts-wid
10
10
  import "../../../../../../linked-accounts-widget/feature/dist/index.js";
11
11
  import { TransfersWidget as i } from "../../../../../../transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetFeature.js";
12
12
  import "../../../../../../transfers-widget/feature/dist/index.js";
13
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
13
+ import { useState as a } from "react";
14
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
14
15
  //#region ../../libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/TransfersSection.js
15
- function s() {
16
- let { grantedScopes: s, labels: c } = e(), l = t(s, [n.ExternalBankAccountReadOrg]);
17
- return /* @__PURE__ */ o("div", {
16
+ function c() {
17
+ let { grantedScopes: c, labels: l } = e(), u = t(c, [n.ExternalBankAccountReadOrg]), d = u && t(c, [n.ExternalBankAccountWriteOrg]), [f, p] = a(!1);
18
+ return /* @__PURE__ */ s("div", {
18
19
  className: "ttw:grid ttw:gap-4",
19
- children: [l && /* @__PURE__ */ a(r, { ...c.sections.linkedAccounts }), /* @__PURE__ */ a(i, { ...c.sections.transfers })]
20
+ children: [u && /* @__PURE__ */ o(r, {
21
+ ...l.sections.linkedAccounts,
22
+ isLinkAccountOpen: f,
23
+ onLinkAccountOpenChange: p
24
+ }), /* @__PURE__ */ o(i, {
25
+ ...l.sections.transfers,
26
+ onLinkAccountClick: d ? () => p(!0) : void 0
27
+ })]
20
28
  });
21
29
  }
22
- var c = {
30
+ var l = {
23
31
  anyOfScopes: [n.BankAccountReadOrg],
24
- Content: s
32
+ Content: c
25
33
  };
26
34
  //#endregion
27
- export { s as TransfersSection, c as transfersSection };
35
+ export { c as TransfersSection, l as transfersSection };