@tesouro/embedded-components-react 0.4.4 → 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 (69) 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/data-access/dist/index.js +8 -8
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index10.js +50 -29
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index11.js +39 -30
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index12.js +26 -311
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index13.js +326 -12
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index14.js +1 -1
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index15.js +1 -1
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index4.js +13 -27
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index5.js +28 -245
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index6.js +256 -92
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index7.js +86 -73
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index8.js +77 -14
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index9.js +18 -63
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +4 -4
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +1 -1
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index3.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +1 -1
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +2 -2
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +1 -1
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +1 -1
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +72 -56
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +77 -48
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +47 -91
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +91 -33
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +33 -167
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +168 -75
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +75 -21
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +23 -210
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +199 -203
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +198 -89
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +105 -13
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +12 -47
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +47 -31
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +27 -198
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +198 -30
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +30 -234
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +240 -18
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +19 -341
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +344 -4
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +4 -33
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +32 -83
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +25 -25
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +1 -1
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +1 -1
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +1 -1
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +1 -1
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +2 -2
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +1 -1
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +2 -0
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +28 -3
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index56.js +2 -0
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index57.js +152 -131
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index97.js +1 -1
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index98.js +32 -27
  64. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsList.js +84 -87
  65. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/labels.js +0 -1
  66. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  67. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index4.js +2 -2
  68. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index9.js +12 -10
  69. package/package.json +1 -1
@@ -1,80 +1,173 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { useAttachPayableFileMutation as e } from "../../data-access/dist/index12.js";
6
- import "../../data-access/dist/index.js";
7
- import { SourceDocumentPanel as t } from "../../ui/dist/index95.js";
1
+ import { UNSAVED_BILL_DIALOG_LABELS_EN as e } from "../../ui/dist/index97.js";
8
2
  import "../../ui/dist/index.js";
9
- import { createSourceDocumentPreview as n } from "./index40.js";
10
- import { SOURCE_DOCUMENT_CONTAINER_LABELS_EN as r } from "./index41.js";
11
- import { useEffect as i, useState as a } from "react";
12
- import { jsx as o } from "react/jsx-runtime";
3
+ import { PAY_BILL_FLOW_LABELS_EN as t, mergePayBillFlowLabels as n } from "./index21.js";
4
+ import { MARK_AS_PAID_FLOW_LABELS_EN as r, mergeMarkAsPaidFlowLabels as i } from "./index12.js";
5
+ import "./index15.js";
6
+ import { APPROVAL_POLICY_RULE_COPY_EN as a } from "./index25.js";
7
+ import { BILL_DETAIL_ACTIONS_LABELS_EN as o, SCHEDULED_SUMMARY_LABEL_EN as s, mergeBillDetailActionsLabels as c } from "./index40.js";
8
+ import { SOURCE_DOCUMENT_PREVIEW_LABELS_EN as l } from "./index41.js";
13
9
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js
14
- function s(e) {
15
- let [t, n] = a();
16
- return i(() => {
17
- if (!e) {
18
- n(void 0);
19
- return;
10
+ var u = {
11
+ unmappedValidationError: (e, t) => `${e}: ${t}`,
12
+ unknownValidationField: "(unknown field)",
13
+ requiredField: "This field is required.",
14
+ saveFailed: "We could not save this bill. Try again.",
15
+ discountTaxBlockedByLineItems: "Discount and Tax can't be saved on a bill with line items. Remove them, then save again.",
16
+ finalizeFailed: "We could not submit this bill. Try again.",
17
+ draftSaved: "Bill saved as a draft.",
18
+ submittedSaved: "Bill updated.",
19
+ submittedDemoted: "Bill updated. It moved back to Drafts because some required details are missing.",
20
+ billFinalized: "Bill submitted for approval.",
21
+ numbersOnly: "Enter numbers only.",
22
+ unreadableMoney: "Enter a valid amount.",
23
+ unusableQuantity: "Enter a quantity greater than 0.",
24
+ lineItemsNeedAttention: "Check the highlighted line items before saving.",
25
+ unreadableDiscount: "Enter a valid discount amount.",
26
+ unreadableTax: "Enter a valid tax amount.",
27
+ unreadableTotal: "Enter a valid total amount."
28
+ }, d = {
29
+ achMethod: "via ACH bank transfer",
30
+ noMethod: "No payment method on file",
31
+ accountHolder: "Account holder",
32
+ routingNumber: "Routing number",
33
+ accountNumber: "Account number",
34
+ paymentMethodLoading: "Loading payment method...",
35
+ paymentMethodUnavailable: "We could not load payment methods. Try again.",
36
+ searchFailed: "We could not load vendors. Try again.",
37
+ vendorDetailsFailed: "We could not load this vendor. Try again."
38
+ }, f = {
39
+ attachFailed: "We could not attach that file. Try again.",
40
+ deleteFailed: "We could not remove that document. Try again.",
41
+ noDocument: "No document attached to this bill.",
42
+ pendingDeletionNotice: "This document will be removed when you save this bill.",
43
+ preview: l
44
+ }, p = {
45
+ notProvided: "Not provided",
46
+ paymentInstructionsValue: (e) => `Account ending in ${e}`,
47
+ invoiceDateRow: "Invoice date",
48
+ dueDateRow: "Due date",
49
+ invoiceNumberRow: "Invoice number",
50
+ glCodeMissing: "GL code not specified",
51
+ glCodeUnavailable: "GL code unavailable",
52
+ qtyPriceValue: (e, t) => `${e} x ${t}`,
53
+ subtotalRow: "Subtotal",
54
+ taxRow: "Tax",
55
+ discountRow: "Discounts",
56
+ totalRow: "Total",
57
+ paidOnLabel: (e) => `Paid on ${e}`,
58
+ paymentInstructionsSaveError: "Couldn't save payment instructions. Try again.",
59
+ paymentInstructionsLinkError: "Payment instructions were saved to the vendor, but couldn't be added to this bill. Try again."
60
+ }, m = {
61
+ dateLabel: (e) => new Date(e).toLocaleString("en-US", {
62
+ month: "short",
63
+ day: "numeric",
64
+ year: "numeric",
65
+ hour: "numeric",
66
+ minute: "2-digit"
67
+ }),
68
+ byActor: (e, t) => `${e} by ${t}`,
69
+ billAdded: "Bill added",
70
+ billUploaded: "Bill uploaded",
71
+ billUpdated: "Bill updated",
72
+ attachmentAdded: "Attachment added",
73
+ submittedForApproval: "Submitted for approval",
74
+ approvalRequested: "Approval requested",
75
+ approved: "Approved",
76
+ autoApproved: "Approved automatically",
77
+ rejected: "Rejected",
78
+ rejectedWithReason: (e) => `Rejected: ${e}`,
79
+ reopened: "Reopened",
80
+ markedAsPaid: "Marked as paid",
81
+ markedAsPartiallyPaid: "Marked as partially paid",
82
+ paymentReverted: "Payment reverted",
83
+ statusChanged: (e) => `Status changed to ${e}`
84
+ }, h = {
85
+ newTitle: "New bill",
86
+ extractedTitle: (e) => `Bill from ${e}`,
87
+ viewTitle: (e) => `Bill from ${e}`,
88
+ readOnlyTitle: "Bill details",
89
+ addedOn: (e) => `Added on ${e}`,
90
+ submittedSaveButton: "Save changes",
91
+ unsavedChanges: e,
92
+ scheduledSummary: s,
93
+ actions: o,
94
+ detail: p,
95
+ history: m,
96
+ payBill: t,
97
+ markAsPaid: r,
98
+ approvalPolicyCopy: a,
99
+ deleteDraft: {
100
+ menuItem: "Delete draft",
101
+ dialog: {
102
+ title: "Delete this draft?",
103
+ description: "The draft and anything entered on it are removed. This can't be undone.",
104
+ confirmButton: "Delete draft"
105
+ },
106
+ error: "Couldn't delete this draft. Try again."
107
+ },
108
+ lineItemsGlCodeUnavailable: {
109
+ loadError: "Couldn't load GL codes",
110
+ noAccess: "You don't have access to GL codes",
111
+ empty: "No GL codes set up yet"
112
+ }
113
+ };
114
+ function g(e) {
115
+ return {
116
+ ...h,
117
+ ...e,
118
+ actions: c(e?.actions),
119
+ detail: {
120
+ ...h.detail,
121
+ ...e?.detail
122
+ },
123
+ history: {
124
+ ...h.history,
125
+ ...e?.history
126
+ },
127
+ payBill: n(e?.payBill),
128
+ markAsPaid: i(e?.markAsPaid),
129
+ lineItemsGlCodeUnavailable: {
130
+ ...h.lineItemsGlCodeUnavailable,
131
+ ...e?.lineItemsGlCodeUnavailable
132
+ },
133
+ unsavedChanges: {
134
+ ...h.unsavedChanges,
135
+ ...e?.unsavedChanges
136
+ },
137
+ approvalPolicyCopy: {
138
+ ...h.approvalPolicyCopy,
139
+ ...e?.approvalPolicyCopy
140
+ },
141
+ deleteDraft: {
142
+ ...h.deleteDraft,
143
+ ...e?.deleteDraft,
144
+ dialog: (() => {
145
+ let t = {
146
+ ...h.deleteDraft.dialog,
147
+ ...e?.deleteDraft?.dialog
148
+ };
149
+ return delete t.reason, t;
150
+ })()
20
151
  }
21
- let t = URL.createObjectURL(e);
22
- return n(t), () => URL.revokeObjectURL(t);
23
- }, [e]), t;
24
- }
25
- function c({ payableId: i, file: a, isDocumentPending: c, pendingFileName: l, readOnly: u, staging: d, deletion: f, labels: p }) {
26
- let { stagedFile: m, onFileStaged: h, onClearStagedFile: g, isSaving: _ } = d ?? {}, { isPending: v, onRequest: y, onDetachNow: b, isDeleting: x, hasFailed: S } = f ?? {}, C = {
27
- ...r,
28
- ...p,
29
- preview: {
30
- ...r.preview,
31
- ...p?.preview
32
- }
33
- }, w = e(), T = s(m), E = !!(a && !v || m);
34
- if (!E && (c || w.isPending)) return /* @__PURE__ */ o(t, {
35
- mode: "loading",
36
- fileName: l
37
- });
38
- if (!E && u) return /* @__PURE__ */ o("div", {
39
- className: "ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:text-sm ttw:text-muted-foreground",
40
- children: C.noDocument
41
- });
42
- if (!E) return /* @__PURE__ */ o(t, {
43
- mode: "upload",
44
- uploadStatus: w.isPending || x ? "uploading" : "idle",
45
- uploadErrorMessage: w.isError ? C.attachFailed : S ? C.deleteFailed : void 0,
46
- noticeMessage: v && !S ? C.pendingDeletionNotice : void 0,
47
- onFilesSelected: (e) => {
48
- let [t] = e;
49
- if (t) {
50
- if (i) {
51
- let e = () => w.mutate({
52
- path: { payable_id: i },
53
- file: t
54
- });
55
- if (v && b) {
56
- b().then(e, () => void 0);
57
- return;
58
- }
59
- e();
60
- } else h?.(t);
61
- }
62
- }
63
- });
64
- let D = a?.name ?? m?.name ?? "", O = n(a || {
65
- name: D,
66
- url: T ?? "",
67
- mimetype: m?.type ?? ""
68
- }, C.preview);
69
- return /* @__PURE__ */ o(t, {
70
- mode: "document",
71
- fileName: D,
72
- preview: O,
73
- isDeleting: x,
74
- deleteErrorMessage: S ? C.deleteFailed : void 0,
75
- onDownload: a ? () => window.open(a.url, "_blank", "noopener,noreferrer") : void 0,
76
- onDelete: u ? void 0 : a && i ? y : _ ? void 0 : g
77
- });
152
+ };
78
153
  }
154
+ var _ = {
155
+ createTitle: "New vendor",
156
+ editTitle: "Edit vendor",
157
+ close: "Close the vendor form",
158
+ nameLabel: "Name",
159
+ addAddress: "Add address (optional)",
160
+ paymentMethodsHeading: "Accepted payment methods",
161
+ paymentMethodsDescription: "How and where will the money be sent. Don't have these yet? No problem. You can save this vendor and add their payment details later — you just won't be able to send payments until you do.",
162
+ achTitle: "ACH bank transfer",
163
+ achDescription: "Fast, direct deposit to the vendor's bank. Arrives in 1–3 business days.",
164
+ addBankAccount: "Add bank account",
165
+ accountHolderNameLabel: "Account holder name",
166
+ routingNumberLabel: "Routing number",
167
+ accountNumberLabel: "Account number",
168
+ achHelp: "Ask your vendor for this — it's usually on their invoice, W-9, or a payment instructions email they send you.",
169
+ cancel: "Cancel",
170
+ save: "Save vendor"
171
+ };
79
172
  //#endregion
80
- export { c as SourceDocumentContainer, c as default };
173
+ export { u as BILL_CREATE_MESSAGE_LABELS_EN, h as BILL_CREATE_SCREEN_LABELS_EN, p as BILL_DETAIL_VIEW_LABELS_EN, m as BILL_HISTORY_LABELS_EN, f as SOURCE_DOCUMENT_CONTAINER_LABELS_EN, _ as VENDOR_INLINE_FORM_LABELS_EN, d as VENDOR_SECTION_PROPS_LABELS_EN, g as mergeBillCreateScreenCopy };
@@ -1,26 +1,80 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useAttachPayableFileMutation as e } from "../../data-access/dist/index13.js";
6
+ import "../../data-access/dist/index.js";
7
+ import { SourceDocumentPanel as t } from "../../ui/dist/index95.js";
8
+ import "../../ui/dist/index.js";
9
+ import { createSourceDocumentPreview as n } from "./index41.js";
10
+ import { SOURCE_DOCUMENT_CONTAINER_LABELS_EN as r } from "./index42.js";
11
+ import { useEffect as i, useState as a } from "react";
12
+ import { jsx as o } from "react/jsx-runtime";
1
13
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js
2
- function e(e) {
3
- return e?.trim() ?? "";
4
- }
5
- function t(t) {
6
- let n = e(t);
7
- return n.length === 2 ? n.toUpperCase() : "";
14
+ function s(e) {
15
+ let [t, n] = a();
16
+ return i(() => {
17
+ if (!e) {
18
+ n(void 0);
19
+ return;
20
+ }
21
+ let t = URL.createObjectURL(e);
22
+ return n(t), () => URL.revokeObjectURL(t);
23
+ }, [e]), t;
8
24
  }
9
- function n(n) {
10
- if (!n) return;
11
- let r = {
12
- legalName: e(n.name),
13
- email: e(n.email),
14
- phone: e(n.phone),
15
- address: {
16
- line1: e(n.address?.line1),
17
- line2: e(n.address?.line2),
18
- city: e(n.address?.city),
19
- state: t(n.address?.state),
20
- postalCode: e(n.address?.postal_code)
25
+ function c({ payableId: i, file: a, isDocumentPending: c, pendingFileName: l, readOnly: u, staging: d, deletion: f, labels: p }) {
26
+ let { stagedFile: m, onFileStaged: h, onClearStagedFile: g, isSaving: _ } = d ?? {}, { isPending: v, onRequest: y, onDetachNow: b, isDeleting: x, hasFailed: S } = f ?? {}, C = {
27
+ ...r,
28
+ ...p,
29
+ preview: {
30
+ ...r.preview,
31
+ ...p?.preview
32
+ }
33
+ }, w = e(), T = s(m), E = !!(a && !v || m);
34
+ if (!E && (c || w.isPending)) return /* @__PURE__ */ o(t, {
35
+ mode: "loading",
36
+ fileName: l
37
+ });
38
+ if (!E && u) return /* @__PURE__ */ o("div", {
39
+ className: "ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:text-sm ttw:text-muted-foreground",
40
+ children: C.noDocument
41
+ });
42
+ if (!E) return /* @__PURE__ */ o(t, {
43
+ mode: "upload",
44
+ uploadStatus: w.isPending || x ? "uploading" : "idle",
45
+ uploadErrorMessage: w.isError ? C.attachFailed : S ? C.deleteFailed : void 0,
46
+ noticeMessage: v && !S ? C.pendingDeletionNotice : void 0,
47
+ onFilesSelected: (e) => {
48
+ let [t] = e;
49
+ if (t) {
50
+ if (i) {
51
+ let e = () => w.mutate({
52
+ path: { payable_id: i },
53
+ file: t
54
+ });
55
+ if (v && b) {
56
+ b().then(e, () => void 0);
57
+ return;
58
+ }
59
+ e();
60
+ } else h?.(t);
61
+ }
21
62
  }
22
- };
23
- return r.legalName || r.email || r.phone || Object.values(r.address).some(Boolean) ? r : void 0;
63
+ });
64
+ let D = a?.name ?? m?.name ?? "", O = n(a || {
65
+ name: D,
66
+ url: T ?? "",
67
+ mimetype: m?.type ?? ""
68
+ }, C.preview);
69
+ return /* @__PURE__ */ o(t, {
70
+ mode: "document",
71
+ fileName: D,
72
+ preview: O,
73
+ isDeleting: x,
74
+ deleteErrorMessage: S ? C.deleteFailed : void 0,
75
+ onDownload: a ? () => window.open(a.url, "_blank", "noopener,noreferrer") : void 0,
76
+ onDelete: u ? void 0 : a && i ? y : _ ? void 0 : g
77
+ });
24
78
  }
25
79
  //#endregion
26
- export { n as buildVendorPrefill };
80
+ export { c as SourceDocumentContainer, c as default };
@@ -1,213 +1,26 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
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";
11
- import "../../../shared/counterpart-management/feature/dist/index.js";
12
- import { VENDOR_INLINE_FORM_LABELS_EN as s } from "./index41.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";
16
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js
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();
40
- }, [
41
- y,
42
- W,
43
- G
44
- ]), l(() => {
45
- V.current !== "none" && M === "none" && P && D(P), V.current = M;
46
- }, [
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());
59
- }, [
60
- y,
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) => ({
116
- ...t,
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
- });
2
+ function e(e) {
3
+ return e?.trim() ?? "";
4
+ }
5
+ function t(t) {
6
+ let n = e(t);
7
+ return n.length === 2 ? n.toUpperCase() : "";
8
+ }
9
+ function n(n) {
10
+ if (!n) return;
11
+ let r = {
12
+ legalName: e(n.name),
13
+ email: e(n.email),
14
+ phone: e(n.phone),
15
+ address: {
16
+ line1: e(n.address?.line1),
17
+ line2: e(n.address?.line2),
18
+ city: e(n.address?.city),
19
+ state: t(n.address?.state),
20
+ postalCode: e(n.address?.postal_code)
21
+ }
22
+ };
23
+ return r.legalName || r.email || r.phone || Object.values(r.address).some(Boolean) ? r : void 0;
211
24
  }
212
25
  //#endregion
213
- export { y as VendorInlineForm, y as default };
26
+ export { n as buildVendorPrefill };