@tesouro/embedded-components-react 0.4.5 → 0.4.6

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 (40) hide show
  1. package/README.md +37 -37
  2. package/dist/index.d.ts +14 -8
  3. package/dist/lib/CreditCardsWidget.d.ts +4 -2
  4. package/dist/lib/DebitCardsWidget.d.ts +4 -2
  5. package/dist/lib/WidgetSuite.d.ts +14 -8
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +4 -4
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +72 -56
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +77 -48
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +47 -91
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +91 -33
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +33 -167
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +168 -75
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +75 -21
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +23 -210
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +199 -203
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +198 -89
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +105 -13
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +12 -47
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +47 -31
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +27 -198
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +198 -30
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +30 -234
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +240 -19
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +19 -342
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +344 -4
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +4 -33
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +32 -83
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +24 -24
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +1 -1
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +2 -2
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +2 -0
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +28 -3
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index56.js +2 -0
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index57.js +152 -131
  35. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsList.js +84 -87
  36. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/labels.js +0 -1
  37. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  38. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index4.js +2 -2
  39. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index9.js +12 -10
  40. package/package.json +1 -1
@@ -2,216 +2,212 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { usePayableSuggestionsQuery as e } from "../../data-access/dist/index16.js";
6
- import "../../data-access/dist/index.js";
7
- import { maskAccountNumber as t } from "./index19.js";
8
- import { counterpartFormBankAccountToCreatePayload as n, counterpartFormBankAccountToUpdatePayload as ee, getAchInstructions as r, getCounterpartEmail as i, getCounterpartName as a, getPayableAchInstructions as o, hasAchFormValues as s, resolveCounterpartBankAccountWrite as c, validateAchFormValues as te } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
9
- import { useCounterpartsQuery as ne } from "../../../shared/counterpart-management/data-access/dist/index3.js";
10
- import { useCreateCounterpartBankAccountMutation as re, useUpdateCounterpartBankAccountMutation as ie } from "../../../shared/counterpart-management/data-access/dist/index5.js";
11
- import { useCounterpartDetails as ae } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
5
+ import { Button as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { getStateOptions as t } from "../../../shared/util/dist/lib/usStates.js";
7
+ import { AchFieldGroup as n } from "../../../shared/counterpart-management/ui/dist/index5.js";
8
+ import { CounterpartFormFields as r, useFocusFirstInvalidField as i } from "../../../shared/counterpart-management/ui/dist/index9.js";
9
+ import { COUNTERPART_MESSAGE_LABELS_EN as a } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
10
+ import { useCounterpartForm as o } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
12
11
  import "../../../shared/counterpart-management/feature/dist/index.js";
13
- import { VENDOR_SECTION_PROPS_LABELS_EN as oe } from "./index41.js";
14
- import { buildVendorPrefill as se } from "./index43.js";
15
- import { VendorInlineForm as ce } from "./index44.js";
16
- import { useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
17
- import { jsx as le } from "react/jsx-runtime";
12
+ import { VENDOR_INLINE_FORM_LABELS_EN as s } from "./index42.js";
13
+ import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
14
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
15
+ import { Landmark as g, Plus as _, X as v } from "lucide-react";
18
16
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js
19
- var m = 10, ue = 300, h = {
20
- accountHolderName: "",
21
- routingNumber: "",
22
- accountNumber: ""
23
- };
24
- function g({ payableId: g, counterpartId: _, payableCounterpartId: v, payableCounterpartBankAccountId: y, onCounterpartChange: b, requiredError: de, extractedVendor: x, labels: fe }) {
25
- let S = {
26
- ...oe,
27
- ...fe
28
- }, [C, w] = p(""), [T, E] = p(""), [D, O] = p(), [pe, k] = p(!1), [A, j] = p(h), M = f(A);
29
- M.current = A;
30
- let [N, P] = p(!1), F = s(A) || N, [I, L] = p(), [R, z] = p(), B = f(_), [V, me] = p(!1), H = l(() => {
31
- k(!1), j(h), L(void 0), z(void 0);
32
- }, []), U = l((e) => {
33
- me(!0), b(e);
34
- }, [b]), W = e(g, { enabled: !!g && !_ && !v }).data?.suggested_counterpart?.id;
35
- u(() => {
36
- !V && !_ && !v && W && U(W);
17
+ function y({ mode: y, counterpart: b, primaryAddress: x, bankAccounts: S, isBankAccountsLoading: C, isBankAccountsError: w, initialName: T, initialValues: E, onSaved: D, onCancel: O, onDirtyChange: k, labels: A }) {
18
+ let j = {
19
+ ...s,
20
+ ...A
21
+ }, [M, N] = f("none"), [P, F] = f(b?.id), [I, L] = f(!1), [R, z] = f(!1);
22
+ l(() => {
23
+ k?.(R);
24
+ }, [R, k]);
25
+ let B = u(() => t(), []), V = d(M), H = d(!1), U = o({
26
+ view: M,
27
+ setView: N,
28
+ selectedId: P,
29
+ setSelectedId: F,
30
+ messages: a,
31
+ counterpartType: "vendor",
32
+ counterpart: b,
33
+ primaryAddress: x,
34
+ bankAccounts: S,
35
+ isBankAccountsLoading: C,
36
+ isBankAccountsError: w
37
+ }), { openCreate: W, openEdit: G, setValues: K, expandAddress: q } = U, J = i(U.errors);
38
+ l(() => {
39
+ y === "edit" ? G() : W();
37
40
  }, [
38
- _,
39
- v,
40
- V,
41
+ y,
41
42
  W,
42
- U
43
- ]), u(() => {
44
- B.current !== _ && (B.current = _, H());
45
- }, [_, H]), u(() => {
46
- let e = setTimeout(() => {
47
- E(C.trim());
48
- }, ue);
49
- return () => clearTimeout(e);
50
- }, [C]);
51
- let G = ne({
52
- sort: "counterpart_name",
53
- order: "asc",
54
- limit: m,
55
- counterpart_name__icontains: T || void 0,
56
- is_vendor: !0,
57
- enabled: !!T
58
- }), K = ae({ selectedId: _ }), q = re(), J = ie(), Y = d(() => {
59
- let e = K.counterpart;
60
- if (!e) return;
61
- if (K.isBankAccountsLoading) return {
62
- name: a(e),
63
- email: i(e),
64
- methodLabel: S.paymentMethodLoading,
65
- fields: []
66
- };
67
- if (K.isBankAccountsError) return {
68
- name: a(e),
69
- email: i(e),
70
- methodLabel: S.paymentMethodUnavailable,
71
- fields: []
72
- };
73
- let n = o(K.bankAccounts);
74
- return {
75
- name: a(e),
76
- email: i(e),
77
- methodLabel: n ? S.achMethod : S.noMethod,
78
- fields: n ? [
79
- {
80
- label: S.accountHolder,
81
- value: n.account_holder_name ?? ""
82
- },
83
- {
84
- label: S.routingNumber,
85
- value: n.routing_number ?? ""
86
- },
87
- {
88
- label: S.accountNumber,
89
- value: n.account_number ?? "",
90
- maskedValue: n.account_number ? t(n.account_number) : ""
91
- }
92
- ] : []
93
- };
43
+ G
44
+ ]), l(() => {
45
+ V.current !== "none" && M === "none" && P && D(P), V.current = M;
94
46
  }, [
95
- K.bankAccounts,
96
- K.counterpart,
97
- K.isBankAccountsError,
98
- K.isBankAccountsLoading,
99
- S
100
- ]), X = d(() => r(K.bankAccounts), [K.bankAccounts]), Z = d(() => o(K.bankAccounts)?.id, [K.bankAccounts]), Q = l(async () => {
101
- let e = M.current;
102
- if (!_) return { ok: !0 };
103
- if (!s(e)) return y && _ === v ? {
104
- ok: !0,
105
- counterpartBankAccountId: y
106
- } : K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError ? { ok: !1 } : {
107
- ok: !0,
108
- counterpartBankAccountId: Z
109
- };
110
- if (K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError) return { ok: !1 };
111
- let t = te(e);
112
- if (Object.keys(t).length > 0) return L(t), k(!0), { ok: !1 };
113
- L(void 0);
114
- let r = c(K.bankAccounts, R ?? X?.id);
115
- if (r.kind === "update") return await J.mutateAsync({
116
- path: {
117
- counterpart_id: _,
118
- bank_account_id: r.bankAccountId
119
- },
120
- body: ee(e, { includeAchDefaults: r.includeAchDefaults })
121
- }), z(r.bankAccountId), {
122
- ok: !0,
123
- counterpartBankAccountId: r.bankAccountId
124
- };
125
- let i = await q.mutateAsync({
126
- path: { counterpart_id: _ },
127
- body: n(e, { isDefaultForCurrency: r.isDefaultForCurrency })
128
- });
129
- return z(i?.id), {
130
- ok: !0,
131
- counterpartBankAccountId: i?.id
132
- };
47
+ M,
48
+ P,
49
+ D
50
+ ]), l(() => {
51
+ y !== "create" || H.current || (H.current = !0, K((e) => ({
52
+ ...e,
53
+ entityType: "organization",
54
+ legalName: T?.trim() || E?.legalName || e.legalName,
55
+ email: E?.email || e.email,
56
+ phone: E?.phone || e.phone,
57
+ address: E?.address ?? e.address
58
+ })), E?.address && Object.values(E.address).some(Boolean) && q());
133
59
  }, [
134
- X,
135
- _,
136
- q,
137
- K.bankAccounts,
138
- K.isBankAccountsError,
139
- K.isBankAccountsFetching,
140
- K.isBankAccountsLoading,
141
- R,
142
- Z,
143
60
  y,
144
- v,
145
- J
146
- ]), he = d(() => (G.data?.data ?? []).map((e) => ({
147
- name: a(e),
148
- email: i(e),
149
- onSelect: () => U(e.id)
150
- })), [G.data, U]), ge = d(() => se(x), [x]), $ = l(() => {
151
- O(void 0), P(!1);
152
- }, []), _e = l((e) => {
153
- O(void 0), P(!1), U(e);
154
- }, [U]);
155
- if (D) return {
156
- mode: "creating",
157
- newVendorForm: /* @__PURE__ */ le(ce, {
158
- mode: D,
159
- counterpart: D === "edit" ? K.counterpart : void 0,
160
- primaryAddress: D === "edit" ? K.primaryAddress : void 0,
161
- bankAccounts: D === "edit" ? K.bankAccounts : void 0,
162
- isBankAccountsLoading: D === "edit" ? K.isBankAccountsLoading : void 0,
163
- isBankAccountsError: D === "edit" ? K.isBankAccountsError : void 0,
164
- initialName: D === "create" ? C : void 0,
165
- initialValues: D === "create" ? ge : void 0,
166
- onSaved: _e,
167
- onCancel: $,
168
- onDirtyChange: P
169
- }),
170
- onClear: $,
171
- hasUnsavedVendorChanges: F
172
- };
173
- if (Y) {
174
- let e = K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError;
175
- return {
176
- mode: "resolved",
177
- summary: Y,
178
- onEdit: e ? void 0 : () => O("edit"),
179
- onClear: () => U(void 0),
180
- paymentInstructions: e ? void 0 : {
181
- isOpen: pe,
182
- values: A,
183
- errors: I,
184
- onOpen: () => {
185
- k(!0), X && (j({
186
- accountHolderName: X.account_holder_name ?? "",
187
- routingNumber: X.routing_number ?? "",
188
- accountNumber: X.account_number ?? ""
189
- }), z(X.id));
190
- },
191
- onChange: (e) => {
192
- j((t) => ({
61
+ T,
62
+ E,
63
+ K,
64
+ q
65
+ ]), l(() => {
66
+ y === "edit" && (U.values.bankAccount.routingNumber || U.values.bankAccount.accountNumber) && L(!0);
67
+ }, [
68
+ y,
69
+ U.values.bankAccount.accountNumber,
70
+ U.values.bankAccount.routingNumber
71
+ ]), l(() => {
72
+ U.sectionsToExpand.bankAccount && L(!0);
73
+ }, [U.sectionsToExpand.bankAccount]);
74
+ let Y = c((e) => {
75
+ z(!0), K((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
76
+ ...t,
77
+ ...e,
78
+ firstName: t.firstName || t.legalName,
79
+ legalName: t.legalName
80
+ } : e.entityType === "organization" && t.entityType !== "organization" ? {
81
+ ...t,
82
+ ...e,
83
+ legalName: t.legalName || [t.firstName, t.lastName].filter(Boolean).join(" ")
84
+ } : {
85
+ ...t,
86
+ ...e
87
+ });
88
+ }, [K]);
89
+ return /* @__PURE__ */ h("div", {
90
+ ref: J,
91
+ className: "ttw:flex ttw:flex-col ttw:gap-4 ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4",
92
+ children: [
93
+ /* @__PURE__ */ h("div", {
94
+ className: "ttw:flex ttw:items-start ttw:justify-between ttw:gap-2",
95
+ children: [/* @__PURE__ */ m("p", {
96
+ className: "ttw:text-base ttw:font-semibold ttw:text-foreground",
97
+ children: y === "edit" ? j.editTitle : j.createTitle
98
+ }), /* @__PURE__ */ m(e, {
99
+ type: "button",
100
+ variant: "ghost",
101
+ size: "icon",
102
+ "aria-label": j.close,
103
+ onClick: O,
104
+ children: /* @__PURE__ */ m(v, { className: "ttw:size-4" })
105
+ })]
106
+ }),
107
+ /* @__PURE__ */ m(r, {
108
+ mode: y,
109
+ counterpartMode: "vendor",
110
+ values: U.values,
111
+ errors: U.errors,
112
+ stateOptions: B,
113
+ onChange: Y,
114
+ onAddressChange: (e) => {
115
+ z(!0), K((t) => ({
193
116
  ...t,
194
- ...e
195
- })), L(void 0);
196
- }
197
- },
198
- savePaymentInstructions: Q,
199
- hasUnsavedVendorChanges: F
200
- };
201
- }
202
- return {
203
- mode: "selecting",
204
- error: G.isError ? S.searchFailed : K.isError ? S.vendorDetailsFailed : de,
205
- search: {
206
- query: C,
207
- onQueryChange: w,
208
- isLoading: G.isLoading,
209
- onAddVendor: () => O("create"),
210
- results: he
211
- },
212
- savePaymentInstructions: Q,
213
- hasUnsavedVendorChanges: F
214
- };
117
+ address: {
118
+ ...t.address,
119
+ ...e
120
+ }
121
+ }));
122
+ },
123
+ sections: {
124
+ entityType: !0,
125
+ profileHeading: !1,
126
+ title: !1,
127
+ taxId: !1,
128
+ address: "collapsible",
129
+ bankAccount: !1
130
+ },
131
+ sectionsToExpand: U.sectionsToExpand,
132
+ onAddressExpand: U.expandAddress,
133
+ labels: { businessNameLabel: j.nameLabel }
134
+ }),
135
+ /* @__PURE__ */ h("div", {
136
+ className: "ttw:flex ttw:flex-col ttw:gap-1",
137
+ children: [/* @__PURE__ */ m("p", {
138
+ className: "ttw:text-sm ttw:font-semibold ttw:text-foreground",
139
+ children: j.paymentMethodsHeading
140
+ }), /* @__PURE__ */ m("p", {
141
+ className: "ttw:text-sm ttw:text-muted-foreground",
142
+ children: j.paymentMethodsDescription
143
+ })]
144
+ }),
145
+ /* @__PURE__ */ h("div", {
146
+ className: "ttw:flex ttw:gap-3 ttw:rounded-lg ttw:border ttw:border-border ttw:p-3",
147
+ children: [/* @__PURE__ */ m("span", {
148
+ className: "ttw:flex ttw:size-8 ttw:shrink-0 ttw:items-center ttw:justify-center ttw:rounded-md ttw:bg-primary",
149
+ children: /* @__PURE__ */ m(g, {
150
+ "aria-hidden": !0,
151
+ className: "ttw:size-4 ttw:text-white"
152
+ })
153
+ }), /* @__PURE__ */ h("div", {
154
+ className: "ttw:flex ttw:flex-1 ttw:flex-col ttw:gap-3",
155
+ children: [/* @__PURE__ */ h("div", {
156
+ className: "ttw:flex ttw:flex-col ttw:gap-0.5",
157
+ children: [/* @__PURE__ */ m("p", {
158
+ className: "ttw:text-sm ttw:font-medium ttw:text-foreground",
159
+ children: j.achTitle
160
+ }), /* @__PURE__ */ m("p", {
161
+ className: "ttw:text-sm ttw:text-muted-foreground",
162
+ children: j.achDescription
163
+ })]
164
+ }), I ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(n, {
165
+ idPrefix: "vendor-inline-ach",
166
+ values: U.values.bankAccount,
167
+ errors: U.errors?.bankAccount,
168
+ onChange: (e) => {
169
+ z(!0), K((t) => ({
170
+ ...t,
171
+ bankAccount: {
172
+ ...t.bankAccount,
173
+ ...e
174
+ }
175
+ }));
176
+ },
177
+ labels: {
178
+ accountHolderName: j.accountHolderNameLabel,
179
+ routingNumber: j.routingNumberLabel,
180
+ accountNumber: j.accountNumberLabel
181
+ }
182
+ }), /* @__PURE__ */ m("p", {
183
+ className: "ttw:text-sm ttw:text-muted-foreground",
184
+ children: j.achHelp
185
+ })] }) : /* @__PURE__ */ h(e, {
186
+ type: "button",
187
+ variant: "link",
188
+ className: "ttw:w-fit ttw:px-0",
189
+ onClick: () => L(!0),
190
+ children: [/* @__PURE__ */ m(_, { className: "ttw:size-4" }), j.addBankAccount]
191
+ })]
192
+ })]
193
+ }),
194
+ /* @__PURE__ */ h("div", {
195
+ className: "ttw:flex ttw:justify-end ttw:gap-2",
196
+ children: [/* @__PURE__ */ m(e, {
197
+ type: "button",
198
+ variant: "outline",
199
+ onClick: O,
200
+ children: j.cancel
201
+ }), /* @__PURE__ */ m(e, {
202
+ type: "button",
203
+ onClick: U.submit,
204
+ loading: U.isSubmitting,
205
+ disabled: U.isSubmitting,
206
+ children: j.save
207
+ })]
208
+ })
209
+ ]
210
+ });
215
211
  }
216
212
  //#endregion
217
- export { g as useVendorSectionProps };
213
+ export { y as VendorInlineForm, y as default };