@tesouro/embedded-components-react 0.7.24 → 0.7.26
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/dist/index.css +0 -3
- package/dist/index.d.ts +11 -19
- package/dist/lib/CounterpartsWidget.d.ts +1 -1
- package/dist/lib/CounterpartsWidgetPublic.d.ts +1 -1
- package/dist/lib/CustomersWidget.d.ts +10 -18
- package/dist/lib/ExpenseManagementWidget.d.ts +1 -1
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/lib/CustomersWidget/CustomersWidget.js +33 -18
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/lib/CustomersWidgetMonite/CustomersWidgetMonite.js +0 -45
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/lib/CustomersWidgetNative/CustomersWidgetNative.js +0 -42
- package/dist/libs/tesouro-embedded-components-react/shared/monite-wrapper/feature/dist/index.js +0 -4
- package/dist/libs/tesouro-embedded-components-react/shared/monite-wrapper/feature/dist/lib/MoniteRegionProvider.js +0 -21
- package/dist/libs/tesouro-embedded-components-react/shared/monite-wrapper/feature/dist/lib/MoniteWrapper.js +0 -134
- package/dist/libs/tesouro-embedded-components-react/shared/monite-wrapper/feature/dist/lib/RefreshingMoniteWidgetProvider.js +0 -7
package/dist/index.css
CHANGED
|
@@ -6629,9 +6629,6 @@
|
|
|
6629
6629
|
.ttw\:\[\&\[data-state\=open\]\>svg\]\:rotate-180[data-state=open] > svg {
|
|
6630
6630
|
rotate: 180deg;
|
|
6631
6631
|
}
|
|
6632
|
-
.dark .ttw\:\[\.dark_\&\]\:bg-background {
|
|
6633
|
-
background-color: var(--ttw-background);
|
|
6634
|
-
}
|
|
6635
6632
|
@media (resolution>192dpi) {
|
|
6636
6633
|
.ttw\:\[\@media\(resolution\>192dpi\)\]\:min-h-\[1828px\] {
|
|
6637
6634
|
min-height: 1828px;
|
package/dist/index.d.ts
CHANGED
|
@@ -3332,7 +3332,7 @@ type ExpenseManagementWidgetProps = WidgetProviderProps & ExpenseManagementWidge
|
|
|
3332
3332
|
* the unmatched-receipts Action Item), and an Upload Receipts entry
|
|
3333
3333
|
* point — composed from `ExpensesScreen` rather than a monolithic UI
|
|
3334
3334
|
* component, following the `WidgetProvider` "Feature Component Pattern" the
|
|
3335
|
-
* same way `
|
|
3335
|
+
* same way `CustomersWidget` does. Uses no Monite provider.
|
|
3336
3336
|
*
|
|
3337
3337
|
* Team tab visibility matches legacy: `ExpenseReadOrg`, or a direct-reports
|
|
3338
3338
|
* probe for people-managers without org-wide read. The Team list, its count
|
|
@@ -4757,7 +4757,7 @@ declare const BillPayWidget: (props: BillPayWidgetProps) => ReactElement;
|
|
|
4757
4757
|
*
|
|
4758
4758
|
* The workspace-internal component additionally accepts a `passThrough` prop
|
|
4759
4759
|
* that tells it to give up its own analytics identity when a composing widget
|
|
4760
|
-
* (`
|
|
4760
|
+
* (`CustomersWidget`, `BillPayWidget`'s Vendors tab) mounts it to
|
|
4761
4761
|
* inherit the host's identity instead (EMBD-5384). That choice is set **only**
|
|
4762
4762
|
* by those composing widgets, never by integrators: an integrator's own
|
|
4763
4763
|
* standalone mount must always claim its own identity.
|
|
@@ -4772,9 +4772,8 @@ declare const BillPayWidget: (props: BillPayWidgetProps) => ReactElement;
|
|
|
4772
4772
|
declare function CounterpartsWidget(props: CounterpartsWidgetProps): ReactNode;
|
|
4773
4773
|
|
|
4774
4774
|
/**
|
|
4775
|
-
*
|
|
4776
|
-
*
|
|
4777
|
-
* thin `counterpartType="customer"` wrapper around `CounterpartsWidget`) minus
|
|
4775
|
+
* Named after {@link CounterpartsWidgetOwnProps} (this widget is a thin
|
|
4776
|
+
* `counterpartType="customer"` wrapper around `CounterpartsWidget`) minus
|
|
4778
4777
|
* `counterpartType` itself, which this widget hardcodes.
|
|
4779
4778
|
*/
|
|
4780
4779
|
interface CustomersWidgetOwnProps {
|
|
@@ -4797,24 +4796,17 @@ interface CustomersWidgetOwnProps {
|
|
|
4797
4796
|
/** Overrides for validation / error / delete-prompt messages. */
|
|
4798
4797
|
messageLabels?: Partial<CounterpartMessageLabels>;
|
|
4799
4798
|
}
|
|
4799
|
+
|
|
4800
4800
|
/** Public props for {@link CustomersWidget}. */
|
|
4801
4801
|
type CustomersWidgetProps = WidgetProviderProps & CustomersWidgetOwnProps;
|
|
4802
|
-
|
|
4803
4802
|
/**
|
|
4804
|
-
*
|
|
4805
|
-
*
|
|
4806
|
-
*
|
|
4807
|
-
*
|
|
4808
|
-
*
|
|
4809
|
-
* honored, whether from this widget's `implementation` prop or from the
|
|
4810
|
-
* provider/global cascade (`RootWidgetProvider implementation="monite"`,
|
|
4811
|
-
* `setGlobalWidgetConfig`) — for a host that has not yet moved off Monite.
|
|
4812
|
-
*
|
|
4813
|
-
* `onViewAllDocuments` / `onCreateDocument` receive a `CounterpartActionTarget`
|
|
4814
|
-
* (`{ id, name }`) under native. Under `monite`, `name` is always empty — the
|
|
4815
|
-
* Monite SDK's own callbacks only carry the id.
|
|
4803
|
+
* A customer is a counterpart, so the published `CounterpartsWidget` already
|
|
4804
|
+
* is this surface end to end (list, details, create/edit, delete) via
|
|
4805
|
+
* `counterpartType`. Reused rather than rebuilt, the same way `BillPayWidget`
|
|
4806
|
+
* reuses it for its Vendors tab. There is no Monite build any more, so
|
|
4807
|
+
* `implementation` only cascades to descendants and changes nothing here.
|
|
4816
4808
|
*/
|
|
4817
|
-
declare function CustomersWidget({
|
|
4809
|
+
declare function CustomersWidget({ pageSizeOptions, onViewAllDocuments, onCreateDocument, screenLabels, formLabels, detailsLabels, addressLabels, deleteLabels, messageLabels, ...widgetProviderProps }: CustomersWidgetProps): React.JSX.Element;
|
|
4818
4810
|
|
|
4819
4811
|
interface MarketingWidgetLabels {
|
|
4820
4812
|
applyNow: string;
|
|
@@ -1012,7 +1012,7 @@ type CounterpartsWidgetProps = WidgetProviderProps & CounterpartsWidgetOwnProps;
|
|
|
1012
1012
|
*
|
|
1013
1013
|
* The workspace-internal component additionally accepts a `passThrough` prop
|
|
1014
1014
|
* that tells it to give up its own analytics identity when a composing widget
|
|
1015
|
-
* (`
|
|
1015
|
+
* (`CustomersWidget`, `BillPayWidget`'s Vendors tab) mounts it to
|
|
1016
1016
|
* inherit the host's identity instead (EMBD-5384). That choice is set **only**
|
|
1017
1017
|
* by those composing widgets, never by integrators: an integrator's own
|
|
1018
1018
|
* standalone mount must always claim its own identity.
|
|
@@ -1012,7 +1012,7 @@ type CounterpartsWidgetProps = WidgetProviderProps & CounterpartsWidgetOwnProps;
|
|
|
1012
1012
|
*
|
|
1013
1013
|
* The workspace-internal component additionally accepts a `passThrough` prop
|
|
1014
1014
|
* that tells it to give up its own analytics identity when a composing widget
|
|
1015
|
-
* (`
|
|
1015
|
+
* (`CustomersWidget`, `BillPayWidget`'s Vendors tab) mounts it to
|
|
1016
1016
|
* inherit the host's identity instead (EMBD-5384). That choice is set **only**
|
|
1017
1017
|
* by those composing widgets, never by integrators: an integrator's own
|
|
1018
1018
|
* standalone mount must always claim its own identity.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ComponentType, AnchorHTMLAttributes, ReactNode, ErrorInfo } from 'react';
|
|
3
|
-
import { PartialDeep } from 'type-fest';
|
|
4
3
|
import { FallbackProps } from 'react-error-boundary';
|
|
4
|
+
import { PartialDeep } from 'type-fest';
|
|
5
5
|
|
|
6
6
|
type AuthToken = string | undefined;
|
|
7
7
|
interface Auth {
|
|
@@ -959,9 +959,8 @@ interface CounterpartActionTarget {
|
|
|
959
959
|
}
|
|
960
960
|
|
|
961
961
|
/**
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
* thin `counterpartType="customer"` wrapper around `CounterpartsWidget`) minus
|
|
962
|
+
* Named after {@link CounterpartsWidgetOwnProps} (this widget is a thin
|
|
963
|
+
* `counterpartType="customer"` wrapper around `CounterpartsWidget`) minus
|
|
965
964
|
* `counterpartType` itself, which this widget hardcodes.
|
|
966
965
|
*/
|
|
967
966
|
interface CustomersWidgetOwnProps {
|
|
@@ -984,24 +983,17 @@ interface CustomersWidgetOwnProps {
|
|
|
984
983
|
/** Overrides for validation / error / delete-prompt messages. */
|
|
985
984
|
messageLabels?: Partial<CounterpartMessageLabels>;
|
|
986
985
|
}
|
|
986
|
+
|
|
987
987
|
/** Public props for {@link CustomersWidget}. */
|
|
988
988
|
type CustomersWidgetProps = WidgetProviderProps & CustomersWidgetOwnProps;
|
|
989
|
-
|
|
990
989
|
/**
|
|
991
|
-
*
|
|
992
|
-
*
|
|
993
|
-
*
|
|
994
|
-
*
|
|
995
|
-
*
|
|
996
|
-
* honored, whether from this widget's `implementation` prop or from the
|
|
997
|
-
* provider/global cascade (`RootWidgetProvider implementation="monite"`,
|
|
998
|
-
* `setGlobalWidgetConfig`) — for a host that has not yet moved off Monite.
|
|
999
|
-
*
|
|
1000
|
-
* `onViewAllDocuments` / `onCreateDocument` receive a `CounterpartActionTarget`
|
|
1001
|
-
* (`{ id, name }`) under native. Under `monite`, `name` is always empty — the
|
|
1002
|
-
* Monite SDK's own callbacks only carry the id.
|
|
990
|
+
* A customer is a counterpart, so the published `CounterpartsWidget` already
|
|
991
|
+
* is this surface end to end (list, details, create/edit, delete) via
|
|
992
|
+
* `counterpartType`. Reused rather than rebuilt, the same way `BillPayWidget`
|
|
993
|
+
* reuses it for its Vendors tab. There is no Monite build any more, so
|
|
994
|
+
* `implementation` only cascades to descendants and changes nothing here.
|
|
1003
995
|
*/
|
|
1004
|
-
declare function CustomersWidget({
|
|
996
|
+
declare function CustomersWidget({ pageSizeOptions, onViewAllDocuments, onCreateDocument, screenLabels, formLabels, detailsLabels, addressLabels, deleteLabels, messageLabels, ...widgetProviderProps }: CustomersWidgetProps): React.JSX.Element;
|
|
1005
997
|
|
|
1006
998
|
export { CustomersWidget };
|
|
1007
999
|
export type { CounterpartActionTarget, CustomersWidgetOwnProps, CustomersWidgetProps };
|
|
@@ -840,7 +840,7 @@ type ExpenseManagementWidgetProps = WidgetProviderProps & ExpenseManagementWidge
|
|
|
840
840
|
* the unmatched-receipts Action Item), and an Upload Receipts entry
|
|
841
841
|
* point — composed from `ExpensesScreen` rather than a monolithic UI
|
|
842
842
|
* component, following the `WidgetProvider` "Feature Component Pattern" the
|
|
843
|
-
* same way `
|
|
843
|
+
* same way `CustomersWidget` does. Uses no Monite provider.
|
|
844
844
|
*
|
|
845
845
|
* Team tab visibility matches legacy: `ExpenseReadOrg`, or a direct-reports
|
|
846
846
|
* probe for people-managers without org-wide read. The Team list, its count
|
|
@@ -2,26 +2,41 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { useAnalyticsTrack as e } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
6
|
+
import { WidgetProvider as t } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
7
7
|
import "../../../../../shared/feature/dist/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
8
|
+
import { CounterpartsWidget as n } from "../../../../../counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartsWidget.js";
|
|
9
|
+
import "../../../../../counterparts-widget/feature/dist/index.js";
|
|
10
|
+
import { CustomersWidgetAnalyticsEvent as r, WIDGET_NAME as i } from "../analytics/events.js";
|
|
11
|
+
import { useEffect as a } from "react";
|
|
12
|
+
import { Fragment as o, jsx as s } from "react/jsx-runtime";
|
|
11
13
|
//#region ../../libs/tesouro-embedded-components-react/customers-widget/feature/dist/lib/CustomersWidget/CustomersWidget.js
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
return (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
function c(t) {
|
|
15
|
+
let i = e();
|
|
16
|
+
return a(() => {
|
|
17
|
+
i(r.Mounted);
|
|
18
|
+
}, [i]), /* @__PURE__ */ s(o, { children: /* @__PURE__ */ s(n, {
|
|
19
|
+
counterpartType: "customer",
|
|
20
|
+
passThrough: !0,
|
|
21
|
+
...t
|
|
22
|
+
}) });
|
|
23
|
+
}
|
|
24
|
+
function l({ pageSizeOptions: e, onViewAllDocuments: n, onCreateDocument: r, screenLabels: a, formLabels: o, detailsLabels: l, addressLabels: u, deleteLabels: d, messageLabels: f, ...p }) {
|
|
25
|
+
return /* @__PURE__ */ s(t, {
|
|
26
|
+
...p,
|
|
27
|
+
widgetName: i,
|
|
28
|
+
children: /* @__PURE__ */ s(c, {
|
|
29
|
+
pageSizeOptions: e,
|
|
30
|
+
onViewAllDocuments: n,
|
|
31
|
+
onCreateDocument: r,
|
|
32
|
+
screenLabels: a,
|
|
33
|
+
formLabels: o,
|
|
34
|
+
detailsLabels: l,
|
|
35
|
+
addressLabels: u,
|
|
36
|
+
deleteLabels: d,
|
|
37
|
+
messageLabels: f
|
|
38
|
+
})
|
|
24
39
|
});
|
|
25
40
|
}
|
|
26
41
|
//#endregion
|
|
27
|
-
export {
|
|
42
|
+
export { l as CustomersWidget, l as default };
|
package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
|
|
2
|
-
var e = "@tesouro/embedded-components-react", t = "0.7.
|
|
2
|
+
var e = "@tesouro/embedded-components-react", t = "0.7.26", n = "ae89f9dbbb943b8364fd46e2c184a10a7b8a9ef3", r = Object.freeze({
|
|
3
3
|
library_name: e,
|
|
4
4
|
library_version: t,
|
|
5
5
|
library_sha: n
|
package/package.json
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { useAnalyticsTrack as e } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
6
|
-
import "../../../../../shared/feature/dist/index.js";
|
|
7
|
-
import { CustomersWidgetAnalyticsEvent as t, WIDGET_NAME as n } from "../analytics/events.js";
|
|
8
|
-
import { Counterparts as r } from "../../../../../monite-sdk/dist/index162.js";
|
|
9
|
-
import "../../../../../monite-sdk/dist/index.js";
|
|
10
|
-
import { MoniteRegionProvider as i } from "../../../../../shared/monite-wrapper/feature/dist/lib/MoniteRegionProvider.js";
|
|
11
|
-
import "../../../../../shared/monite-wrapper/feature/dist/index.js";
|
|
12
|
-
import { useEffect as a } from "react";
|
|
13
|
-
import { jsx as o } from "react/jsx-runtime";
|
|
14
|
-
//#region ../../libs/tesouro-embedded-components-react/customers-widget/feature/dist/lib/CustomersWidgetMonite/CustomersWidgetMonite.js
|
|
15
|
-
var s = (e) => e;
|
|
16
|
-
function c({ onViewAllDocuments: n, onCreateDocument: i, pageTitleComponent: c = s }) {
|
|
17
|
-
let l = e();
|
|
18
|
-
return a(() => {
|
|
19
|
-
l(t.Mounted);
|
|
20
|
-
}, [l]), /* @__PURE__ */ o(r, {
|
|
21
|
-
type: "customer",
|
|
22
|
-
pageTitleComponent: c,
|
|
23
|
-
onCreateInvoiceForCustomer: i && ((e) => i({
|
|
24
|
-
id: e,
|
|
25
|
-
name: ""
|
|
26
|
-
})),
|
|
27
|
-
onViewCustomerInvoices: n && ((e) => n({
|
|
28
|
-
id: e,
|
|
29
|
-
name: ""
|
|
30
|
-
}))
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
function l({ onViewAllDocuments: e, onCreateDocument: t, pageTitleComponent: r, ...a }) {
|
|
34
|
-
return /* @__PURE__ */ o(i, {
|
|
35
|
-
...a,
|
|
36
|
-
widgetName: n,
|
|
37
|
-
children: /* @__PURE__ */ o(c, {
|
|
38
|
-
onViewAllDocuments: e,
|
|
39
|
-
onCreateDocument: t,
|
|
40
|
-
pageTitleComponent: r
|
|
41
|
-
})
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { l as CustomersWidgetMonite, l as default };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { useAnalyticsTrack as e } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
6
|
-
import { WidgetProvider as t } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
7
|
-
import "../../../../../shared/feature/dist/index.js";
|
|
8
|
-
import { CounterpartsWidget as n } from "../../../../../counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartsWidget.js";
|
|
9
|
-
import "../../../../../counterparts-widget/feature/dist/index.js";
|
|
10
|
-
import { CustomersWidgetAnalyticsEvent as r, WIDGET_NAME as i } from "../analytics/events.js";
|
|
11
|
-
import { useEffect as a } from "react";
|
|
12
|
-
import { Fragment as o, jsx as s } from "react/jsx-runtime";
|
|
13
|
-
//#region ../../libs/tesouro-embedded-components-react/customers-widget/feature/dist/lib/CustomersWidgetNative/CustomersWidgetNative.js
|
|
14
|
-
function c(t) {
|
|
15
|
-
let i = e();
|
|
16
|
-
return a(() => {
|
|
17
|
-
i(r.Mounted);
|
|
18
|
-
}, [i]), /* @__PURE__ */ s(o, { children: /* @__PURE__ */ s(n, {
|
|
19
|
-
counterpartType: "customer",
|
|
20
|
-
passThrough: !0,
|
|
21
|
-
...t
|
|
22
|
-
}) });
|
|
23
|
-
}
|
|
24
|
-
function l({ pageSizeOptions: e, onViewAllDocuments: n, onCreateDocument: r, screenLabels: a, formLabels: o, detailsLabels: l, addressLabels: u, deleteLabels: d, messageLabels: f, ...p }) {
|
|
25
|
-
return /* @__PURE__ */ s(t, {
|
|
26
|
-
...p,
|
|
27
|
-
widgetName: i,
|
|
28
|
-
children: /* @__PURE__ */ s(c, {
|
|
29
|
-
pageSizeOptions: e,
|
|
30
|
-
onViewAllDocuments: n,
|
|
31
|
-
onCreateDocument: r,
|
|
32
|
-
screenLabels: a,
|
|
33
|
-
formLabels: o,
|
|
34
|
-
detailsLabels: l,
|
|
35
|
-
addressLabels: u,
|
|
36
|
-
deleteLabels: d,
|
|
37
|
-
messageLabels: f
|
|
38
|
-
})
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
export { l as CustomersWidgetNative, l as default };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { WidgetProvider as e } from "../../../../feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
6
|
-
import "../../../../feature/dist/index.js";
|
|
7
|
-
import { MoniteWrapper as t } from "./MoniteWrapper.js";
|
|
8
|
-
import { jsx as n } from "react/jsx-runtime";
|
|
9
|
-
//#region ../../libs/tesouro-embedded-components-react/shared/monite-wrapper/feature/dist/lib/MoniteRegionProvider.js
|
|
10
|
-
function r({ finopsThemeColors: r, children: i, widgetName: a, ...o }) {
|
|
11
|
-
return /* @__PURE__ */ n(e, {
|
|
12
|
-
...o,
|
|
13
|
-
widgetName: a,
|
|
14
|
-
children: /* @__PURE__ */ n(t, {
|
|
15
|
-
finopsThemeColors: r,
|
|
16
|
-
children: i
|
|
17
|
-
})
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { r as MoniteRegionProvider };
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { useEmbedApi as e } from "../../../../data-access/dist/lib/EmbedApiContext.js";
|
|
6
|
-
import "../../../../data-access/dist/index.js";
|
|
7
|
-
import { useOptionalWidgetToken as t } from "../../../../feature/dist/lib/WidgetProvider/useWidgetToken.js";
|
|
8
|
-
import { useWidgetConfig as n, useWidgetError as r, useWidgetInitStaleForToken as i } from "../../../../feature/dist/lib/WidgetProvider/hooks.js";
|
|
9
|
-
import "../../../../feature/dist/index.js";
|
|
10
|
-
import { RootElementsProvider as a } from "../../../../../monite-sdk/dist/index47.js";
|
|
11
|
-
import { MoniteProvider as o } from "../../../../../monite-sdk/dist/index416.js";
|
|
12
|
-
import "../../../../../monite-sdk/dist/index.js";
|
|
13
|
-
import { useEffect as s, useLayoutEffect as c, useMemo as l, useState as u } from "react";
|
|
14
|
-
import { jsx as d } from "react/jsx-runtime";
|
|
15
|
-
//#region ../../libs/tesouro-embedded-components-react/shared/monite-wrapper/feature/dist/lib/MoniteWrapper.js
|
|
16
|
-
var f = 0, p = "tesouro-embedded-light", m = `${p} ttw:[.dark_&]:bg-background`, h = { color: "var(--ttw-foreground)" }, g = "position: relative; z-index: calc(var(--tesouro-embedded-overlay-z-index, 2147483000) - 1); color: var(--ttw-foreground);", _ = typeof document > "u" ? s : c;
|
|
17
|
-
function v() {
|
|
18
|
-
let [e] = u(() => {
|
|
19
|
-
if (typeof document > "u") return;
|
|
20
|
-
let e = document.createElement("div");
|
|
21
|
-
return e.className = `tesouro-embedded ${p}`, e.setAttribute("style", g), e;
|
|
22
|
-
});
|
|
23
|
-
return _(() => {
|
|
24
|
-
if (e) return document.body.appendChild(e), () => e.remove();
|
|
25
|
-
}, [e]), e;
|
|
26
|
-
}
|
|
27
|
-
function y(e) {
|
|
28
|
-
return e instanceof Error ? e : Error(String(e));
|
|
29
|
-
}
|
|
30
|
-
function b({ finopsThemeColors: s, children: c }) {
|
|
31
|
-
let p = v(), { baseUrl: g, organizationId: _, initResponse: b, widgetToken: x } = n(), { client: S } = e(), C = t(), w = C !== null, T = C?.state, E = C?.refresh, D = C?.getState, O = w && T?.status === "ready" ? T.widgetToken : x ?? null, k = w && T?.status === "ready" ? T.exp : void 0, A = i(), [j, M] = u(() => ({
|
|
32
|
-
organizationId: _,
|
|
33
|
-
widgetToken: O,
|
|
34
|
-
widgetTokenExp: k
|
|
35
|
-
}));
|
|
36
|
-
!A && (j.organizationId !== _ || j.widgetToken !== O || j.widgetTokenExp !== k) && M({
|
|
37
|
-
organizationId: _,
|
|
38
|
-
widgetToken: O,
|
|
39
|
-
widgetTokenExp: k
|
|
40
|
-
});
|
|
41
|
-
let N = A ? j.organizationId : _, P = A ? j.widgetToken : O, F = A ? j.widgetTokenExp : k, I = r();
|
|
42
|
-
if (I) throw I;
|
|
43
|
-
if (T?.status === "error") throw T.error instanceof Error ? T.error : Error(String(T.error));
|
|
44
|
-
let L = b?.userId ?? null, R = w ? T?.status === "ready" : !!x, z = l(() => {
|
|
45
|
-
let e = S.getConfig();
|
|
46
|
-
return async (t, n) => {
|
|
47
|
-
let r = t instanceof Request ? t : new Request(t, n);
|
|
48
|
-
for (let t of S.interceptors.request.fns) t && (r = await t(r, e));
|
|
49
|
-
if (A) {
|
|
50
|
-
if (!P) throw Error("MoniteWrapper.fetch: widget token is not ready during init refresh");
|
|
51
|
-
r = new Request(r), r.headers.has("X-Client-Secret") ? (r.headers.delete("Authorization"), r.headers.set("X-Widget-Token", P)) : (r.headers.set("Authorization", `Bearer ${P}`), r.headers.has("X-Widget-Token") && r.headers.set("X-Widget-Token", P));
|
|
52
|
-
}
|
|
53
|
-
return (S.getConfig().fetch ?? globalThis.fetch)(r);
|
|
54
|
-
};
|
|
55
|
-
}, [
|
|
56
|
-
S,
|
|
57
|
-
A,
|
|
58
|
-
P
|
|
59
|
-
]), B = l(() => !g || !N ? null : {
|
|
60
|
-
apiUrl: g,
|
|
61
|
-
entityId: N,
|
|
62
|
-
fetch: z,
|
|
63
|
-
fetchToken: async () => {
|
|
64
|
-
if (A) {
|
|
65
|
-
if (!P) throw Error("MoniteWrapper.fetchToken: widget token is not ready during init refresh");
|
|
66
|
-
let e = Date.now() / 1e3;
|
|
67
|
-
return {
|
|
68
|
-
access_token: P,
|
|
69
|
-
expires_in: F === void 0 ? f : Math.max(0, F - e),
|
|
70
|
-
token_type: "Bearer"
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
if (!w) {
|
|
74
|
-
if (!x) throw Error("MoniteWrapper.fetchToken: widget token is not ready");
|
|
75
|
-
return {
|
|
76
|
-
access_token: x,
|
|
77
|
-
expires_in: f,
|
|
78
|
-
token_type: "Bearer"
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
if (!E || !D) throw Error("MoniteWrapper.fetchToken: token refresh provider is unavailable");
|
|
82
|
-
let e = !1, t = () => {
|
|
83
|
-
let e = D();
|
|
84
|
-
if (e.status === "error") throw y(e.error);
|
|
85
|
-
return e;
|
|
86
|
-
}, n = (e) => {
|
|
87
|
-
if (e.status !== "ready") throw Error("MoniteWrapper.fetchToken: widget token is not ready after refresh()");
|
|
88
|
-
return e;
|
|
89
|
-
}, r = D();
|
|
90
|
-
if (r.status === "error") throw y(r.error);
|
|
91
|
-
if (r.status !== "ready" && (await E(), e = !0, r = t()), r = n(r), r.exp === void 0 && !e && (await E(), r = n(t())), r.exp === void 0 && r.lastError !== void 0) throw y(r.lastError);
|
|
92
|
-
let i = Date.now() / 1e3, a = r.exp === void 0 ? f : Math.max(0, r.exp - i);
|
|
93
|
-
return {
|
|
94
|
-
access_token: r.widgetToken,
|
|
95
|
-
expires_in: a,
|
|
96
|
-
token_type: "Bearer"
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}, [
|
|
100
|
-
g,
|
|
101
|
-
D,
|
|
102
|
-
w,
|
|
103
|
-
A,
|
|
104
|
-
z,
|
|
105
|
-
P,
|
|
106
|
-
F,
|
|
107
|
-
N,
|
|
108
|
-
E,
|
|
109
|
-
x
|
|
110
|
-
]), V = l(() => new Set(b?.scopes ?? []), [b?.scopes]), H = l(() => {
|
|
111
|
-
if (!s) return;
|
|
112
|
-
let e = {};
|
|
113
|
-
return s.primary && (e.primary = s.primary), s.primaryForeground && (e.primaryForeground = s.primaryForeground), Object.keys(e).length > 0 ? { colors: e } : void 0;
|
|
114
|
-
}, [s]);
|
|
115
|
-
return !R || !B || !b || !g || !N ? null : /* @__PURE__ */ d(a, {
|
|
116
|
-
elements: p ? {
|
|
117
|
-
root: p,
|
|
118
|
-
styles: void 0
|
|
119
|
-
} : void 0,
|
|
120
|
-
children: /* @__PURE__ */ d(o, {
|
|
121
|
-
monite: B,
|
|
122
|
-
theme: H,
|
|
123
|
-
userPermissions: V,
|
|
124
|
-
componentSettings: { financing: { enableFinanceWidgetButton: !1 } },
|
|
125
|
-
children: /* @__PURE__ */ d("div", {
|
|
126
|
-
className: m,
|
|
127
|
-
style: h,
|
|
128
|
-
children: c
|
|
129
|
-
})
|
|
130
|
-
}, L ?? "no-user")
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
//#endregion
|
|
134
|
-
export { b as MoniteWrapper };
|