@tesouro/embedded-components-react 0.6.5 → 0.7.1

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.
package/README.md CHANGED
@@ -536,7 +536,6 @@ A single navigable settings surface combining profile, team, invoice, bill-pay,
536
536
  | `helpContactUrl` | `string` | `undefined` | Link (URL or `mailto:`) for the Help section's "Contact Us" line; hidden when unset. |
537
537
  | `helpFaq` | `HelpFaqSection[]` | `HELP_FAQ_EN` | FAQ shown in the Help section. Extend the exported `HELP_FAQ_EN` to add your own questions. |
538
538
  | `helpContent` | `ReactNode` | Help widget | Replaces the help section content. |
539
- | `finopsThemeColors` | `FinopsThemeColors` | `undefined` | Legacy theme overrides; currently has no effect. |
540
539
 
541
540
  ### TransfersWidget
542
541
 
package/dist/index.css CHANGED
@@ -4910,6 +4910,9 @@
4910
4910
  .ttw\:hover\:bg-purple-50:hover {
4911
4911
  background-color: var(--ttw-color-purple-50);
4912
4912
  }
4913
+ .ttw\:hover\:bg-purple-100:hover {
4914
+ background-color: var(--ttw-color-purple-100);
4915
+ }
4913
4916
  .ttw\:hover\:bg-red-50:hover {
4914
4917
  background-color: var(--ttw-color-red-50);
4915
4918
  }
package/dist/index.d.ts CHANGED
@@ -3256,6 +3256,7 @@ interface TransactionDetailsLabels {
3256
3256
  acceptedFileTypes: string;
3257
3257
  uploadingReceipt: string;
3258
3258
  uploadingReceiptBody: string;
3259
+ readingReceipt: string;
3259
3260
  loadFailed: string;
3260
3261
  }
3261
3262
 
@@ -3562,16 +3563,6 @@ interface HelpFaqSection {
3562
3563
  */
3563
3564
  declare const HELP_FAQ_EN: HelpFaqSection[];
3564
3565
 
3565
- interface FinopsThemeColors {
3566
- primary?: string;
3567
- primaryForeground?: string;
3568
- }
3569
- interface MoniteWrapperProps {
3570
- finopsThemeColors?: FinopsThemeColors;
3571
- }
3572
-
3573
- type MoniteRegionProviderProps = WidgetProviderProps & MoniteWrapperProps;
3574
-
3575
3566
  interface FeatureLabels$1 {
3576
3567
  profileSection: string;
3577
3568
  teamSection: string;
@@ -3626,7 +3617,7 @@ interface SettingsWidgetAdditionalSection extends SettingsWidgetSection {
3626
3617
  after?: SettingsSection;
3627
3618
  }
3628
3619
 
3629
- interface SettingsWidgetProps extends MoniteRegionProviderProps {
3620
+ interface SettingsWidgetProps extends WidgetProviderProps {
3630
3621
  labels?: Partial<Labels>;
3631
3622
  featureLabels?: Partial<FeatureLabels$1>;
3632
3623
  /** Forwarded to the embedded Team section's {@link TeamWidget} — the
@@ -3678,7 +3669,7 @@ interface SettingsWidgetProps extends MoniteRegionProviderProps {
3678
3669
  invoiceContent?: ReactNode;
3679
3670
  legalContent?: ReactNode;
3680
3671
  }
3681
- declare function SettingsWidget({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, implementation, uiFramework, errorFallback, onError, finopsThemeColors, analytics, disclosuresAcceptance, providerLabels, ...innerProps }: SettingsWidgetProps): React.JSX.Element;
3672
+ declare function SettingsWidget({ labels, featureLabels, acceptInviteRedirectUri, helpContactUrl, helpFaq, profileContactUrl, selectedSection, defaultSelectedSection, onSelectedSectionChange, additionalSections, profileContent, teamContent, billPayContent, helpContent, expenseContent, accountingContent, invoiceContent, legalContent, ...widgetProviderProps }: SettingsWidgetProps): React.JSX.Element;
3682
3673
 
3683
3674
  interface TransfersWidgetLabels {
3684
3675
  widgetTitle: string;
@@ -4449,6 +4440,16 @@ declare module '@mui/material/transitions' {
4449
4440
  }
4450
4441
  }
4451
4442
 
4443
+ interface FinopsThemeColors {
4444
+ primary?: string;
4445
+ primaryForeground?: string;
4446
+ }
4447
+ interface MoniteWrapperProps {
4448
+ finopsThemeColors?: FinopsThemeColors;
4449
+ }
4450
+
4451
+ type MoniteRegionProviderProps = WidgetProviderProps & MoniteWrapperProps;
4452
+
4452
4453
  type BillPayWidgetMoniteProps = MoniteRegionProviderProps & Omit<PayablesProps, 'pageTitleComponent'> & {
4453
4454
  pageTitleComponent?: PayablesProps['pageTitleComponent'];
4454
4455
  };
@@ -141,6 +141,7 @@ interface TransactionDetailsLabels {
141
141
  acceptedFileTypes: string;
142
142
  uploadingReceipt: string;
143
143
  uploadingReceiptBody: string;
144
+ readingReceipt: string;
144
145
  loadFailed: string;
145
146
  }
146
147
 
@@ -678,16 +678,6 @@ interface WidgetProviderProps extends WidgetProviderBaseProps {
678
678
  providerLabels?: Partial<WidgetProviderLabels>;
679
679
  }
680
680
 
681
- interface FinopsThemeColors {
682
- primary?: string;
683
- primaryForeground?: string;
684
- }
685
- interface MoniteWrapperProps {
686
- finopsThemeColors?: FinopsThemeColors;
687
- }
688
-
689
- type MoniteRegionProviderProps = WidgetProviderProps & MoniteWrapperProps;
690
-
691
681
  interface FeatureLabels {
692
682
  profileSection: string;
693
683
  teamSection: string;
@@ -742,7 +732,7 @@ interface SettingsWidgetAdditionalSection extends SettingsWidgetSection {
742
732
  after?: SettingsSection;
743
733
  }
744
734
 
745
- interface SettingsWidgetProps extends MoniteRegionProviderProps {
735
+ interface SettingsWidgetProps extends WidgetProviderProps {
746
736
  labels?: Partial<Labels>;
747
737
  featureLabels?: Partial<FeatureLabels>;
748
738
  /** Forwarded to the embedded Team section's {@link TeamWidget} — the
@@ -794,7 +784,7 @@ interface SettingsWidgetProps extends MoniteRegionProviderProps {
794
784
  invoiceContent?: ReactNode;
795
785
  legalContent?: ReactNode;
796
786
  }
797
- declare function SettingsWidget({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, implementation, uiFramework, errorFallback, onError, finopsThemeColors, analytics, disclosuresAcceptance, providerLabels, ...innerProps }: SettingsWidgetProps): React.JSX.Element;
787
+ declare function SettingsWidget({ labels, featureLabels, acceptInviteRedirectUri, helpContactUrl, helpFaq, profileContactUrl, selectedSection, defaultSelectedSection, onSelectedSectionChange, additionalSections, profileContent, teamContent, billPayContent, helpContent, expenseContent, accountingContent, invoiceContent, legalContent, ...widgetProviderProps }: SettingsWidgetProps): React.JSX.Element;
798
788
 
799
789
  export { HELP_FAQ_EN, SettingsSection, SettingsWidget };
800
790
  export type { HelpFaqAnswer, HelpFaqBullet, HelpFaqBulletType, HelpFaqItem, HelpFaqSection, SettingsWidgetAdditionalSection, FeatureLabels as SettingsWidgetFeatureLabels, Labels as SettingsWidgetLabels, SettingsWidgetProps, SettingsWidgetSection, SettingsWidgetSectionId };
@@ -2325,6 +2325,7 @@ interface TransactionDetailsLabels {
2325
2325
  acceptedFileTypes: string;
2326
2326
  uploadingReceipt: string;
2327
2327
  uploadingReceiptBody: string;
2328
+ readingReceipt: string;
2328
2329
  loadFailed: string;
2329
2330
  }
2330
2331
 
@@ -2601,16 +2602,6 @@ interface HelpFaqSection {
2601
2602
  items: HelpFaqItem[];
2602
2603
  }
2603
2604
 
2604
- interface FinopsThemeColors {
2605
- primary?: string;
2606
- primaryForeground?: string;
2607
- }
2608
- interface MoniteWrapperProps {
2609
- finopsThemeColors?: FinopsThemeColors;
2610
- }
2611
-
2612
- type MoniteRegionProviderProps = WidgetProviderProps & MoniteWrapperProps;
2613
-
2614
2605
  interface FeatureLabels$1 {
2615
2606
  profileSection: string;
2616
2607
  teamSection: string;
@@ -2665,7 +2656,7 @@ interface SettingsWidgetAdditionalSection extends SettingsWidgetSection {
2665
2656
  after?: SettingsSection;
2666
2657
  }
2667
2658
 
2668
- interface SettingsWidgetProps extends MoniteRegionProviderProps {
2659
+ interface SettingsWidgetProps extends WidgetProviderProps {
2669
2660
  labels?: Partial<Labels>;
2670
2661
  featureLabels?: Partial<FeatureLabels$1>;
2671
2662
  /** Forwarded to the embedded Team section's {@link TeamWidget} — the
@@ -7,14 +7,14 @@ import { invalidateAllClients as t } from "../../../../shared/data-access/dist/l
7
7
  import { useEmbedApi as n } from "../../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
8
  import { organizationHeaders as r } from "../../../../shared/data-access/dist/lib/organizationHeaders.js";
9
9
  import "../../../../shared/data-access/dist/index.js";
10
- import { analyticsReceiptsInvalidationKey as i, analyticsTransactionsInvalidationKey as a, receiptsIdInvalidationKey as o, receiptsInvalidationKey as s, transactionsIdInvalidationKey as c, transactionsInvalidationKey as l } from "./queryKeys.js";
11
- import { useCallback as u, useEffect as d, useRef as f } from "react";
10
+ import { analyticsReceiptsInvalidationKey as i, analyticsTransactionsInvalidationKey as a, receiptsIdInvalidationKey as o, receiptsInvalidationKey as s, transactionsIdExpenseHistoryInvalidationKey as c, transactionsIdInvalidationKey as l, transactionsInvalidationKey as u } from "./queryKeys.js";
11
+ import { useCallback as d, useEffect as f, useRef as p } from "react";
12
12
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/lib/useTrackReceiptMatching.js
13
- var p = 3e3, m = 30, h = 10;
14
- function g(e) {
13
+ var m = 3e3, h = 30, g = 10;
14
+ function _(e) {
15
15
  return e.transaction_id ? "matched" : e.ocr_status === "processing" ? null : e.ocr_status === "error" ? "unreadable" : "unmatched";
16
16
  }
17
- function _(e, t) {
17
+ function v(e, t) {
18
18
  return new Promise((n, r) => {
19
19
  if (t.aborted) {
20
20
  r(new DOMException("Aborted", "AbortError"));
@@ -28,83 +28,136 @@ function _(e, t) {
28
28
  t.addEventListener("abort", i, { once: !0 });
29
29
  });
30
30
  }
31
- function v({ intervalMs: v = p, maxAttempts: y = m } = {}) {
32
- let { client: b, organizationId: x } = n(), S = f(null);
33
- d(() => {
31
+ function y({ intervalMs: y = m, maxAttempts: b = h } = {}) {
32
+ let { client: x, organizationId: S } = n(), C = p(null);
33
+ f(() => {
34
34
  let e = new AbortController();
35
- return S.current = e, () => e.abort();
35
+ return C.current = e, () => e.abort();
36
36
  }, []);
37
- let C = u(() => Promise.all([
37
+ let w = d(() => Promise.all([
38
38
  t(s({
39
- client: b,
40
- organizationId: x
39
+ client: x,
40
+ organizationId: S
41
41
  })),
42
- t(l({
43
- client: b,
44
- organizationId: x
42
+ t(u({
43
+ client: x,
44
+ organizationId: S
45
45
  })),
46
46
  t(i({
47
- client: b,
48
- organizationId: x
47
+ client: x,
48
+ organizationId: S
49
49
  })),
50
50
  t(a({
51
- client: b,
52
- organizationId: x
51
+ client: x,
52
+ organizationId: S
53
53
  }))
54
- ]), [b, x]);
55
- return { trackBatch: u(async (n) => {
56
- let i = {
57
- total: n.length,
58
- matched: 0,
59
- unmatched: 0,
60
- unreadable: 0,
61
- stillProcessing: 0
62
- };
63
- if (n.length === 0) return i;
64
- let a = new Set(n), s = S.current?.signal ?? new AbortController().signal;
65
- await C();
66
- for (let n = 0; n < y && a.size > 0; n++) {
67
- if (s.aborted) throw new DOMException("Aborted", "AbortError");
68
- let { data: l } = await e({
69
- client: b,
70
- headers: r(x),
71
- query: {
72
- id__in: [...a],
73
- limit: h
74
- },
75
- signal: s,
76
- throwOnError: !0
77
- }), u = [], d = [];
78
- for (let e of l?.data ?? []) {
79
- if (!a.has(e.id)) continue;
80
- let t = g(e);
81
- t && (a.delete(e.id), i[t] += 1, u.push(e.id), t === "matched" && e.transaction_id && d.push(e.transaction_id));
54
+ ]), [x, S]);
55
+ return {
56
+ trackBatch: d(async (n) => {
57
+ let i = {
58
+ total: n.length,
59
+ matched: 0,
60
+ unmatched: 0,
61
+ unreadable: 0,
62
+ stillProcessing: 0
63
+ };
64
+ if (n.length === 0) return i;
65
+ let a = new Set(n), s = C.current?.signal ?? new AbortController().signal;
66
+ await w();
67
+ for (let n = 0; n < b && a.size > 0; n++) {
68
+ if (s.aborted) throw new DOMException("Aborted", "AbortError");
69
+ let { data: c } = await e({
70
+ client: x,
71
+ headers: r(S),
72
+ query: {
73
+ id__in: [...a],
74
+ limit: g
75
+ },
76
+ signal: s,
77
+ throwOnError: !0
78
+ }), u = [], d = [];
79
+ for (let e of c?.data ?? []) {
80
+ if (!a.has(e.id)) continue;
81
+ let t = _(e);
82
+ t && (a.delete(e.id), i[t] += 1, u.push(e.id), t === "matched" && e.transaction_id && d.push(e.transaction_id));
83
+ }
84
+ u.length > 0 && await Promise.all([
85
+ w(),
86
+ ...u.map((e) => t(o({
87
+ client: x,
88
+ organizationId: S,
89
+ receiptId: e
90
+ }))),
91
+ ...d.map((e) => t(l({
92
+ client: x,
93
+ organizationId: S,
94
+ transactionId: e
95
+ })))
96
+ ]), a.size > 0 && n < b - 1 && await v(y, s);
82
97
  }
83
- u.length > 0 && await Promise.all([
84
- C(),
85
- ...u.map((e) => t(o({
86
- client: b,
87
- organizationId: x,
88
- receiptId: e
89
- }))),
90
- ...d.map((e) => t(c({
91
- client: b,
92
- organizationId: x,
93
- transactionId: e
94
- })))
95
- ]), a.size > 0 && n < y - 1 && await _(v, s);
96
- }
97
- return {
98
- ...i,
99
- stillProcessing: a.size
100
- };
101
- }, [
102
- b,
103
- v,
104
- y,
105
- x,
106
- C
107
- ]) };
98
+ return {
99
+ ...i,
100
+ stillProcessing: a.size
101
+ };
102
+ }, [
103
+ x,
104
+ y,
105
+ b,
106
+ S,
107
+ w
108
+ ]),
109
+ trackAttachedReceipt: d(async ({ receiptId: n, transactionId: i }) => {
110
+ let a = C.current?.signal ?? new AbortController().signal;
111
+ for (let s = 0; s < b; s++) {
112
+ if (a.aborted) throw new DOMException("Aborted", "AbortError");
113
+ let u, d = !1;
114
+ try {
115
+ let { data: t } = await e({
116
+ client: x,
117
+ headers: r(S),
118
+ query: {
119
+ id__in: [n],
120
+ limit: 1
121
+ },
122
+ signal: a,
123
+ throwOnError: !0
124
+ });
125
+ u = t?.data?.find((e) => e.id === n);
126
+ } catch (e) {
127
+ if (a.aborted) throw e;
128
+ d = !0;
129
+ }
130
+ if (!d && u?.ocr_status !== "processing") {
131
+ await Promise.all([
132
+ w(),
133
+ t(o({
134
+ client: x,
135
+ organizationId: S,
136
+ receiptId: n
137
+ })),
138
+ t(l({
139
+ client: x,
140
+ organizationId: S,
141
+ transactionId: i
142
+ })),
143
+ t(c({
144
+ client: x,
145
+ organizationId: S,
146
+ transactionId: i
147
+ }))
148
+ ]);
149
+ return;
150
+ }
151
+ s < b - 1 && await v(y, a);
152
+ }
153
+ }, [
154
+ x,
155
+ y,
156
+ b,
157
+ S,
158
+ w
159
+ ])
160
+ };
108
161
  }
109
162
  //#endregion
110
- export { g as classifyReceipt, v as useTrackReceiptMatching };
163
+ export { _ as classifyReceipt, y as useTrackReceiptMatching };