@tesouro/embedded-components-react 0.11.120 → 0.11.123

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 (119) hide show
  1. package/README.md +6 -3
  2. package/dist/index.css +32 -161
  3. package/dist/index.d.ts +40 -8
  4. package/dist/index.js +29 -28
  5. package/dist/lib/ExpenseManagementWidget.d.ts +11 -2
  6. package/dist/lib/ReceivablesWidget.d.ts +29 -6
  7. package/dist/lib/ReceivablesWidget.js +3 -1
  8. package/dist/lib/WidgetSuite.d.ts +38 -6
  9. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/ExpenseManagementWidget/ExpenseManagementWidget.js +343 -264
  10. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/ExpenseManagementWidget/labels.js +14 -0
  11. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/ExpenseManagementWidget/permissions.js +6 -3
  12. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/ExpenseManagementWidget/useExpenseTabBadgeCounts.js +34 -19
  13. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/ExpenseManagementWidget/useExpensesTransactions.js +100 -98
  14. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/TransactionDetails/TransactionDetailsActionsFeature.js +27 -24
  15. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/TransactionDetails/TransactionDetailsFeature.js +1 -0
  16. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/expenseStatus.js +2 -2
  17. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/feature/dist/index2.js +43 -44
  18. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/feature/dist/index4.js +79 -40
  19. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/ui/dist/index2.js +10 -0
  20. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/ui/dist/index3.js +47 -46
  21. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/ui/dist/index4.js +78 -84
  22. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/ui/dist/index5.js +165 -158
  23. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/ui/dist/index6.js +38 -100
  24. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/ui/dist/index7.js +77 -54
  25. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/AccordionItemCard/AccordionItemCard.js +213 -229
  26. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseStatusBadge/ExpenseStatusBadge.js +6 -8
  27. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpensesScreen/ExpensesScreen.js +66 -73
  28. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpensesTransactionsFilterBar/ExpensesTransactionsFilterBar.js +13 -13
  29. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpensesTransactionsTable/ExpensesTransactionsTable.js +123 -80
  30. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpensesTransactionsTable/labels.js +1 -0
  31. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/FileViewer/FileViewer.js +83 -74
  32. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/TransactionDetails/DeleteReceiptDialog/DeleteReceiptDialog.js +22 -30
  33. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/TransactionDetails/TransactionDetails.js +176 -259
  34. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/TransactionDetails/labels.js +4 -2
  35. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/TransactionDetailsActions/BulkProgress.js +1 -0
  36. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/TransactionDetailsActions/TransactionDetailsActions.js +112 -121
  37. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/TransactionDetailsActions/labels.js +1 -0
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +3 -1
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivableAttachmentsSection.js +1 -1
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivableCustomerSection.js +1 -1
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +342 -295
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentTerms.js +1 -1
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +1 -1
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/recurrence.js +1 -1
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/reminders.js +1 -1
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/tabs.js +26 -0
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +1 -1
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +1 -1
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/labels.js +1 -1
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +30 -26
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +18 -2
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +121 -11
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +100 -11
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +39 -27
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +2 -205
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +11 -52
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +11 -210
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +27 -159
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +203 -14
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +51 -22
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +210 -2
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +154 -111
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +15 -3
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +21 -195
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +3 -2
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +116 -53
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +3 -22
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +197 -8
  69. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +2 -78
  70. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +53 -39
  71. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +20 -17
  72. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +8 -41
  73. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +73 -25
  74. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +36 -17
  75. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +17 -9
  76. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +39 -34
  77. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +29 -14
  78. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +18 -24
  79. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +8 -85
  80. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +33 -490
  81. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +15 -2
  82. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +22 -42
  83. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +82 -65
  84. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +475 -426
  85. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +2 -226
  86. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +46 -21
  87. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +69 -5
  88. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +445 -0
  89. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index48.js +208 -246
  90. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +22 -2
  91. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +5 -129
  92. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +247 -222
  93. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +1 -2
  94. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index54.js +125 -242
  95. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index55.js +23 -56
  96. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index56.js +229 -209
  97. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index57.js +3 -47
  98. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index58.js +248 -0
  99. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index59.js +60 -0
  100. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +2 -17
  101. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index60.js +194 -0
  102. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index61.js +47 -0
  103. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +53 -117
  104. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +9 -99
  105. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +3 -40
  106. package/dist/libs/tesouro-embedded-components-react/shared/expense-requirements/feature/dist/lib/ExpenseRequirementsWidget.js +41 -32
  107. package/dist/libs/tesouro-embedded-components-react/shared/expense-requirements/ui/dist/index3.js +43 -53
  108. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  109. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/index.js +3 -1
  110. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/CopyAddress/CopyAddress.js +55 -0
  111. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/UploadTray/UploadTray.js +84 -0
  112. package/dist/libs/tesouro-embedded-components-react/upload-receipt-widget/feature/dist/lib/UploadReceiptWidget.js +126 -73
  113. package/dist/libs/tesouro-embedded-components-react/upload-receipt-widget/ui/dist/index2.js +14 -1
  114. package/dist/libs/tesouro-embedded-components-react/upload-receipt-widget/ui/dist/index3.js +9 -8
  115. package/dist/libs/tesouro-embedded-components-react/upload-receipt-widget/ui/dist/index4.js +75 -128
  116. package/dist/packages/shared-ui-shadcn/dist/index.js +1399 -1302
  117. package/package.json +1 -1
  118. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseStatusBadge/badgeTones.js +0 -9
  119. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +0 -27
@@ -0,0 +1,84 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { Button as e, Tooltip as t, TooltipContent as n, TooltipProvider as r, TooltipTrigger as i, usePortalContainer as a } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { useState as o } from "react";
7
+ import { createPortal as s } from "react-dom";
8
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
9
+ import { ChevronDown as u, ChevronUp as d, X as f } from "lucide-react";
10
+ // ../../libs/tesouro-embedded-components-react/shared/ui/dist/lib/UploadTray/UploadTray.js
11
+ function p({ title: p, items: m, summary: h, closeLabel: g, collapseLabel: _, expandLabel: v, retryLabel: y, onClose: b }) {
12
+ let [x, S] = o(!1), C = a();
13
+ return typeof document > "u" ? null : s(/* @__PURE__ */ l("section", {
14
+ "aria-label": p,
15
+ className: "ttw:fixed ttw:bottom-4 ttw:right-4 ttw:z-50 ttw:flex ttw:max-h-[calc(100dvh-2rem)] ttw:w-80 ttw:max-w-[calc(100vw-2rem)] ttw:flex-col ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:shadow-md",
16
+ children: [
17
+ /* @__PURE__ */ l("div", {
18
+ className: "ttw:flex ttw:items-center ttw:gap-2",
19
+ children: [/* @__PURE__ */ c("span", {
20
+ className: "ttw:flex-1 ttw:text-sm ttw:font-semibold",
21
+ children: p
22
+ }), /* @__PURE__ */ l(r, { children: [/* @__PURE__ */ l(t, { children: [/* @__PURE__ */ c(i, {
23
+ asChild: !0,
24
+ children: /* @__PURE__ */ c(e, {
25
+ type: "button",
26
+ variant: "ghost",
27
+ size: "icon-sm",
28
+ "aria-expanded": !x,
29
+ "aria-label": x ? v : _,
30
+ onClick: () => S((e) => !e),
31
+ children: c(x ? d : u, { className: "ttw:size-4" })
32
+ })
33
+ }), /* @__PURE__ */ c(n, { children: x ? v : _ })] }), /* @__PURE__ */ l(t, { children: [/* @__PURE__ */ c(i, {
34
+ asChild: !0,
35
+ children: /* @__PURE__ */ c(e, {
36
+ type: "button",
37
+ variant: "ghost",
38
+ size: "icon-sm",
39
+ "aria-label": g,
40
+ onClick: b,
41
+ children: /* @__PURE__ */ c(f, { className: "ttw:size-4" })
42
+ })
43
+ }), /* @__PURE__ */ c(n, { children: g })] })] })]
44
+ }),
45
+ h && /* @__PURE__ */ c("p", {
46
+ role: "status",
47
+ className: "ttw:mt-2 ttw:text-sm ttw:text-muted-foreground",
48
+ children: h
49
+ }),
50
+ !x && /* @__PURE__ */ c("ul", {
51
+ className: "ttw:mt-3 ttw:flex ttw:min-h-0 ttw:flex-col ttw:gap-3 ttw:overflow-y-auto",
52
+ children: m.map((t) => /* @__PURE__ */ l("li", {
53
+ className: "ttw:flex ttw:flex-col ttw:gap-1",
54
+ children: [
55
+ /* @__PURE__ */ l("div", {
56
+ className: "ttw:flex ttw:items-center ttw:gap-2",
57
+ children: [/* @__PURE__ */ c("span", {
58
+ className: "ttw:min-w-0 ttw:flex-1 ttw:truncate ttw:text-sm",
59
+ title: t.name,
60
+ children: t.name
61
+ }), t.onRetry && /* @__PURE__ */ c(e, {
62
+ variant: "ghost",
63
+ size: "sm",
64
+ onClick: t.onRetry,
65
+ children: y
66
+ })]
67
+ }),
68
+ /* @__PURE__ */ c("span", {
69
+ className: "ttw:text-xs ttw:text-muted-foreground",
70
+ children: t.status
71
+ }),
72
+ t.progress !== void 0 && /* @__PURE__ */ c("progress", {
73
+ "aria-label": t.name,
74
+ value: t.progress,
75
+ max: 100,
76
+ className: "ttw:w-full"
77
+ })
78
+ ]
79
+ }, t.id))
80
+ })
81
+ ]
82
+ }), C ?? document.body);
83
+ }
84
+ export { p as UploadTray };
@@ -2,85 +2,138 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { toast as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { EmbeddedToaster as t } from "../../../../shared/ui/dist/lib/EmbeddedToaster.js";
5
+ import { UploadTray as e } from "../../../../shared/ui/dist/lib/UploadTray/UploadTray.js";
7
6
  import "../../../../shared/ui/dist/index.js";
8
- import { UploadReceiptToastLabels as n } from "../../../ui/dist/index2.js";
9
- import { UploadReceiptButton as r } from "../../../ui/dist/index3.js";
10
- import { UploadReceiptModal as i } from "../../../ui/dist/index4.js";
7
+ import { UploadReceiptToastLabels as t } from "../../../ui/dist/index2.js";
8
+ import { UploadReceiptButton as n } from "../../../ui/dist/index3.js";
9
+ import { UploadReceiptModal as r } from "../../../ui/dist/index4.js";
11
10
  import "../../../ui/dist/index.js";
12
- import { useEffect as a, useRef as o, useState as s } from "react";
11
+ import { useEffect as i, useImperativeHandle as a, useRef as o, useState as s } from "react";
13
12
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
14
13
  // ../../libs/tesouro-embedded-components-react/upload-receipt-widget/feature/dist/lib/UploadReceiptWidget.js
15
- var u = 3e3, d = 5e3, f = 10;
16
- function p(e, t) {
17
- return e ? e.stillProcessing > 0 ? n.MatchingUnfinished(e.stillProcessing) : e.total === 0 ? n.UploadedAll(t) : e.matched === e.total ? n.MatchedAll(e.matched) : n.MatchedPartial(e.matched, e.total) : n.UploadedAll(t);
14
+ var u = 10;
15
+ function d(e, n) {
16
+ return e ? e.stillProcessing > 0 ? t.MatchingUnfinished(e.stillProcessing) : e.total === 0 ? t.UploadedAll(n) : e.matched === e.total ? t.MatchedAll(e.matched) : t.MatchedPartial(e.matched, e.total) : t.UploadedAll(n);
18
17
  }
19
- function m({ emailAddress: m, onFileUpload: h, onAwaitMatching: g, isUploading: _ = !1 }) {
20
- let [v, y] = s(!1), [b, x] = s(!1), S = o(!0);
21
- return a(() => (S.current = !0, () => {
22
- S.current = !1;
23
- }), []), /* @__PURE__ */ l("div", {
18
+ function f({ emailAddress: f, onFileUpload: p, onAwaitMatching: m, isUploading: h = !1, ref: g }) {
19
+ let [_, v] = s(!1), [y, b] = s(!1), [x, S] = s(!1), [C, w] = s(""), T = o(0), [E, D] = s([]), O = o(!0);
20
+ i(() => (O.current = !0, () => {
21
+ O.current = !1;
22
+ }), []);
23
+ let k = async (e) => {
24
+ if (!p || h || y || e.length === 0) return;
25
+ if (e.length > u) {
26
+ ++T.current, D([]), w(t.TooManyFiles(u)), S(!0);
27
+ return;
28
+ }
29
+ let n = ++T.current;
30
+ b(!0), D(e.map((e) => ({
31
+ file: e,
32
+ status: "queued"
33
+ }))), w(t.Uploading(e.length)), S(!0), v(!1);
34
+ let r = 0, i = 0;
35
+ for (let [t, n] of e.entries()) {
36
+ O.current && D((e) => e.map((e, n) => n === t ? {
37
+ ...e,
38
+ status: "uploading"
39
+ } : e));
40
+ try {
41
+ await p(n), r++, O.current && D((e) => e.map((e, n) => n === t ? {
42
+ ...e,
43
+ status: "uploaded"
44
+ } : e));
45
+ } catch {
46
+ i++, O.current && D((e) => e.map((e, n) => n === t ? {
47
+ ...e,
48
+ status: "failed"
49
+ } : e));
50
+ }
51
+ }
52
+ let a;
53
+ try {
54
+ a = m?.(r);
55
+ } catch {
56
+ a = void 0;
57
+ }
58
+ if (i > 0 || r === 0) {
59
+ a?.catch(() => void 0), O.current && (w(r === 0 ? e.length === 1 ? t.UploadFailedSingle : t.UploadFailedAll(i) : t.UploadedPartial(r, e.length)), b(!1));
60
+ return;
61
+ }
62
+ if (O.current && b(!1), !O.current) {
63
+ a?.catch(() => void 0);
64
+ return;
65
+ }
66
+ let o = null;
67
+ if (a) {
68
+ w(t.Matching(r));
69
+ try {
70
+ o = await a;
71
+ } catch {}
72
+ }
73
+ O.current && n === T.current && w(d(o, r));
74
+ }, A = async (e) => {
75
+ if (!p || h || y) return;
76
+ let n = E[e]?.file;
77
+ if (!n) return;
78
+ let r = ++T.current;
79
+ b(!0);
80
+ let i = !1, a = () => {
81
+ i || (i = !0, O.current && b(!1));
82
+ };
83
+ D((t) => t.map((t, n) => n === e ? {
84
+ ...t,
85
+ status: "uploading"
86
+ } : t));
87
+ try {
88
+ await p(n), D((t) => t.map((t, n) => n === e ? {
89
+ ...t,
90
+ status: "uploaded"
91
+ } : t)), a();
92
+ let t = null;
93
+ try {
94
+ t = await m?.(1) ?? null;
95
+ } catch {}
96
+ O.current && r === T.current && w(d(t, 1));
97
+ } catch {
98
+ try {
99
+ (m?.(0))?.catch(() => void 0);
100
+ } catch {}
101
+ if (!O.current) return;
102
+ w(t.UploadFailedSingle), D((t) => t.map((t, n) => n === e ? {
103
+ ...t,
104
+ status: "failed"
105
+ } : t));
106
+ } finally {
107
+ a();
108
+ }
109
+ };
110
+ return a(g, () => ({ upload: (e) => void k(e) })), /* @__PURE__ */ l("div", {
24
111
  className: "ttw:relative",
25
- children: [
26
- /* @__PURE__ */ c(t, {}),
27
- /* @__PURE__ */ c(r, {
28
- onClick: () => y((e) => !e),
29
- open: v
112
+ children: [x && /* @__PURE__ */ c(e, {
113
+ title: t.TrayTitle,
114
+ summary: C,
115
+ closeLabel: t.CloseTray,
116
+ collapseLabel: t.CollapseTray,
117
+ expandLabel: t.ExpandTray,
118
+ retryLabel: t.Retry,
119
+ onClose: () => S(!1),
120
+ items: E.map((e, n) => ({
121
+ id: String(n),
122
+ name: e.file.name,
123
+ status: e.status === "failed" ? t.FileFailed : e.status === "uploaded" ? t.FileUploaded : e.status === "queued" ? t.FileQueued : t.FileUploading(n + 1, E.length),
124
+ onRetry: e.status === "failed" && !y ? () => void A(n) : void 0
125
+ }))
126
+ }), /* @__PURE__ */ c(r, {
127
+ trigger: /* @__PURE__ */ c(n, {
128
+ onClick: () => v((e) => !e),
129
+ open: _
30
130
  }),
31
- /* @__PURE__ */ c(i, {
32
- open: v,
33
- onClose: () => y(!1),
34
- emailAddress: m,
35
- onFilesSelected: async (t) => {
36
- if (!h || _ || b || t.length === 0) return;
37
- if (t.length > f) {
38
- e.error(n.TooManyFiles(f), { duration: d });
39
- return;
40
- }
41
- x(!0), y(!1);
42
- let r = e.loading(n.Uploading(t.length)), i = 0, a = 0;
43
- for (let e of t) try {
44
- await h(e), i++;
45
- } catch {
46
- a++;
47
- }
48
- let o;
49
- try {
50
- o = g?.(i);
51
- } catch {
52
- o = void 0;
53
- }
54
- if (a > 0 || i === 0) {
55
- if (o?.catch(() => void 0), !S.current) {
56
- e.dismiss(r);
57
- return;
58
- }
59
- e.error(i === 0 ? t.length === 1 ? n.UploadFailedSingle : n.UploadFailedAll(a) : n.UploadedPartial(i, t.length), {
60
- id: r,
61
- duration: d
62
- }), x(!1);
63
- return;
64
- }
65
- if (x(!1), !S.current) {
66
- o?.catch(() => void 0), e.dismiss(r);
67
- return;
68
- }
69
- let s = null;
70
- if (o) {
71
- e.loading(n.Matching(i), { id: r });
72
- try {
73
- s = await o;
74
- } catch {}
75
- }
76
- S.current ? e.success(p(s, i), {
77
- id: r,
78
- duration: u
79
- }) : e.dismiss(r);
80
- },
81
- isUploading: _ || b
82
- })
83
- ]
131
+ open: _,
132
+ onClose: () => v(!1),
133
+ emailAddress: f,
134
+ onFilesSelected: k,
135
+ isUploading: h || y
136
+ })]
84
137
  });
85
138
  }
86
- export { m as UploadReceiptWidget };
139
+ export { f as UploadReceiptWidget };
@@ -4,7 +4,11 @@ var e = {
4
4
  Subtitle: "Upload card transaction receipts and we'll automatically match them to the correct transaction.",
5
5
  DropZonePrefix: "Drop your files here, or",
6
6
  ClickToBrowse: "click to browse",
7
- FileTypes: "PDF, PNG or JPG (max. 20MB)",
7
+ FileTypes: "PDF, PNG or JPG, 10 files at a time",
8
+ TooManyFiles: "Choose up to 10 files at a time.",
9
+ CopyAddress: "Copy email address",
10
+ CopiedAddress: "Email address copied",
11
+ CopyFailed: "Couldn’t copy email address",
8
12
  OrSendViaEmail: "Or send via email",
9
13
  EmailDescription: "All receipts sent to this email address will be automatically processed and matched to expenses.",
10
14
  CopyButton: "Copy",
@@ -17,6 +21,15 @@ function n(e) {
17
21
  return e === 1 ? "1 attachment" : `${e} attachments`;
18
22
  }
19
23
  var r = {
24
+ TrayTitle: "Receipt uploads",
25
+ CloseTray: "Close receipt uploads",
26
+ CollapseTray: "Collapse receipt uploads",
27
+ ExpandTray: "Expand receipt uploads",
28
+ Retry: "Try again",
29
+ FileUploading: (e, t) => `Uploading ${e} of ${t}`,
30
+ FileUploaded: "Uploaded",
31
+ FileQueued: "Waiting to upload",
32
+ FileFailed: "Couldn’t upload",
20
33
  Uploading: (e) => `Uploading ${n(e)}`,
21
34
  UploadedAll: (e) => `Uploaded ${n(e)}`,
22
35
  UploadFailedSingle: "Upload failed",
@@ -4,15 +4,16 @@
4
4
  "use client";
5
5
  import { Button as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
6
  import { UploadReceiptWidgetLabels as t } from "./index2.js";
7
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
8
- import { ChevronDown as i, ChevronUp as a } from "lucide-react";
7
+ import { jsx as n } from "react/jsx-runtime";
9
8
  // ../../libs/tesouro-embedded-components-react/upload-receipt-widget/ui/dist/index3.js
10
- function o({ onClick: o, open: s = !1 }) {
11
- return /* @__PURE__ */ r(e, {
12
- onClick: o,
9
+ function r({ open: r = !1, ref: i, ...a }) {
10
+ return /* @__PURE__ */ n(e, {
11
+ ...a,
12
+ ref: i,
13
13
  size: "lg",
14
- className: "ttw:cursor-pointer ttw:shadow-xs",
15
- children: [t.ButtonLabel, n(s ? a : i, { size: 16 })]
14
+ "aria-expanded": r,
15
+ "aria-haspopup": "dialog",
16
+ children: t.ButtonLabel
16
17
  });
17
18
  }
18
- export { o as UploadReceiptButton };
19
+ export { r as UploadReceiptButton };
@@ -2,141 +2,88 @@
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 { UploadReceiptModalLabels as t } from "./index2.js";
7
- import { useRef as n, useState as r } from "react";
8
- import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
9
- import { CloudUpload as s, Copy as c, Loader2 as l, X as u } from "lucide-react";
5
+ import { Button as e, Heading as t, Popover as n, PopoverContent as r, PopoverTrigger as i, Tooltip as a, TooltipContent as o, TooltipProvider as s, TooltipTrigger as c } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { FileDropZone as l } from "../../../shared/ui/dist/lib/FileDropZone/FileDropZone.js";
7
+ import { CopyAddress as u } from "../../../shared/ui/dist/lib/CopyAddress/CopyAddress.js";
8
+ import "../../../shared/ui/dist/index.js";
9
+ import { UploadReceiptModalLabels as d } from "./index2.js";
10
+ import { useId as f, useState as p } from "react";
11
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
+ import { X as g } from "lucide-react";
10
13
  // ../../libs/tesouro-embedded-components-react/upload-receipt-widget/ui/dist/index4.js
11
- function d({ open: d, onClose: f, emailAddress: p, onFilesSelected: m, isUploading: h = !1 }) {
12
- let g = n(null), [_, v] = r(!1);
13
- return d ? /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("div", {
14
- className: "ttw:fixed ttw:inset-0 ttw:z-40",
15
- onClick: f,
16
- "aria-hidden": "true"
17
- }), /* @__PURE__ */ a("div", {
18
- role: "dialog",
19
- "aria-modal": "false",
20
- "aria-label": t.Title,
21
- className: "ttw:absolute ttw:right-0 ttw:top-full ttw:z-50 ttw:mt-2 ttw:w-[27.5rem] ttw:max-w-[calc(100vw-2rem)] ttw:rounded-2xl ttw:border ttw:border-border ttw:bg-popover ttw:p-6 ttw:shadow-xl",
22
- children: /* @__PURE__ */ o("div", {
23
- className: "ttw:relative",
14
+ function _({ open: _, onClose: v, trigger: y, emailAddress: b, onFilesSelected: x, isUploading: S = !1 }) {
15
+ let C = f(), [w, T] = p(), E = () => {
16
+ T(void 0), v();
17
+ };
18
+ return /* @__PURE__ */ h(n, {
19
+ open: _,
20
+ onOpenChange: (e) => {
21
+ e || E();
22
+ },
23
+ children: [y && /* @__PURE__ */ m(i, {
24
+ asChild: !0,
25
+ children: y
26
+ }), /* @__PURE__ */ h(r, {
27
+ align: "end",
28
+ "aria-labelledby": C,
29
+ className: "ttw:w-[27.5rem] ttw:max-w-[calc(100vw-2rem)] ttw:p-6",
24
30
  children: [
25
- /* @__PURE__ */ a("button", {
26
- onClick: f,
27
- "aria-label": t.Close,
28
- className: "ttw:absolute ttw:top-0 ttw:right-0 ttw:text-muted-foreground ttw:hover:text-foreground ttw:transition-colors",
29
- children: /* @__PURE__ */ a(u, { size: 20 })
31
+ /* @__PURE__ */ h("div", {
32
+ className: "ttw:flex ttw:items-start ttw:justify-between ttw:gap-4",
33
+ children: [/* @__PURE__ */ m(t, {
34
+ variant: "dialog",
35
+ level: 2,
36
+ id: C,
37
+ children: d.Title
38
+ }), /* @__PURE__ */ m(s, { children: /* @__PURE__ */ h(a, { children: [/* @__PURE__ */ m(c, {
39
+ asChild: !0,
40
+ children: /* @__PURE__ */ m(e, {
41
+ type: "button",
42
+ variant: "ghost",
43
+ size: "icon-sm",
44
+ "aria-label": d.Close,
45
+ onClick: E,
46
+ children: /* @__PURE__ */ m(g, { className: "ttw:size-4" })
47
+ })
48
+ }), /* @__PURE__ */ m(o, { children: d.Close })] }) })]
49
+ }),
50
+ /* @__PURE__ */ m("p", {
51
+ className: "ttw:mt-1 ttw:mb-4 ttw:text-sm ttw:text-muted-foreground",
52
+ children: d.Subtitle
30
53
  }),
31
- /* @__PURE__ */ a("h2", {
32
- className: "ttw:text-xl ttw:font-semibold ttw:mb-1",
33
- children: t.Title
54
+ /* @__PURE__ */ m(l, {
55
+ label: `${d.DropZonePrefix} ${d.ClickToBrowse}`,
56
+ rules: d.FileTypes,
57
+ inputLabel: d.FileInput,
58
+ accept: ".pdf,.png,.jpg,.jpeg",
59
+ multiple: !0,
60
+ disabled: S,
61
+ onFilesSelected: (e) => {
62
+ e.length > 10 ? T(d.TooManyFiles) : (T(void 0), x?.(e));
63
+ },
64
+ error: w
34
65
  }),
35
- h ? /* @__PURE__ */ o("div", {
36
- className: "ttw:flex ttw:flex-col ttw:items-center ttw:py-8 ttw:gap-3 ttw:text-center",
37
- children: [/* @__PURE__ */ o("div", {
38
- className: "ttw:flex ttw:items-center ttw:gap-2",
39
- children: [/* @__PURE__ */ a(l, {
40
- size: 18,
41
- className: "ttw:animate-spin ttw:text-primary"
42
- }), /* @__PURE__ */ a("p", {
66
+ b && /* @__PURE__ */ h("div", {
67
+ className: "ttw:mt-4 ttw:flex ttw:flex-col ttw:gap-2",
68
+ children: [
69
+ /* @__PURE__ */ m("p", {
43
70
  className: "ttw:text-sm ttw:font-medium ttw:text-primary",
44
- children: t.ProcessingTitle
45
- })]
46
- }), /* @__PURE__ */ a("p", {
47
- className: "ttw:text-sm ttw:text-muted-foreground",
48
- children: t.ProcessingSubtitle
49
- })]
50
- }) : /* @__PURE__ */ o(i, { children: [
51
- /* @__PURE__ */ a("p", {
52
- className: "ttw:text-sm ttw:text-muted-foreground ttw:mb-5",
53
- children: t.Subtitle
54
- }),
55
- /* @__PURE__ */ o("button", {
56
- type: "button",
57
- className: `ttw:mb-5 ttw:flex ttw:w-full ttw:cursor-pointer ttw:flex-col ttw:items-center ttw:rounded-xl ttw:border ttw:border-dashed ttw:p-8 ttw:text-center ${_ ? "ttw:border-primary ttw:bg-white" : "ttw:border-border ttw:bg-muted"}`,
58
- onClick: () => g.current?.click(),
59
- onDragOver: (e) => {
60
- e.preventDefault(), v(!0);
61
- },
62
- onDragLeave: (e) => {
63
- e.preventDefault(), v(!1);
64
- },
65
- onDrop: async (e) => {
66
- e.preventDefault(), v(!1);
67
- let t = e.dataTransfer.files ? Array.from(e.dataTransfer.files) : [];
68
- t.length > 0 && await m?.(t);
69
- },
70
- disabled: h,
71
- children: [
72
- /* @__PURE__ */ a("div", {
73
- className: "ttw:w-12 ttw:h-12 ttw:rounded-full ttw:bg-primary ttw:flex ttw:items-center ttw:justify-center ttw:mb-3",
74
- children: /* @__PURE__ */ a(s, {
75
- size: 24,
76
- className: "ttw:text-white"
77
- })
78
- }),
79
- /* @__PURE__ */ o("p", {
80
- className: "ttw:text-sm ttw:text-center ttw:text-foreground",
81
- children: [
82
- t.DropZonePrefix,
83
- " ",
84
- /* @__PURE__ */ a("span", {
85
- className: "ttw:text-primary ttw:cursor-pointer ttw:hover:underline",
86
- children: t.ClickToBrowse
87
- })
88
- ]
89
- }),
90
- /* @__PURE__ */ a("p", {
91
- className: "ttw:text-xs ttw:text-muted-foreground ttw:mt-1",
92
- children: t.FileTypes
93
- })
94
- ]
95
- }),
96
- p ? /* @__PURE__ */ o(i, { children: [
97
- /* @__PURE__ */ a("p", {
98
- className: "ttw:text-sm ttw:font-medium ttw:text-primary ttw:mb-1",
99
- children: t.OrSendViaEmail
71
+ children: d.OrSendViaEmail
100
72
  }),
101
- /* @__PURE__ */ a("p", {
102
- className: "ttw:text-xs ttw:text-muted-foreground ttw:mb-3",
103
- children: t.EmailDescription
73
+ /* @__PURE__ */ m("p", {
74
+ className: "ttw:text-sm ttw:text-muted-foreground",
75
+ children: d.EmailDescription
104
76
  }),
105
- /* @__PURE__ */ o("div", {
106
- className: "ttw:flex ttw:items-center ttw:justify-between ttw:border ttw:border-border ttw:rounded-lg ttw:px-3 ttw:py-2.5",
107
- children: [/* @__PURE__ */ a("span", {
108
- className: "ttw:text-sm ttw:text-foreground",
109
- children: p
110
- }), /* @__PURE__ */ o(e, {
111
- type: "button",
112
- variant: "ghost",
113
- size: "sm",
114
- className: "ttw:flex ttw:items-center ttw:gap-1.5 ttw:text-primary ttw:text-sm ttw:font-medium ttw:transition-colors",
115
- onClick: () => navigator.clipboard.writeText(p).catch(() => void 0),
116
- children: [/* @__PURE__ */ a(c, { size: 14 }), t.CopyButton]
117
- })]
77
+ /* @__PURE__ */ m(u, {
78
+ address: b,
79
+ copyLabel: d.CopyAddress,
80
+ copiedLabel: d.CopiedAddress,
81
+ failedLabel: d.CopyFailed
118
82
  })
119
- ] }) : null,
120
- /* @__PURE__ */ a("input", {
121
- ref: g,
122
- type: "file",
123
- accept: ".pdf,.png,.jpg,.jpeg",
124
- multiple: !0,
125
- disabled: h,
126
- "aria-label": t.FileInput,
127
- className: "ttw:hidden",
128
- onChange: async (e) => {
129
- let t = e.target.files ? Array.from(e.target.files) : [];
130
- try {
131
- t.length > 0 && await m?.(t);
132
- } finally {
133
- e.target.value = "";
134
- }
135
- }
136
- })
137
- ] })
83
+ ]
84
+ })
138
85
  ]
139
- })
140
- })] }) : null;
86
+ })]
87
+ });
141
88
  }
142
- export { d as UploadReceiptModal };
89
+ export { _ as UploadReceiptModal };