@tesouro/embedded-components-react 0.2.256 → 0.2.257

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 +19 -0
  2. package/dist/index.d.ts +127 -111
  3. package/dist/index.js +42 -38
  4. package/dist/lib/CardsWidget.d.ts +4 -5
  5. package/dist/lib/CreateCardWidget.d.ts +686 -0
  6. package/dist/lib/CreateCardWidget.js +5 -0
  7. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index.js +5 -0
  8. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index2.js +13 -0
  9. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index3.js +12 -0
  10. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index4.js +29 -0
  11. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index5.js +22 -0
  12. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index.js +4 -0
  13. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index2.js +4 -0
  14. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index3.js +56 -0
  15. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index4.js +31 -0
  16. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index5.js +16 -0
  17. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index6.js +52 -0
  18. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index7.js +200 -0
  19. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/index.js +4 -0
  20. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/CardArt.js +12 -0
  21. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/CreateCardWidget.js +99 -0
  22. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/ManualAddressFields.js +67 -0
  23. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/PreparingView.js +31 -0
  24. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/SetupView.js +172 -0
  25. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/SuccessView.js +50 -0
  26. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/labels.js +103 -0
  27. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/types.js +11 -0
  28. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +16 -16
  29. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +169 -151
  30. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +141 -113
  31. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  32. package/dist/pending-feature-style-sources.d.ts +1 -2
  33. package/package.json +1 -1
@@ -0,0 +1,5 @@
1
+ import { useCreateCard as e } from "./index2.js";
2
+ import "./index3.js";
3
+ import { useCreateDebitCardMutation as t } from "./index4.js";
4
+ import { useCreateCardOrganizationQuery as n } from "./index5.js";
5
+ export { e as useCreateCard, n as useCreateCardOrganizationQuery, t as useCreateDebitCardMutation };
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
+ import "../../../shared/data-access/dist/index.js";
7
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index2.js
8
+ function t() {
9
+ let { organizationId: t, widgetToken: n } = e();
10
+ return { isReady: !!(t && n) };
11
+ }
12
+ //#endregion
13
+ export { t as useCreateCard };
@@ -0,0 +1,12 @@
1
+ import { organizationHeaders as e } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
2
+ import { getDebitCardsQueryKey as t } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
3
+ import "../../../shared/data-access/dist/index.js";
4
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index3.js
5
+ function n({ client: n, organizationId: r }) {
6
+ return t({
7
+ client: n,
8
+ headers: e(r)
9
+ });
10
+ }
11
+ //#endregion
12
+ export { n as debitCardsInvalidationKey };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { invalidateAllClients as e } from "../../../shared/data-access/dist/lib/clientRegistry.js";
6
+ import { useEmbedApi as t } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
7
+ import { organizationHeaders as n } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
8
+ import { createDebitCardMutation as r } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
9
+ import "../../../shared/data-access/dist/index.js";
10
+ import { debitCardsInvalidationKey as i } from "./index3.js";
11
+ import { useMutation as a } from "@tanstack/react-query";
12
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index4.js
13
+ function o() {
14
+ let { client: o, organizationId: s } = t(), c = n(s), l = r({
15
+ client: o,
16
+ headers: c
17
+ });
18
+ return a({
19
+ ...l,
20
+ onSuccess: async (...t) => {
21
+ await e(i({
22
+ client: o,
23
+ organizationId: s
24
+ })), await l.onSuccess?.(...t);
25
+ }
26
+ });
27
+ }
28
+ //#endregion
29
+ export { o as useCreateDebitCardMutation };
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
+ import { getOrganizationOptions as t } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
7
+ import { withAuthEpoch as n } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
8
+ import "../../../shared/data-access/dist/index.js";
9
+ import { useQuery as r } from "@tanstack/react-query";
10
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index5.js
11
+ function i({ enabled: i } = {}) {
12
+ let { client: a, organizationId: o, widgetToken: s, authEpoch: c } = e(), l = t({
13
+ client: a,
14
+ path: { organizationId: o ?? "" }
15
+ });
16
+ return r({
17
+ ...n(l, c),
18
+ enabled: !!(o && s) && (i === !0 || i === void 0)
19
+ });
20
+ }
21
+ //#endregion
22
+ export { i as useCreateCardOrganizationQuery };
@@ -0,0 +1,4 @@
1
+ import { CardFormatValue as e } from "./index3.js";
2
+ import { CREATE_CARD_FEATURE_LABELS_EN as t, resolveCreateCardFeatureLabels as n } from "./index4.js";
3
+ import { CreateCardWidget as r } from "./index7.js";
4
+ export { t as CREATE_CARD_FEATURE_LABELS_EN, e as CardFormatValue, r as CreateCardWidget, n as resolveCreateCardFeatureLabels };
@@ -0,0 +1,4 @@
1
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index2.js
2
+ var e = { Mounted: "create_card.mounted" }, t = "create_card";
3
+ //#endregion
4
+ export { e as CreateCardWidgetAnalyticsEvent, t as WIDGET_NAME };
@@ -0,0 +1,56 @@
1
+ import { MailingOptionValue as e } from "../../ui/dist/lib/CreateCardWidget/types.js";
2
+ import "../../ui/dist/index.js";
3
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index3.js
4
+ var t = {
5
+ Virtual: "virtual",
6
+ Physical: "physical"
7
+ };
8
+ function n(e) {
9
+ if (e === t.Virtual) return "DIGITAL";
10
+ if (e === t.Physical) return "PHYSICAL";
11
+ }
12
+ function r(e) {
13
+ return e ? [[e.address1, e.address2].map((e) => e?.trim()).filter(Boolean).join(", "), [e.city?.trim(), [e.stateOrProvince?.trim(), e.postalCode?.trim()].filter(Boolean).join(" ")].filter(Boolean).join(", ")].filter(Boolean).join(", ") : "";
14
+ }
15
+ function i(e) {
16
+ if (e?.address1?.trim()) return {
17
+ address1: e.address1.trim(),
18
+ address2: e.address2?.trim() || void 0,
19
+ city: e.city?.trim() || void 0,
20
+ state: e.stateOrProvince?.trim() || void 0,
21
+ postalCode: e.postalCode?.trim() || void 0,
22
+ countryCode: "USA"
23
+ };
24
+ }
25
+ function a(e) {
26
+ if (!(!e.street.trim() || !e.city.trim() || !e.state.trim() || !e.zip.trim())) return {
27
+ address1: e.street.trim(),
28
+ city: e.city.trim(),
29
+ state: e.state.trim(),
30
+ postalCode: e.zip.trim(),
31
+ countryCode: "USA"
32
+ };
33
+ }
34
+ function o(e) {
35
+ return !!(e.street.trim() && e.city.trim() && e.state.trim() && e.zip.trim());
36
+ }
37
+ function s(e) {
38
+ return !!i(e);
39
+ }
40
+ function c({ cardholderUserId: t, format: r, bankAccountId: o, reference: s, mailingOption: c, orgAddress: l, manualAddress: u }) {
41
+ let d = n(r);
42
+ if (!t || !d || !o) return;
43
+ let f;
44
+ if (!(d === "PHYSICAL" && (c === e.BusinessAddress ? f = i(l) : c === e.DifferentAddress && (f = a(u)), !f))) return {
45
+ bankAccountId: o,
46
+ cardType: d,
47
+ reference: s,
48
+ cardholderUserId: t,
49
+ ...f ? { shippingAddress: f } : {}
50
+ };
51
+ }
52
+ function l() {
53
+ return crypto.randomUUID().replace(/-/g, "").slice(0, 50);
54
+ }
55
+ //#endregion
56
+ export { t as CardFormatValue, i as addressDtoToShippingAddress, c as buildCreateDebitCardRequest, l as createDebitCardReference, r as formatBusinessAddress, s as isBusinessAddressComplete, o as isManualAddressComplete, a as manualAddressToShippingAddress, n as toDebitCardType };
@@ -0,0 +1,31 @@
1
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index4.js
2
+ var e = {
3
+ toast: {
4
+ creating: "Creating your card…",
5
+ success: "Card created successfully.",
6
+ error: "We could not create this card. Please try again."
7
+ },
8
+ untitledFundingAccount: "Bank account",
9
+ success: {
10
+ pendingActivationTitle: "Card created",
11
+ pendingActivationDescription: "Your card needs to be activated before it can be used.",
12
+ createdTitle: "Card created",
13
+ createdDescription: "Your card has been created."
14
+ }
15
+ };
16
+ function t(t) {
17
+ return {
18
+ ...e,
19
+ ...t,
20
+ toast: {
21
+ ...e.toast,
22
+ ...t?.toast
23
+ },
24
+ success: {
25
+ ...e.success,
26
+ ...t?.success
27
+ }
28
+ };
29
+ }
30
+ //#endregion
31
+ export { e as CREATE_CARD_FEATURE_LABELS_EN, t as resolveCreateCardFeatureLabels };
@@ -0,0 +1,16 @@
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
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index5.js
5
+ function n(n) {
6
+ let r = new Set(n ?? []);
7
+ return {
8
+ canIssue: e(r, [t.DebitCardIssueOrg]),
9
+ canReadUsers: e(r, [t.UserReadOrg]),
10
+ canReadRoles: e(r, [t.RoleReadOrg]),
11
+ canReadFundingAccounts: e(r, [t.BankAccountReadOrg]),
12
+ canReadOrganization: e(r, [t.OrganizationReadOrg])
13
+ };
14
+ }
15
+ //#endregion
16
+ export { n as getCreateCardPermissions };
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { Scope as e } from "../../../shared/data-access/dist/lib/scopes.js";
6
+ import { useAllOrganizationRolesQuery as t } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
7
+ import { useRolePermissionsQueries as n } from "../../../shared/data-access/dist/lib/role/useRolePermissionsQueries.js";
8
+ import { useAllOrganizationUsersQuery as r } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
9
+ import "../../../shared/data-access/dist/index.js";
10
+ import { useCallback as i, useMemo as a } from "react";
11
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index6.js
12
+ var o = e.DebitCardReadOrg;
13
+ function s(e) {
14
+ let t = e.name?.trim(), n = e.email?.trim();
15
+ return t && n ? `${t} (${n})` : t || n || e.id;
16
+ }
17
+ function c({ enabled: e = !0 } = {}) {
18
+ let c = r({ enabled: e }), l = t({ enabled: e }), u = c.data?.data, d = l.data?.data, f = a(() => (d ?? []).map((e) => e.id), [d]), p = n({
19
+ roleIds: f,
20
+ enabled: e && !l.isResolving
21
+ }), m = c.refetch, h = l.refetch, g = p.refetch, _ = e && (c.isResolving || l.isResolving || p.isResolving), v = p.byRoleId, y = a(() => {
22
+ if (!e || _) return [];
23
+ let t = new Map((d ?? []).filter((e) => e.key?.trim()).map((e) => [e.key.trim().toLowerCase(), e])), n = (e) => !!v.get(e)?.has(o);
24
+ return [...u ?? []].filter((e) => {
25
+ let r = t.get(e.role?.trim().toLowerCase() ?? "");
26
+ return !!(r && n(r.id));
27
+ }).sort((e, t) => e.name.localeCompare(t.name)).map((e) => ({
28
+ value: e.id,
29
+ label: s(e)
30
+ }));
31
+ }, [
32
+ e,
33
+ _,
34
+ v,
35
+ d,
36
+ u
37
+ ]), b = i(() => {
38
+ m(), h(), g();
39
+ }, [
40
+ g,
41
+ h,
42
+ m
43
+ ]);
44
+ return {
45
+ options: y,
46
+ isResolving: _,
47
+ isError: e && (c.isError || l.isError || p.isError),
48
+ refetch: b
49
+ };
50
+ }
51
+ //#endregion
52
+ export { o as CARDHOLDER_PERMISSION_KEY, s as formatCardholderOptionLabel, c as useCreateCardCardholderOptions };
@@ -0,0 +1,200 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { useAllBankAccountsQuery as t } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
7
+ import "../../../shared/data-access/dist/index.js";
8
+ import { EmbeddedToaster as n } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
9
+ import "../../../shared/ui/dist/index.js";
10
+ import { useAnalyticsTrack as r } from "../../../shared/feature/dist/lib/analytics/hooks.js";
11
+ import { WidgetProvider as ee } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
12
+ import { getStateOptions as i } from "../../../shared/util/dist/lib/usStates.js";
13
+ import { useWidgetConfig as a } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
14
+ import "../../../shared/feature/dist/index.js";
15
+ import { CREATE_CARD_WIDGET_LABELS_EN as o } from "../../ui/dist/lib/CreateCardWidget/labels.js";
16
+ import { CreateCardView as s, MailingOptionValue as c } from "../../ui/dist/lib/CreateCardWidget/types.js";
17
+ import { CreateCardWidget as te } from "../../ui/dist/lib/CreateCardWidget/CreateCardWidget.js";
18
+ import "../../ui/dist/index.js";
19
+ import { CardFormatValue as l, buildCreateDebitCardRequest as ne, createDebitCardReference as re, formatBusinessAddress as ie, isBusinessAddressComplete as ae, isManualAddressComplete as oe } from "./index3.js";
20
+ import { resolveCreateCardFeatureLabels as se } from "./index4.js";
21
+ import { CreateCardWidgetAnalyticsEvent as ce, WIDGET_NAME as u } from "./index2.js";
22
+ import { getCreateCardPermissions as le } from "./index5.js";
23
+ import { useCreateCardCardholderOptions as ue } from "./index6.js";
24
+ import { useCreateCard as de } from "../../data-access/dist/index2.js";
25
+ import { useCreateDebitCardMutation as fe } from "../../data-access/dist/index4.js";
26
+ import { useCreateCardOrganizationQuery as pe } from "../../data-access/dist/index5.js";
27
+ import "../../data-access/dist/index.js";
28
+ import { useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
29
+ import { Fragment as me, jsx as h, jsxs as he } from "react/jsx-runtime";
30
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index7.js
31
+ var g = {
32
+ street: "",
33
+ city: "",
34
+ state: "",
35
+ zip: ""
36
+ }, ge = 3e3, _e = 5e3;
37
+ function ve(e, t) {
38
+ if (e === "PENDING_ACTIVATION") return {
39
+ title: t.success.pendingActivationTitle,
40
+ description: t.success.pendingActivationDescription
41
+ };
42
+ if (e !== null && e !== "ACTIVE") return {
43
+ title: t.success.createdTitle,
44
+ description: t.success.createdDescription
45
+ };
46
+ }
47
+ function _(e) {
48
+ let t = e?.trim().slice(-4);
49
+ return t ? `••••${t}` : void 0;
50
+ }
51
+ function v(e, t) {
52
+ let n = e.nickname?.trim(), r = _(e.accountNumber);
53
+ return n && r ? `${n} (${r})` : n || r || t;
54
+ }
55
+ function y({ cardArtSrc: ee, labels: u, featureLabels: _, className: y, onClose: b, onCancel: ye, onViewCard: x }) {
56
+ let S = r(), { isReady: C } = de(), { initResponse: w, organizationId: T } = a(), E = f(() => le(w?.scopes), [w?.scopes]), D = se(_), O = {
57
+ ...o,
58
+ ...u,
59
+ setup: {
60
+ ...o.setup,
61
+ ...u?.setup
62
+ }
63
+ }, be = f(() => [{
64
+ value: l.Virtual,
65
+ label: O.setup.cardFormatVirtual
66
+ }, {
67
+ value: l.Physical,
68
+ label: O.setup.cardFormatPhysical
69
+ }], [O.setup.cardFormatPhysical, O.setup.cardFormatVirtual]), xe = f(() => i(), []), [Se, k] = m(s.Setup), [A, j] = m(null), [M, N] = m(null), [Ce, P] = m(null), [F, I] = m(null), [L, R] = m(g), [z, B] = m(null), [V, H] = m(null), U = () => {
70
+ j(null), N(null), P(null), I(null), R(g), B(null), H(null), k(s.Setup);
71
+ }, W = p(T);
72
+ T && T !== W.current && (W.current = T, U());
73
+ let G = p(!0);
74
+ d(() => (G.current = !0, () => {
75
+ G.current = !1;
76
+ }), []), d(() => {
77
+ S(ce.Mounted);
78
+ }, [S]);
79
+ let { options: we, isError: K, refetch: Te } = ue({ enabled: C && E.canReadUsers && E.canReadRoles }), Ee = pe({ enabled: C && E.canReadOrganization }), q = t({ enabled: C && E.canReadFundingAccounts }), J = fe(), Y = !!q.isError && C && E.canReadFundingAccounts, X = f(() => Y ? [] : (q.data?.data ?? []).map((e) => ({
80
+ value: e.id,
81
+ label: v(e, D.untitledFundingAccount)
82
+ })), [
83
+ q.data?.data,
84
+ D.untitledFundingAccount,
85
+ Y
86
+ ]), Z = Ce ?? (X.length === 1 ? X[0].value : null), Q = Ee.data?.address, De = ie(Q), Oe = ae(Q), $ = M === l.Physical, ke = $ && F === c.BusinessAddress && !!De, Ae = $ && F === c.DifferentAddress, je = Y || X.length > 0, Me = !C || !E.canIssue || J.isPending || K || Y || !A || !M || !Z || M === l.Physical && (!F || F === c.BusinessAddress && !Oe || F === c.DifferentAddress && !oe(L)), Ne = f(() => {
87
+ let e = ve(V, D);
88
+ return {
89
+ ...u,
90
+ success: {
91
+ ...u?.success,
92
+ ...e
93
+ }
94
+ };
95
+ }, [
96
+ V,
97
+ D,
98
+ u
99
+ ]), Pe = async () => {
100
+ if (!C) return;
101
+ let t = re(), n = ne({
102
+ cardholderUserId: A,
103
+ format: M,
104
+ bankAccountId: Z,
105
+ reference: t,
106
+ mailingOption: F,
107
+ orgAddress: Q,
108
+ manualAddress: L
109
+ });
110
+ if (!n) return;
111
+ k(s.Preparing);
112
+ let r = e.loading(D.toast.creating);
113
+ try {
114
+ let t = await J.mutateAsync({ body: n });
115
+ if (!G.current) {
116
+ e.dismiss(r);
117
+ return;
118
+ }
119
+ B(t.id), H(t.cardStatus), k(s.Success), e.success(D.toast.success, {
120
+ id: r,
121
+ duration: ge
122
+ });
123
+ } catch {
124
+ if (!G.current) {
125
+ e.dismiss(r);
126
+ return;
127
+ }
128
+ k(s.Setup), e.error(D.toast.error, {
129
+ id: r,
130
+ duration: _e
131
+ });
132
+ }
133
+ };
134
+ return /* @__PURE__ */ he(me, { children: [/* @__PURE__ */ h(n, {}), /* @__PURE__ */ h(te, {
135
+ view: Se,
136
+ cardArtSrc: ee,
137
+ labels: Ne,
138
+ className: y,
139
+ cardholderOptions: we,
140
+ selectedCardholder: A,
141
+ onCardholderSelect: j,
142
+ isCardholderError: K,
143
+ onCardholderRetry: K ? Te : void 0,
144
+ cardFormatOptions: be,
145
+ selectedCardFormat: M,
146
+ onCardFormatSelect: (e) => {
147
+ N(e), I(null);
148
+ },
149
+ isFundingAccountVisible: je,
150
+ fundingAccountOptions: X,
151
+ selectedFundingAccount: Z,
152
+ onFundingAccountSelect: P,
153
+ isFundingAccountError: Y,
154
+ onFundingAccountRetry: Y ? () => {
155
+ q.refetch();
156
+ } : void 0,
157
+ isMailingSectionVisible: $,
158
+ selectedMailingOption: F,
159
+ onMailingOptionSelect: I,
160
+ businessAddress: De,
161
+ isBusinessAddressVisible: ke,
162
+ isManualAddressVisible: Ae,
163
+ manualAddress: L,
164
+ onManualAddressChange: (e) => R((t) => ({
165
+ ...t,
166
+ ...e
167
+ })),
168
+ stateOptions: xe,
169
+ isCreateDisabled: Me,
170
+ onCreateClick: () => {
171
+ Pe();
172
+ },
173
+ onCancelClick: () => {
174
+ ye?.(), b?.();
175
+ },
176
+ onClose: b,
177
+ onCreateAnotherClick: U,
178
+ onViewCardClick: x && z ? () => {
179
+ x(z);
180
+ } : void 0
181
+ })] });
182
+ }
183
+ function b({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, linkComponent: i, implementation: a, uiFramework: o, errorFallback: s, onError: c, analytics: te, ...l }) {
184
+ return /* @__PURE__ */ h(ee, {
185
+ widgetName: u,
186
+ baseUrl: e,
187
+ widgetToken: t,
188
+ organizationId: n,
189
+ configClient: r,
190
+ linkComponent: i,
191
+ implementation: a,
192
+ uiFramework: o,
193
+ errorFallback: s,
194
+ onError: c,
195
+ analytics: te,
196
+ children: /* @__PURE__ */ h(y, { ...l })
197
+ });
198
+ }
199
+ //#endregion
200
+ export { b as CreateCardWidget, v as formatFundingAccountLabel };
@@ -0,0 +1,4 @@
1
+ import { CREATE_CARD_WIDGET_LABELS_EN as e } from "./lib/CreateCardWidget/labels.js";
2
+ import { CreateCardView as t, MailingOptionValue as n } from "./lib/CreateCardWidget/types.js";
3
+ import { CreateCardWidget as r } from "./lib/CreateCardWidget/CreateCardWidget.js";
4
+ export { e as CREATE_CARD_WIDGET_LABELS_EN, t as CreateCardView, r as CreateCardWidget, n as MailingOptionValue };
@@ -0,0 +1,12 @@
1
+ import { cn as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/CardArt.js
4
+ function n({ src: n, alt: r, className: i }) {
5
+ return /* @__PURE__ */ t("img", {
6
+ src: n,
7
+ alt: r,
8
+ className: e("ttw:mx-auto ttw:block ttw:h-auto ttw:w-full ttw:max-w-[300px] ttw:rounded-xl ttw:object-cover ttw:shadow-md", i)
9
+ });
10
+ }
11
+ //#endregion
12
+ export { n as CardArt };
@@ -0,0 +1,99 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { Button as e, cn as t } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { resolveCreateCardWidgetLabels as n } from "./labels.js";
7
+ import { CreateCardView as r } from "./types.js";
8
+ import { PreparingView as i } from "./PreparingView.js";
9
+ import { SetupView as a } from "./SetupView.js";
10
+ import { SuccessView as o } from "./SuccessView.js";
11
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
12
+ import { ChevronRightIcon as u, XIcon as d } from "lucide-react";
13
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/CreateCardWidget.js
14
+ var f = {
15
+ street: "",
16
+ city: "",
17
+ state: "",
18
+ zip: ""
19
+ }, p = () => void 0;
20
+ function m(e) {
21
+ return e === r.Setup || e === r.Preparing || e === r.Success ? e : (console.error(`[CreateCardWidget] unexpected view ${JSON.stringify(e)}; falling back to "${r.Setup}"`), r.Setup);
22
+ }
23
+ function h({ view: h, cardArtSrc: g, labels: _, className: v, cardholderOptions: y = [], selectedCardholder: b = null, onCardholderSelect: x = p, isCardholderError: S = !1, onCardholderRetry: C, cardFormatOptions: w = [], selectedCardFormat: T = null, onCardFormatSelect: E = p, isFundingAccountVisible: D = !1, fundingAccountOptions: O = [], selectedFundingAccount: k = null, onFundingAccountSelect: A = p, isFundingAccountError: j = !1, onFundingAccountRetry: M, isMailingSectionVisible: N = !1, selectedMailingOption: P = null, onMailingOptionSelect: F = p, businessAddress: I = "", isBusinessAddressVisible: L = !1, isManualAddressVisible: R = !1, manualAddress: z = f, onManualAddressChange: B = p, stateOptions: V = [], isCreateDisabled: H = !1, onCreateClick: U = p, onCancelClick: W = p, onClose: G, onCreateAnotherClick: K = p, onViewCardClick: q }) {
24
+ let J = n(_), Y = m(h), X = Y === r.Setup;
25
+ return /* @__PURE__ */ l("div", {
26
+ className: t("ttw:relative ttw:flex ttw:h-full ttw:w-full ttw:min-h-0 ttw:flex-col ttw:bg-background", v),
27
+ children: [
28
+ /* @__PURE__ */ l("div", {
29
+ className: t("ttw:flex ttw:shrink-0 ttw:items-center ttw:gap-3 ttw:px-6 ttw:pt-4", X ? "ttw:bg-primary/5 ttw:pb-2" : "ttw:absolute ttw:inset-x-0 ttw:top-0 ttw:z-10 ttw:bg-transparent ttw:pb-0"),
30
+ children: [X ? /* @__PURE__ */ c("h2", {
31
+ className: "ttw:min-w-0 ttw:flex-1 ttw:text-lg ttw:font-semibold ttw:text-primary",
32
+ children: J.header.title
33
+ }) : /* @__PURE__ */ c("span", { className: "ttw:flex-1" }), G ? /* @__PURE__ */ c(e, {
34
+ type: "button",
35
+ variant: "ghost",
36
+ size: "icon",
37
+ "aria-label": J.header.closeAriaLabel,
38
+ onClick: G,
39
+ children: /* @__PURE__ */ c(d, { className: "ttw:size-4" })
40
+ }) : null]
41
+ }),
42
+ X ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("div", {
43
+ className: "ttw:min-h-0 ttw:flex-1 ttw:overflow-y-auto",
44
+ children: /* @__PURE__ */ c(a, {
45
+ cardArtSrc: g,
46
+ labels: J,
47
+ cardholderOptions: y,
48
+ selectedCardholder: b,
49
+ onCardholderSelect: x,
50
+ isCardholderError: S,
51
+ onCardholderRetry: C,
52
+ cardFormatOptions: w,
53
+ selectedCardFormat: T,
54
+ onCardFormatSelect: E,
55
+ isFundingAccountVisible: D,
56
+ fundingAccountOptions: O,
57
+ selectedFundingAccount: k,
58
+ onFundingAccountSelect: A,
59
+ isFundingAccountError: j,
60
+ onFundingAccountRetry: M,
61
+ isMailingSectionVisible: N,
62
+ selectedMailingOption: P,
63
+ onMailingOptionSelect: F,
64
+ businessAddress: I,
65
+ isBusinessAddressVisible: L,
66
+ isManualAddressVisible: R,
67
+ manualAddress: z,
68
+ onManualAddressChange: B,
69
+ stateOptions: V
70
+ })
71
+ }), /* @__PURE__ */ l("div", {
72
+ className: "ttw:flex ttw:shrink-0 ttw:justify-end ttw:gap-3 ttw:border-t ttw:border-border ttw:bg-muted/40 ttw:px-6 ttw:py-4",
73
+ children: [/* @__PURE__ */ c(e, {
74
+ type: "button",
75
+ variant: "outline",
76
+ onClick: W,
77
+ children: J.footer.cancel
78
+ }), /* @__PURE__ */ l(e, {
79
+ type: "button",
80
+ disabled: H,
81
+ onClick: U,
82
+ children: [J.footer.createCard, /* @__PURE__ */ c(u, { className: "ttw:size-4" })]
83
+ })]
84
+ })] }) : null,
85
+ Y === r.Preparing ? /* @__PURE__ */ c(i, {
86
+ cardArtSrc: g,
87
+ labels: J
88
+ }) : null,
89
+ Y === r.Success ? /* @__PURE__ */ c(o, {
90
+ cardArtSrc: g,
91
+ labels: J,
92
+ onCreateAnotherClick: K,
93
+ onViewCardClick: q
94
+ }) : null
95
+ ]
96
+ });
97
+ }
98
+ //#endregion
99
+ export { r as CreateCardView, h as CreateCardWidget, n as resolveCreateCardWidgetLabels };
@@ -0,0 +1,67 @@
1
+ import { Input as e, Label as t, Select as n, SelectContent as r, SelectItem as i, SelectTrigger as a, SelectValue as o } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { useId as s } from "react";
3
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
4
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/ManualAddressFields.js
5
+ function u({ values: u, stateOptions: d, onChange: f, labels: p }) {
6
+ let m = s(), h = `${m}-street`, g = `${m}-city`, _ = `${m}-state`, v = `${m}-zip`;
7
+ return /* @__PURE__ */ l("div", {
8
+ className: "ttw:mt-3 ttw:flex ttw:flex-col ttw:gap-3",
9
+ children: [/* @__PURE__ */ l("div", {
10
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
11
+ children: [/* @__PURE__ */ c(t, {
12
+ htmlFor: h,
13
+ children: p.streetLabel
14
+ }), /* @__PURE__ */ c(e, {
15
+ id: h,
16
+ value: u.street,
17
+ onChange: (e) => f({ street: e.target.value })
18
+ })]
19
+ }), /* @__PURE__ */ l("div", {
20
+ className: "ttw:grid ttw:grid-cols-3 ttw:gap-3",
21
+ children: [
22
+ /* @__PURE__ */ l("div", {
23
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
24
+ children: [/* @__PURE__ */ c(t, {
25
+ htmlFor: g,
26
+ children: p.cityLabel
27
+ }), /* @__PURE__ */ c(e, {
28
+ id: g,
29
+ value: u.city,
30
+ onChange: (e) => f({ city: e.target.value })
31
+ })]
32
+ }),
33
+ /* @__PURE__ */ l("div", {
34
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
35
+ children: [/* @__PURE__ */ c(t, {
36
+ htmlFor: _,
37
+ children: p.stateLabel
38
+ }), /* @__PURE__ */ l(n, {
39
+ value: u.state,
40
+ onValueChange: (e) => f({ state: e }),
41
+ children: [/* @__PURE__ */ c(a, {
42
+ id: _,
43
+ className: "ttw:w-full",
44
+ children: /* @__PURE__ */ c(o, { placeholder: p.statePlaceholder })
45
+ }), /* @__PURE__ */ c(r, { children: d.map((e) => /* @__PURE__ */ c(i, {
46
+ value: e.value,
47
+ children: e.label
48
+ }, e.value)) })]
49
+ })]
50
+ }),
51
+ /* @__PURE__ */ l("div", {
52
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
53
+ children: [/* @__PURE__ */ c(t, {
54
+ htmlFor: v,
55
+ children: p.zipLabel
56
+ }), /* @__PURE__ */ c(e, {
57
+ id: v,
58
+ value: u.zip,
59
+ onChange: (e) => f({ zip: e.target.value })
60
+ })]
61
+ })
62
+ ]
63
+ })]
64
+ });
65
+ }
66
+ //#endregion
67
+ export { u as ManualAddressFields };