@tesouro/embedded-components-react 0.2.280 → 0.2.282

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 (112) hide show
  1. package/README.md +17 -14
  2. package/dist/experimental/WidgetSuite.d.ts +9 -1
  3. package/dist/experimental/index.d.ts +9 -1
  4. package/dist/index.css +20 -6
  5. package/dist/index.d.ts +46 -23
  6. package/dist/index.js +54 -53
  7. package/dist/lib/AcceptDisclosuresWidget.d.ts +9 -1
  8. package/dist/lib/BalancesWidget.d.ts +8 -0
  9. package/dist/lib/BankAccountOnboardingWidget.d.ts +9 -1
  10. package/dist/lib/BankAccountsWidget.d.ts +9 -1
  11. package/dist/lib/BillPayWidget.d.ts +8 -0
  12. package/dist/lib/BillPayWidget.js +1 -1
  13. package/dist/lib/CardDetailsWidget.d.ts +9 -1
  14. package/dist/lib/CardsWidget.d.ts +9 -1
  15. package/dist/lib/ChartOfAccountsWidget.d.ts +9 -1
  16. package/dist/lib/CounterpartsWidget.d.ts +9 -1
  17. package/dist/lib/CreateCardWidget.d.ts +9 -1
  18. package/dist/lib/ExpenseApprovalPoliciesWidget.d.ts +9 -1
  19. package/dist/lib/ExpenseManagementWidget.d.ts +9 -1
  20. package/dist/lib/ExpenseRequirementsWidget.d.ts +9 -1
  21. package/dist/lib/HelpWidget.d.ts +9 -1
  22. package/dist/lib/InsightsWidget.d.ts +8 -0
  23. package/dist/lib/InvoicingWidget.d.ts +9 -1
  24. package/dist/lib/LinkedAccountsWidget.d.ts +9 -1
  25. package/dist/lib/ProductsWidget.d.ts +9 -1
  26. package/dist/lib/ProfileWidget.d.ts +9 -1
  27. package/dist/lib/ReceiptMatchWidget.d.ts +9 -1
  28. package/dist/lib/ReceivablesWidget.d.ts +9 -1
  29. package/dist/lib/SettingsWidget.d.ts +9 -1
  30. package/dist/lib/TagsWidget.d.ts +9 -1
  31. package/dist/lib/TeamWidget.d.ts +9 -1
  32. package/dist/lib/TransfersWidget.d.ts +8 -0
  33. package/dist/lib/WidgetProvider.d.ts +25 -2
  34. package/dist/lib/WidgetProvider.js +8 -7
  35. package/dist/lib/WidgetProviderPublic.d.ts +8 -0
  36. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index4.js +3 -2
  37. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index17.js +54 -53
  38. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index8.js +3 -2
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +9 -5
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +42 -39
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +69 -54
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +21 -2
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +46 -40
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +81 -1
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +46 -47
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +3 -11
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +2 -8
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index2.js +5 -3
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +43 -5
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +1 -102
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +11 -3
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +9 -6
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +4 -5
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +127 -76
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +6 -6
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +7 -111
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +85 -1
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index3.js +16 -12
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +2 -24
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +8 -0
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +114 -0
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +1 -0
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +25 -0
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +50 -49
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +1 -1
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +25 -12
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +86 -69
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +2 -1
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +7 -7
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +17 -16
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +1 -0
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index21.js +1 -1
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index22.js +89 -124
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index24.js +2 -1
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +31 -26
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index27.js +1 -1
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +80 -77
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index36.js +20 -4
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index37.js +228 -6
  80. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index6.js +3 -2
  81. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index8.js +3 -2
  82. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index8.js +3 -2
  83. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index7.js +30 -29
  84. package/dist/libs/tesouro-embedded-components-react/expense-approval-policies-widget/feature/dist/lib/ExpenseApprovalPoliciesWidgetFeature.js +2 -1
  85. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index3.js +3 -2
  86. package/dist/libs/tesouro-embedded-components-react/expense-receipt-match-widget/feature/dist/lib/ReceiptMatchWidget.js +7 -6
  87. package/dist/libs/tesouro-embedded-components-react/expense-requirements-widget/feature/dist/lib/ExpenseRequirementsWidget.js +2 -1
  88. package/dist/libs/tesouro-embedded-components-react/gl-code-table-widget/feature/dist/index8.js +5 -4
  89. package/dist/libs/tesouro-embedded-components-react/help-widget/feature/dist/index3.js +3 -2
  90. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +3 -2
  91. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index3.js +5 -4
  92. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index9.js +3 -2
  93. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index8.js +3 -2
  94. package/dist/libs/tesouro-embedded-components-react/profile-widget/feature/dist/index4.js +3 -2
  95. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js +3 -2
  96. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +6 -6
  97. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/reference-data/useLedgerAccountsQuery.js +53 -11
  98. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/index.js +5 -5
  99. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/RootWidgetProvider.js +69 -67
  100. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/WidgetProvider.js +158 -132
  101. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/hooks.js +7 -4
  102. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/isDisclosuresAcceptanceRequired.js +20 -0
  103. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/labels.js +6 -1
  104. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  105. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/index.js +9 -9
  106. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/ErrorState/ErrorState.js +19 -18
  107. package/dist/libs/tesouro-embedded-components-react/tags-widget/feature/dist/index11.js +3 -2
  108. package/dist/libs/tesouro-embedded-components-react/team-widget/feature/dist/index17.js +3 -2
  109. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index5.js +1 -1
  110. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index6.js +3 -2
  111. package/dist/packages/shared-ui-shadcn/dist/index.js +3445 -3413
  112. package/package.json +1 -1
@@ -9,32 +9,36 @@ import { SourceDocumentPanel as r } from "../../ui/dist/index48.js";
9
9
  import "../../ui/dist/index.js";
10
10
  import { jsx as i } from "react/jsx-runtime";
11
11
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index3.js
12
- function a({ payableId: a, file: o, isDocumentPending: s, pendingFileName: c, labels: l }) {
13
- let u = {
12
+ function a({ payableId: a, file: o, isDocumentPending: s, pendingFileName: c, readOnly: l, labels: u }) {
13
+ let d = {
14
14
  ...e,
15
- ...l
16
- }, d = t(), f = n();
17
- if (!o && (s || d.isPending)) return /* @__PURE__ */ i(r, {
15
+ ...u
16
+ }, f = t(), p = n();
17
+ if (!o && (s || f.isPending)) return /* @__PURE__ */ i(r, {
18
18
  mode: "loading",
19
19
  fileName: c
20
20
  });
21
+ if (!o && l) return /* @__PURE__ */ i("div", {
22
+ className: "ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:text-sm ttw:text-muted-foreground",
23
+ children: d.noDocument
24
+ });
21
25
  if (!o && !a) return /* @__PURE__ */ i("div", {
22
26
  className: "ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:text-sm ttw:text-muted-foreground",
23
- children: u.saveBeforeAttaching
27
+ children: d.saveBeforeAttaching
24
28
  });
25
29
  if (!o) return /* @__PURE__ */ i(r, {
26
30
  mode: "upload",
27
- uploadStatus: d.isPending ? "uploading" : "idle",
28
- uploadErrorMessage: d.isError ? u.attachFailed : void 0,
31
+ uploadStatus: f.isPending ? "uploading" : "idle",
32
+ uploadErrorMessage: f.isError ? d.attachFailed : void 0,
29
33
  onFilesSelected: (e) => {
30
34
  let [t] = e;
31
- !t || !a || d.mutate({
35
+ !t || !a || f.mutate({
32
36
  path: { payable_id: a },
33
37
  file: t
34
38
  });
35
39
  }
36
40
  });
37
- let p = o.mimetype === "application/pdf" ? /* @__PURE__ */ i("iframe", {
41
+ let m = o.mimetype === "application/pdf" ? /* @__PURE__ */ i("iframe", {
38
42
  src: `${o.url}#toolbar=0&navpanes=0`,
39
43
  title: o.name,
40
44
  referrerPolicy: "no-referrer",
@@ -47,9 +51,9 @@ function a({ payableId: a, file: o, isDocumentPending: s, pendingFileName: c, la
47
51
  return /* @__PURE__ */ i(r, {
48
52
  mode: "document",
49
53
  fileName: o.name,
50
- preview: p,
54
+ preview: m,
51
55
  onDownload: () => window.open(o.url, "_blank", "noopener,noreferrer"),
52
- onDelete: a ? () => f.mutate({
56
+ onDelete: a && !l ? () => p.mutate({
53
57
  path: { file_id: o.id },
54
58
  payableId: a
55
59
  }) : void 0
@@ -1,25 +1,3 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { Implementation as e } from "../../../shared/feature/dist/lib/WidgetProvider/types.js";
6
- import { useWidgetConfig as t } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
7
- import "../../../shared/feature/dist/index.js";
8
- import { BillPayWidgetMonite as n } from "./index15.js";
9
- import "./index16.js";
10
- import { BillPayWidgetNative as r } from "./index28.js";
1
+ import "./index27.js";
2
+ import "./index28.js";
11
3
  import "./index29.js";
12
- import { jsx as i } from "react/jsx-runtime";
13
- //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js
14
- function a({ implementation: a, ...o }) {
15
- let s = t().implementation, c = a ?? s ?? e.Monite;
16
- return c === e.Native ? /* @__PURE__ */ i(r, {
17
- implementation: c,
18
- ...o
19
- }) : /* @__PURE__ */ i(n, {
20
- implementation: c,
21
- ...o
22
- });
23
- }
24
- //#endregion
25
- export { a as BillPayWidget, a as default };
@@ -0,0 +1,8 @@
1
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js
2
+ var e = {
3
+ bills: "Bills",
4
+ vendors: "Vendors",
5
+ settings: "Settings"
6
+ };
7
+ //#endregion
8
+ export { e as DEFAULT_TABS_LABELS };
@@ -0,0 +1,114 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
6
+ import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.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 i } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
12
+ import { useWidgetConfig as a } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
13
+ import "../../../shared/feature/dist/index.js";
14
+ import { BillPayWidgetUi as o } from "../../ui/dist/index31.js";
15
+ import { BillUploadStatusTray as s } from "../../ui/dist/index41.js";
16
+ import "../../ui/dist/index.js";
17
+ import { billsTabTestIds as c } from "./index24.js";
18
+ import { BillsTab as l } from "./index25.js";
19
+ import "./index26.js";
20
+ import { useBillUploadQueue as u } from "./index29.js";
21
+ import "./index30.js";
22
+ import { BillPayWidgetAnalyticsEvent as d, WIDGET_NAME as f } from "./index19.js";
23
+ import { DEFAULT_TABS_LABELS as p } from "./index31.js";
24
+ import { ApprovalPoliciesSettings as m } from "../../../shared/approval-policy/feature/dist/lib/ApprovalPoliciesSettings.js";
25
+ import "../../../shared/approval-policy/feature/dist/index.js";
26
+ import { CounterpartsWidget as h } from "../../../counterparts-widget/feature/dist/index8.js";
27
+ import "../../../counterparts-widget/feature/dist/index.js";
28
+ import { useCallback as g, useEffect as _, useState as v } from "react";
29
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
30
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js
31
+ var S = {
32
+ Bills: "bills",
33
+ Vendors: "vendors",
34
+ Settings: "settings"
35
+ }, C = [
36
+ S.Bills,
37
+ S.Vendors,
38
+ S.Settings
39
+ ];
40
+ function w({ labels: i, tabsLabels: f, approvalPolicyLabels: w, approvalPolicyComponentLabels: T, vendorLabels: E }) {
41
+ let D = r();
42
+ _(() => {
43
+ D(d.Mounted);
44
+ }, [D]);
45
+ let O = {
46
+ ...p,
47
+ ...f
48
+ }, { initResponse: k } = a(), A = e(k?.scopes, [t.ApprovalPolicyWriteOrg]), j = !k || A, [M, N] = v(S.Bills), [P, F] = v(), I = g((e) => {
49
+ N(S.Bills), F(e);
50
+ }, []), L = u({ onOpenBill: I }), R = [{
51
+ id: S.Bills,
52
+ label: O.bills,
53
+ content: /* @__PURE__ */ b(l, {
54
+ onEnqueueFiles: L.enqueue,
55
+ openPayableId: P,
56
+ onOpenPayableHandled: () => F(void 0)
57
+ })
58
+ }, {
59
+ id: S.Vendors,
60
+ label: O.vendors,
61
+ content: /* @__PURE__ */ b(h, {
62
+ ...E,
63
+ counterpartType: "vendor",
64
+ showTitle: !1,
65
+ onViewAllDocuments: () => N(S.Bills)
66
+ })
67
+ }];
68
+ j && R.push({
69
+ id: S.Settings,
70
+ label: O.settings,
71
+ content: /* @__PURE__ */ b(m, {
72
+ labels: w,
73
+ componentLabels: T
74
+ })
75
+ });
76
+ let z = R.some((e) => e.id === M) ? M : C.find((e) => R.some((t) => t.id === e)) ?? R[0]?.id ?? "";
77
+ return /* @__PURE__ */ x(y, { children: [
78
+ /* @__PURE__ */ b(n, {}),
79
+ /* @__PURE__ */ b(o, {
80
+ labels: i,
81
+ tabs: R,
82
+ selectedTabId: z,
83
+ onTabChange: N
84
+ }),
85
+ L.isVisible ? /* @__PURE__ */ b(s, {
86
+ sections: L.sections,
87
+ summaryLabel: L.summaryLabel,
88
+ collapsed: L.collapsed,
89
+ onToggleCollapsed: L.onToggleCollapsed,
90
+ onClose: L.onClose,
91
+ testId: c.uploadTray
92
+ }) : null
93
+ ] });
94
+ }
95
+ function T({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: a, linkComponent: o, implementation: s, uiFramework: c, errorFallback: l, onError: u, analytics: d, disclosuresAcceptance: p, ...m }) {
96
+ return /* @__PURE__ */ b(i, {
97
+ widgetName: f,
98
+ baseUrl: e,
99
+ widgetToken: t,
100
+ organizationId: n,
101
+ configClient: r,
102
+ gatewayRouting: a,
103
+ linkComponent: o,
104
+ implementation: s,
105
+ uiFramework: c,
106
+ errorFallback: l,
107
+ onError: u,
108
+ analytics: d,
109
+ disclosuresAcceptance: p,
110
+ children: /* @__PURE__ */ b(w, { ...m })
111
+ });
112
+ }
113
+ //#endregion
114
+ export { T as BillPayWidgetNative, T as default };
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { Implementation as e } from "../../../shared/feature/dist/lib/WidgetProvider/types.js";
6
+ import { useWidgetConfig as t } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
7
+ import "../../../shared/feature/dist/index.js";
8
+ import { BillPayWidgetMonite as n } from "./index20.js";
9
+ import "./index21.js";
10
+ import { BillPayWidgetNative as r } from "./index32.js";
11
+ import "./index33.js";
12
+ import { jsx as i } from "react/jsx-runtime";
13
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js
14
+ function a({ implementation: a, ...o }) {
15
+ let s = t().implementation, c = a ?? s ?? e.Monite;
16
+ return c === e.Native ? /* @__PURE__ */ i(r, {
17
+ implementation: c,
18
+ ...o
19
+ }) : /* @__PURE__ */ i(n, {
20
+ implementation: c,
21
+ ...o
22
+ });
23
+ }
24
+ //#endregion
25
+ export { a as BillPayWidget, a as default };
@@ -13,94 +13,95 @@ import { VendorInlineForm as o } from "./index4.js";
13
13
  import { useCallback as s, useEffect as c, useMemo as l, useState as u } from "react";
14
14
  import { jsx as d } from "react/jsx-runtime";
15
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js
16
- var f = 25, p = 300;
17
- function m({ payableId: m, counterpartId: h, payableCounterpartId: g, onCounterpartChange: _, labels: v }) {
18
- let y = {
16
+ var f = 10, p = 300;
17
+ function m({ payableId: m, counterpartId: h, payableCounterpartId: g, onCounterpartChange: _, requiredError: v, labels: y }) {
18
+ let b = {
19
19
  ...e,
20
- ...v
21
- }, [b, x] = u(""), [S, C] = u(""), [w, T] = u(), [E, D] = u(!1), O = s((e) => {
22
- D(!0), _(e);
23
- }, [_]), k = t(m, { enabled: !!m && !h && !g }).data?.suggested_counterpart?.id;
20
+ ...y
21
+ }, [x, S] = u(""), [C, w] = u(""), [T, E] = u(), [D, O] = u(!1), k = s((e) => {
22
+ O(!0), _(e);
23
+ }, [_]), A = t(m, { enabled: !!m && !h && !g }).data?.suggested_counterpart?.id;
24
24
  c(() => {
25
- !E && !h && !g && k && O(k);
25
+ !D && !h && !g && A && k(A);
26
26
  }, [
27
27
  h,
28
28
  g,
29
- E,
30
- k,
31
- O
29
+ D,
30
+ A,
31
+ k
32
32
  ]), c(() => {
33
33
  let e = setTimeout(() => {
34
- C(b.trim());
34
+ w(x.trim());
35
35
  }, p);
36
36
  return () => clearTimeout(e);
37
- }, [b]);
38
- let A = i({
37
+ }, [x]);
38
+ let j = i({
39
39
  sort: "counterpart_name",
40
40
  order: "asc",
41
41
  limit: f,
42
- counterpart_name__icontains: S || void 0,
43
- is_vendor: !0
44
- }), j = a({ selectedId: h }), M = l(() => {
45
- let e = j.counterpart;
42
+ counterpart_name__icontains: C || void 0,
43
+ is_vendor: !0,
44
+ enabled: !!C
45
+ }), M = a({ selectedId: h }), N = l(() => {
46
+ let e = M.counterpart;
46
47
  if (!e) return;
47
- let t = j.bankAccounts?.find((e) => e.is_default_for_currency);
48
+ let t = M.bankAccounts?.find((e) => e.is_default_for_currency);
48
49
  return {
49
50
  name: r(e),
50
51
  email: n(e),
51
- methodLabel: t ? y.achMethod : y.noMethod,
52
+ methodLabel: t ? b.achMethod : b.noMethod,
52
53
  fields: t ? [
53
54
  {
54
- label: y.accountHolder,
55
+ label: b.accountHolder,
55
56
  value: t.account_holder_name ?? ""
56
57
  },
57
58
  {
58
- label: y.routingNumber,
59
+ label: b.routingNumber,
59
60
  value: t.routing_number ?? ""
60
61
  },
61
62
  {
62
- label: y.accountNumber,
63
+ label: b.accountNumber,
63
64
  value: "",
64
65
  maskedValue: t.account_number ?? ""
65
66
  }
66
67
  ] : []
67
68
  };
68
69
  }, [
69
- j.bankAccounts,
70
- j.counterpart,
71
- y
72
- ]), N = l(() => (A.data?.data ?? []).map((e) => ({
70
+ M.bankAccounts,
71
+ M.counterpart,
72
+ b
73
+ ]), P = l(() => (j.data?.data ?? []).map((e) => ({
73
74
  name: r(e),
74
75
  email: n(e),
75
- onSelect: () => O(e.id)
76
- })), [A.data, O]), P = s(() => T(void 0), []), F = s((e) => {
77
- T(void 0), O(e);
78
- }, [O]);
79
- return w ? {
76
+ onSelect: () => k(e.id)
77
+ })), [j.data, k]), F = s(() => E(void 0), []), I = s((e) => {
78
+ E(void 0), k(e);
79
+ }, [k]);
80
+ return T ? {
80
81
  mode: "creating",
81
82
  newVendorForm: /* @__PURE__ */ d(o, {
82
- mode: w,
83
- counterpart: w === "edit" ? j.counterpart : void 0,
84
- primaryAddress: w === "edit" ? j.primaryAddress : void 0,
85
- initialName: w === "create" ? b : void 0,
86
- onSaved: F,
87
- onCancel: P
83
+ mode: T,
84
+ counterpart: T === "edit" ? M.counterpart : void 0,
85
+ primaryAddress: T === "edit" ? M.primaryAddress : void 0,
86
+ initialName: T === "create" ? x : void 0,
87
+ onSaved: I,
88
+ onCancel: F
88
89
  }),
89
- onClear: P
90
- } : M ? {
90
+ onClear: F
91
+ } : N ? {
91
92
  mode: "resolved",
92
- summary: M,
93
- onEdit: () => T("edit"),
94
- onClear: () => O(void 0)
93
+ summary: N,
94
+ onEdit: () => E("edit"),
95
+ onClear: () => k(void 0)
95
96
  } : {
96
97
  mode: "selecting",
97
- error: A.isError ? y.searchFailed : j.isError ? y.vendorDetailsFailed : void 0,
98
+ error: j.isError ? b.searchFailed : M.isError ? b.vendorDetailsFailed : v,
98
99
  search: {
99
- query: b,
100
- onQueryChange: x,
101
- isLoading: A.isLoading,
102
- onAddVendor: () => T("create"),
103
- results: N
100
+ query: x,
101
+ onQueryChange: S,
102
+ isLoading: j.isLoading,
103
+ onAddVendor: () => E("create"),
104
+ results: P
104
105
  }
105
106
  };
106
107
  }
@@ -12,7 +12,7 @@ function r(e) {
12
12
  return Number.isFinite(n) && n > 0 ? n : null;
13
13
  }
14
14
  function i(e) {
15
- return !!(e.description.trim() || n(e.price) !== null || n(e.amount) !== null);
15
+ return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
16
16
  }
17
17
  function a(e) {
18
18
  return n(e) ?? 0;
@@ -1,21 +1,34 @@
1
1
  import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index2.js";
2
- import { parseMoneyToMinorUnits as t, parseQuantity as n } from "./index6.js";
2
+ import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index6.js";
3
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js
4
- var r = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
5
- function i(e) {
6
- let n = e.trim();
7
- return !n || t(n) !== null ? !0 : r.test(n) ? Number(n.replaceAll(",", "")) === 0 : !1;
4
+ var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
5
+ function a(e) {
6
+ let t = e.trim();
7
+ return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
8
8
  }
9
- function a(r, i = e) {
9
+ function o(t, i = e) {
10
10
  let a = {};
11
- for (let e of r) {
12
- let r = t(e.price), o = t(e.amount), s = {};
13
- e.price.trim() && r === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), (r !== null || o !== null) && n(e.quantity) === null && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
11
+ for (let e of t) {
12
+ let t = n(e.price), o = n(e.amount), s = {};
13
+ e.price.trim() && t === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), (t !== null || o !== null) && r(e.quantity) === null && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
14
14
  }
15
15
  return Object.keys(a).length ? a : void 0;
16
16
  }
17
- function o(t, n, r, a = e) {
18
- return !i(t) || !i(n) || r !== void 0 && (!r.trim() || !i(r)) ? { form: a.totalsNeedAttention } : void 0;
17
+ function s(i, a, o, s = e) {
18
+ let c = {};
19
+ a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField), i.invoiceDate.trim() || (c.invoiceDate = s.requiredField), i.dueDate.trim() || (c.dueDate = s.requiredField);
20
+ let l = {};
21
+ return o.forEach((e, i) => {
22
+ if (i > 0 && !t(e)) return;
23
+ let a = {};
24
+ e.description.trim() || (a.description = s.requiredField), r(e.quantity) === null && (a.quantity = s.requiredField), n(e.price) === null && n(e.amount) === null && (a.price = s.requiredField, a.amount = s.requiredField), Object.keys(a).length && (l[e.id] = a);
25
+ }), {
26
+ formErrors: Object.keys(c).length ? c : void 0,
27
+ lineItemErrors: Object.keys(l).length ? l : void 0
28
+ };
29
+ }
30
+ function c(t, r, i, o = e) {
31
+ return !a(t) || !a(r) || i !== void 0 && n(i) === null ? { form: o.totalsNeedAttention } : void 0;
19
32
  }
20
33
  //#endregion
21
- export { o as validateBillTotals, a as validateLineItems };
34
+ export { s as validateBillCompleteness, c as validateBillTotals, o as validateLineItems };
@@ -9,126 +9,143 @@ import { useReplacePayableLineItemsMutation as n } from "../../data-access/dist/
9
9
  import { useCreatePayableMutation as r, useSubmitPayableForApprovalMutation as i, useUpdatePayableMutation as a, useValidatePayableMutation as o } from "../../data-access/dist/index7.js";
10
10
  import "../../data-access/dist/index.js";
11
11
  import { mapBillFormToPayload as s, mapLineItemsToPayload as c } from "./index6.js";
12
- import { validateBillTotals as l, validateLineItems as u } from "./index7.js";
13
- import { useCallback as d, useRef as f, useState as p } from "react";
12
+ import { validateBillCompleteness as l, validateBillTotals as u, validateLineItems as d } from "./index7.js";
13
+ import { useCallback as f, useRef as p, useState as m } from "react";
14
14
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js
15
- var m = {
15
+ var h = {
16
16
  document_id: "invoiceNumber",
17
17
  issued_at: "invoiceDate",
18
- due_date: "dueDate"
18
+ due_date: "dueDate",
19
+ counterpart_id: "vendor"
19
20
  };
20
- function h(e) {
21
+ function g(e) {
21
22
  return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
22
23
  }
23
- function g(e, n = t) {
24
+ function _(e, n = t) {
24
25
  let r = {}, i = [];
25
26
  for (let t of e) {
26
- let e = t.loc[0] ?? n.unknownValidationField, a = m[e], o = h(t) ? n.requiredField : t.msg;
27
+ let e = t.loc[0] ?? n.unknownValidationField, a = h[e], o = g(t) ? n.requiredField : t.msg;
27
28
  a ? r[a] = o : i.push(n.unmappedValidationError(e, o));
28
29
  }
29
30
  return i.length && (r.form = i.join(" ")), r;
30
31
  }
31
- function _({ payableId: m, form: h, counterpartId: _, onSaved: v, onPayableCreated: y, onDraftSaved: b, onFinalized: x, labels: S }) {
32
- let C = {
32
+ function v(e, t) {
33
+ if (!e && !t) return;
34
+ let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
35
+ for (let i of r) n[i] = {
36
+ ...e?.[i],
37
+ ...t?.[i]
38
+ };
39
+ return n;
40
+ }
41
+ function y({ payableId: h, form: g, counterpartId: y, onSaved: b, onPayableCreated: x, onDraftSaved: S, onFinalized: C, labels: w }) {
42
+ let T = {
33
43
  ...t,
34
- ...S
35
- }, [w, T] = p(), E = m ?? w, [D, O] = p(), k = f(!1), A = r(), j = a(), M = n(), N = o(), P = i(), F = d(() => {
36
- let e = u(h.lineItems, C), t = l(h.discount, h.tax, h.totalOverride, C);
37
- return h.setLineItemErrors(e), !e && !t || (h.setErrors(e ? { form: C.lineItemsNeedAttention } : t), !1);
38
- }, [h, C]), I = d(async () => {
44
+ ...w
45
+ }, [E, D] = m(), O = h ?? E, [k, A] = m(), j = p(!1), M = r(), N = a(), P = n(), F = o(), I = i(), L = f(() => {
46
+ let t = d(g.lineItems, T), n = u(g.discount, g.tax, g.totalOverride, T);
47
+ return g.setLineItemErrors(t), !t && !n || (t ? (g.setErrors(void 0), e.error(T.lineItemsNeedAttention)) : g.setErrors(n), !1);
48
+ }, [g, T]), R = f(async () => {
39
49
  let e = s({
40
- values: h.values,
41
- counterpartId: _,
42
- editedTotals: h.isTotalsDirty ? {
43
- discount: h.discount,
44
- tax: h.tax,
45
- total: h.totalOverride
50
+ values: g.values,
51
+ counterpartId: y,
52
+ editedTotals: g.isTotalsDirty ? {
53
+ discount: g.discount,
54
+ tax: g.tax,
55
+ total: g.totalOverride
46
56
  } : void 0
47
- }), t = E;
48
- if (t ? await j.mutateAsync({
57
+ }), t = O;
58
+ if (t ? await N.mutateAsync({
49
59
  path: { payable_id: t },
50
60
  body: e
51
- }) : (t = (await A.mutateAsync({ body: e }))?.id, t && (T(t), y?.(t))), !t) throw Error("Payable was created without an id");
52
- return await M.mutateAsync({
61
+ }) : (t = (await M.mutateAsync({ body: e }))?.id, t && (D(t), x?.(t))), !t) throw Error("Payable was created without an id");
62
+ return await P.mutateAsync({
53
63
  path: { payable_id: t },
54
- body: { data: c(h.lineItems) }
64
+ body: { data: c(g.lineItems) }
55
65
  }), t;
56
66
  }, [
57
- _,
58
- A,
59
- h.discount,
60
- h.isTotalsDirty,
61
- h.lineItems,
62
- h.tax,
63
- h.totalOverride,
64
- h.values,
65
67
  y,
66
- E,
67
68
  M,
68
- j
69
+ g.discount,
70
+ g.isTotalsDirty,
71
+ g.lineItems,
72
+ g.tax,
73
+ g.totalOverride,
74
+ g.values,
75
+ x,
76
+ O,
77
+ P,
78
+ N
69
79
  ]);
70
80
  return {
71
- saveDraft: d(async () => {
72
- if (!k.current && F()) {
73
- k.current = !0, O("draft");
81
+ saveDraft: f(async () => {
82
+ if (!j.current && L()) {
83
+ j.current = !0, A("draft");
74
84
  try {
75
- let t = await I();
76
- h.setErrors(void 0), v?.(t), b?.(t), e.success(C.draftSaved);
85
+ let t = await R();
86
+ g.setErrors(void 0), b?.(t), S?.(t), e.success(T.draftSaved);
77
87
  } catch {
78
- h.setErrors({ form: C.saveFailed });
88
+ g.setErrors({ form: T.saveFailed });
79
89
  } finally {
80
- O(void 0), k.current = !1;
90
+ A(void 0), j.current = !1;
81
91
  }
82
92
  }
83
93
  }, [
84
- h,
85
- F,
86
- C.draftSaved,
87
- C.saveFailed,
94
+ g,
95
+ L,
96
+ T.draftSaved,
97
+ T.saveFailed,
98
+ S,
88
99
  b,
89
- v,
90
- I
100
+ R
91
101
  ]),
92
- finalize: d(async () => {
93
- if (!k.current && F()) {
94
- k.current = !0, O("finalize");
102
+ finalize: f(async () => {
103
+ if (j.current) return;
104
+ let t = d(g.lineItems, T), n = u(g.discount, g.tax, g.totalOverride, T), { formErrors: r, lineItemErrors: i } = l(g.values, y, g.lineItems, T), a = v(i, t);
105
+ g.setLineItemErrors(a);
106
+ let o = {
107
+ ...r,
108
+ ...n
109
+ };
110
+ if (g.setErrors(Object.keys(o).length ? o : void 0), t && e.error(T.lineItemsNeedAttention), !(a || Object.keys(o).length)) {
111
+ j.current = !0, A("finalize");
95
112
  try {
96
113
  let t;
97
114
  try {
98
- t = await I();
115
+ t = await R();
99
116
  } catch {
100
- h.setErrors({ form: C.saveFailed });
117
+ g.setErrors({ form: T.saveFailed });
101
118
  return;
102
119
  }
103
- v?.(t);
120
+ b?.(t);
104
121
  try {
105
- let n = await N.mutateAsync({ path: { payable_id: t } });
122
+ let n = await F.mutateAsync({ path: { payable_id: t } });
106
123
  if (n.validation_errors.length) {
107
- h.setErrors(g(n.validation_errors, C));
124
+ g.setErrors(_(n.validation_errors, T));
108
125
  return;
109
126
  }
110
- await P.mutateAsync({ path: { payable_id: t } }), h.setErrors(void 0), x?.(t), e.success(C.billFinalized);
127
+ await I.mutateAsync({ path: { payable_id: t } }), g.setErrors(void 0), C?.(t), e.success(T.billFinalized);
111
128
  } catch {
112
- h.setErrors({ form: C.finalizeFailed });
129
+ g.setErrors({ form: T.finalizeFailed });
113
130
  }
114
131
  } finally {
115
- O(void 0), k.current = !1;
132
+ A(void 0), j.current = !1;
116
133
  }
117
134
  }
118
135
  }, [
119
- h,
120
- F,
136
+ y,
137
+ g,
138
+ T,
121
139
  C,
122
- x,
123
- v,
140
+ b,
141
+ R,
124
142
  I,
125
- P,
126
- N
143
+ F
127
144
  ]),
128
- payableId: E,
129
- isSavingDraft: D === "draft",
130
- isFinalizing: D === "finalize"
145
+ payableId: O,
146
+ isSavingDraft: k === "draft",
147
+ isFinalizing: k === "finalize"
131
148
  };
132
149
  }
133
150
  //#endregion
134
- export { g as mapValidationErrorsToForm, _ as useBillCreateController };
151
+ export { _ as mapValidationErrorsToForm, y as useBillCreateController };