@tesouro/embedded-components-react 0.3.11 → 0.3.12

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