@tesouro/embedded-components-react 0.5.202 → 0.5.204

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 (42) hide show
  1. package/README.md +20 -6
  2. package/dist/index.css +12 -0
  3. package/dist/index.d.ts +70 -7
  4. package/dist/index.js +7 -6
  5. package/dist/lib/MarketingWidget.d.ts +66 -7
  6. package/dist/lib/MarketingWidget.js +5 -4
  7. package/dist/lib/ProductsWidget.d.ts +4 -0
  8. package/dist/lib/ProductsWidget.js +1 -1
  9. package/dist/lib/ReceivablesWidget.d.ts +2 -0
  10. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index.js +5 -4
  11. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index3.js +1 -0
  12. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index4.js +33 -81
  13. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index5.js +34 -0
  14. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index6.js +20 -0
  15. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index7.js +161 -0
  16. package/dist/libs/tesouro-embedded-components-react/marketing-widget/ui/dist/index.js +3 -3
  17. package/dist/libs/tesouro-embedded-components-react/marketing-widget/ui/dist/index3.js +5 -1
  18. package/dist/libs/tesouro-embedded-components-react/marketing-widget/ui/dist/index8.js +34 -81
  19. package/dist/libs/tesouro-embedded-components-react/marketing-widget/ui/dist/index9.js +92 -0
  20. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index10.js +136 -0
  22. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index4.js +5 -30
  23. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index5.js +9 -19
  24. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index6.js +22 -54
  25. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index7.js +14 -40
  26. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index8.js +57 -118
  27. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index9.js +72 -0
  28. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index2.js +2 -0
  29. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js +97 -93
  30. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js +35 -32
  31. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +2 -1
  32. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useOrganizationApplicationStatus.js +25 -0
  33. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useOrganizationOnboardingSuppression.js +9 -9
  34. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  35. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index10.js +8 -8
  36. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index4.js +8 -8
  37. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index9.js +8 -8
  38. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +79 -70
  39. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useMeasureUnits.js +4 -4
  40. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +1 -0
  41. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +109 -107
  42. package/package.json +1 -1
@@ -0,0 +1,161 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useOrganizationApplicationStatus as e } from "../../../shared/data-access/dist/lib/useOrganizationApplicationStatus.js";
6
+ import "../../../shared/data-access/dist/index.js";
7
+ import { useAnalyticsTrack as t } from "../../../shared/feature/dist/lib/analytics/hooks.js";
8
+ import { WidgetProvider as n } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
9
+ import { useWidgetConfig as r, useWidgetInitStaleForToken as i } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import "../../../shared/feature/dist/index.js";
11
+ import { MARKETING_WIDGET_STATUS_LABELS_EN as a } from "./index4.js";
12
+ import { MarketingWidgetAnalyticsEvent as o, WIDGET_NAME as s } from "./index2.js";
13
+ import { marketingWidgetTestIds as c } from "./index3.js";
14
+ import { MarketingApplicationView as l, deniedNoticeExpiresAt as u, marketingApplicationViewFor as d } from "./index5.js";
15
+ import { selectBankAccountApplication as f } from "./index6.js";
16
+ import { MARKETING_WIDGET_LABELS_EN as p } from "../../ui/dist/index2.js";
17
+ import { MarketingBenefitIcon as m, MarketingWidgetStatusTone as h } from "../../ui/dist/index3.js";
18
+ import { MarketingWidget as g } from "../../ui/dist/index9.js";
19
+ import "../../ui/dist/index.js";
20
+ import { useCallback as _, useEffect as v, useMemo as y, useReducer as b, useState as x } from "react";
21
+ import { jsx as S } from "react/jsx-runtime";
22
+ //#region ../../libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index7.js
23
+ var C = 2 ** 31 - 1, w = /* @__PURE__ */ new Set([
24
+ "ACTIVE",
25
+ "INACTIVE",
26
+ "INVITED"
27
+ ]), T = {
28
+ [l.DraftStartedByOther]: "draftStartedByOther",
29
+ [l.SubmittedByYou]: "submittedByYou",
30
+ [l.SubmittedByOther]: "submittedByOther",
31
+ [l.DeniedByYou]: "deniedByYou",
32
+ [l.DeniedByOther]: "deniedByOther"
33
+ }, E = {
34
+ [l.DraftStartedByOther]: h.Brand,
35
+ [l.SubmittedByYou]: h.Warning,
36
+ [l.SubmittedByOther]: h.Warning,
37
+ [l.DeniedByYou]: h.Danger,
38
+ [l.DeniedByOther]: h.Danger
39
+ };
40
+ function D(e) {
41
+ return e in T;
42
+ }
43
+ function O(e) {
44
+ let t = a, n = (n) => ({
45
+ ...t[n],
46
+ ...e?.[n]
47
+ });
48
+ return {
49
+ resumeApplication: e?.resumeApplication ?? t.resumeApplication,
50
+ bankNameFallback: e?.bankNameFallback ?? t.bankNameFallback,
51
+ formatDate: e?.formatDate ?? t.formatDate,
52
+ draftStartedByOther: n("draftStartedByOther"),
53
+ submittedByYou: n("submittedByYou"),
54
+ submittedByOther: n("submittedByOther"),
55
+ deniedByYou: n("deniedByYou"),
56
+ deniedByOther: n("deniedByOther")
57
+ };
58
+ }
59
+ function k(e, t, n) {
60
+ let r = (e) => e ? n(e) : void 0;
61
+ return {
62
+ bankName: t,
63
+ applicantName: [e?.applicantFirstName, e?.applicantLastName].map((e) => e?.trim()).filter(Boolean).join(" ") || void 0,
64
+ startedOn: r(e?.createdAt),
65
+ submittedOn: r(e?.submittedAt),
66
+ deniedOn: r(e?.deniedAt)
67
+ };
68
+ }
69
+ function A({ content: n, onPrimaryCtaClick: a, labels: s, statusLabels: p }) {
70
+ let m = t(), { initResponse: h } = r(), A = i(), j = e(), [M, N] = x(!1), [P, F] = b((e) => e + 1, 0), I = y(() => f(j.applications), [j.applications]), L = u(I), R = y(() => O(p), [p]), z = d(I), B = h?.bankName || R.bankNameFallback, V = y(() => {
71
+ if (!D(z)) return;
72
+ let e = R[T[z]], t = k(I, B, R.formatDate);
73
+ return {
74
+ chipLabel: e.chipLabel,
75
+ chipTone: E[z],
76
+ heading: e.heading?.(t),
77
+ body: e.body(t)
78
+ };
79
+ }, [
80
+ I,
81
+ B,
82
+ R,
83
+ z
84
+ ]), H = y(() => z === l.Resume ? {
85
+ ...s,
86
+ applyNow: R.resumeApplication,
87
+ primaryCta: R.resumeApplication
88
+ } : s, [
89
+ s,
90
+ R.resumeApplication,
91
+ z
92
+ ]);
93
+ v(() => {
94
+ m(o.Mounted);
95
+ }, [m]), v(() => {
96
+ if (L === null) return;
97
+ let e = L - Date.now();
98
+ if (e < 0) return;
99
+ let t = setTimeout(F, Math.min(e + 1, C));
100
+ return () => clearTimeout(t);
101
+ }, [L, P]);
102
+ let U = !V && z !== l.Hidden;
103
+ M && !U && N(!1);
104
+ let W = _(() => {
105
+ m(o.OpenModal), N(!0);
106
+ }, [m]), G = _(() => {
107
+ N(!1);
108
+ }, []), K = _(() => {
109
+ m(o.PrimaryCta), N(!1), a();
110
+ }, [a, m]);
111
+ return !h?.status || w.has(h.status) || A || !j.isResolved || z === l.Hidden ? null : /* @__PURE__ */ S(g, {
112
+ open: M,
113
+ vspLogo: n.vspLogo,
114
+ bankingText: n.bankingText,
115
+ primaryCaption: n.primaryCaption,
116
+ secondaryCaption: n.secondaryCaption,
117
+ providedByCaption: n.providedByCaption,
118
+ primaryModalHeader: n.primaryModalHeader,
119
+ howItWorksHeader: n.howItWorksHeader,
120
+ howItWorksSteps: n.howItWorksSteps,
121
+ fromDayOneHeader: n.fromDayOneHeader,
122
+ benefits: n.benefits,
123
+ appearance: n.appearance,
124
+ onOpenMarketingModal: W,
125
+ onCloseMarketingModal: G,
126
+ onPrimaryCtaClick: K,
127
+ statusMessage: V,
128
+ labels: H,
129
+ testIds: {
130
+ root: c.root,
131
+ learnMoreButton: c.learnMoreButton,
132
+ applyNowButton: c.applyNowButton,
133
+ statusMessage: c.statusMessage,
134
+ modal: {
135
+ root: c.modal,
136
+ primaryCtaButton: c.primaryCtaButton
137
+ }
138
+ }
139
+ });
140
+ }
141
+ function j({ baseUrl: e, widgetToken: t, organizationId: r, configClient: i, gatewayRouting: a, linkComponent: o, implementation: c, uiFramework: l, errorFallback: u, onError: d, analytics: f, disclosuresAcceptance: p, providerLabels: m, ...h }) {
142
+ return /* @__PURE__ */ S(n, {
143
+ widgetName: s,
144
+ baseUrl: e,
145
+ widgetToken: t,
146
+ organizationId: r,
147
+ configClient: i,
148
+ gatewayRouting: a,
149
+ linkComponent: o,
150
+ implementation: c,
151
+ uiFramework: l,
152
+ errorFallback: u,
153
+ onError: d,
154
+ analytics: f,
155
+ disclosuresAcceptance: p,
156
+ providerLabels: m,
157
+ children: /* @__PURE__ */ S(A, { ...h })
158
+ });
159
+ }
160
+ //#endregion
161
+ export { p as MARKETING_WIDGET_LABELS_EN, a as MARKETING_WIDGET_STATUS_LABELS_EN, m as MarketingBenefitIcon, j as MarketingWidget };
@@ -1,5 +1,5 @@
1
1
  import { MARKETING_WIDGET_LABELS_EN as e } from "./index2.js";
2
- import { MarketingBenefitIcon as t } from "./index3.js";
2
+ import { MarketingBenefitIcon as t, MarketingWidgetStatusTone as n } from "./index3.js";
3
3
  import "./index7.js";
4
- import { MarketingWidget as n } from "./index8.js";
5
- export { e as MARKETING_WIDGET_LABELS_EN, t as MarketingBenefitIcon, n as MarketingWidget };
4
+ import { MarketingWidget as r } from "./index9.js";
5
+ export { e as MARKETING_WIDGET_LABELS_EN, t as MarketingBenefitIcon, r as MarketingWidget, n as MarketingWidgetStatusTone };
@@ -5,6 +5,10 @@ var e = {
5
5
  Document: "document",
6
6
  Dollar: "dollar",
7
7
  Card: "card"
8
+ }, t = {
9
+ Brand: "brand",
10
+ Warning: "warning",
11
+ Danger: "danger"
8
12
  };
9
13
  //#endregion
10
- export { e as MarketingBenefitIcon };
14
+ export { e as MarketingBenefitIcon, t as MarketingWidgetStatusTone };
@@ -1,88 +1,41 @@
1
- import { Button as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { MARKETING_WIDGET_LABELS_EN as t } from "./index2.js";
3
- import { MarketingWidgetModal as n } from "./index7.js";
4
- import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
1
+ import { Badge as e, cn as t } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { MarketingWidgetStatusTone as n } from "./index3.js";
3
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
4
  //#region ../../libs/tesouro-embedded-components-react/marketing-widget/ui/dist/index8.js
6
- function o({ open: o, vspLogo: s, bankingText: c, primaryCaption: l, secondaryCaption: u, providedByCaption: d, primaryModalHeader: f, howItWorksHeader: p, howItWorksSteps: m, fromDayOneHeader: h, benefits: g, appearance: _, onOpenMarketingModal: v, onCloseMarketingModal: y, onPrimaryCtaClick: b, labels: x, testIds: S }) {
7
- let C = {
8
- ...t,
9
- ...x
10
- };
11
- return /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ a("div", {
12
- "data-testid": S?.root,
13
- className: "ttw:relative ttw:flex ttw:w-full ttw:flex-col ttw:items-start ttw:overflow-hidden ttw:border ttw:border-border ttw:p-6",
14
- style: {
15
- backgroundColor: _.cardBackgroundColor,
16
- borderRadius: _.borderRadius,
17
- boxShadow: _.boxShadow
18
- },
5
+ var a = {
6
+ [n.Brand]: "ttw:border-transparent",
7
+ [n.Warning]: "ttw:border-amber-100 ttw:bg-amber-100 ttw:text-amber-700",
8
+ [n.Danger]: "ttw:border-destructive/20 ttw:bg-destructive/20 ttw:text-destructive"
9
+ };
10
+ function o({ statusMessage: o, primaryColor: s, testId: c }) {
11
+ let { chipLabel: l, chipTone: u, heading: d, body: f } = o, p = u === n.Brand;
12
+ return /* @__PURE__ */ i("div", {
13
+ "data-testid": c,
14
+ className: "ttw:flex ttw:flex-col ttw:items-start",
19
15
  children: [
20
- /* @__PURE__ */ a("div", {
21
- className: "ttw:mb-2 ttw:flex ttw:items-center ttw:gap-3",
22
- children: [/* @__PURE__ */ i("img", {
23
- src: s.src,
24
- alt: s.alt,
25
- height: 40,
26
- width: s.width,
27
- className: "ttw:h-10 ttw:w-auto ttw:object-contain"
28
- }), /* @__PURE__ */ i("p", {
29
- className: "ttw:text-xl ttw:font-semibold ttw:text-foreground",
30
- children: c
31
- })]
16
+ /* @__PURE__ */ i(e, {
17
+ variant: "outline",
18
+ className: t("ttw:mb-2 ttw:gap-2 ttw:rounded-full ttw:px-3 ttw:py-1 ttw:text-sm", a[u]),
19
+ style: p ? {
20
+ color: s,
21
+ backgroundColor: `color-mix(in srgb, ${s} 12%, transparent)`
22
+ } : void 0,
23
+ children: [/* @__PURE__ */ r("span", {
24
+ "aria-hidden": "true",
25
+ className: "ttw:size-2 ttw:rounded-full ttw:bg-current"
26
+ }), l]
32
27
  }),
33
- /* @__PURE__ */ i("p", {
34
- className: "ttw:mb-2 ttw:text-sm ttw:text-muted-foreground",
28
+ d ? /* @__PURE__ */ r("p", {
29
+ className: "ttw:text-xl ttw:font-semibold",
30
+ style: { color: s },
35
31
  children: d
36
- }),
37
- /* @__PURE__ */ a("div", {
38
- className: "ttw:mb-2 ttw:flex ttw:flex-col",
39
- children: [/* @__PURE__ */ i("p", {
40
- className: "ttw:text-xl ttw:font-semibold",
41
- style: { color: _.primaryColor },
42
- children: l
43
- }), /* @__PURE__ */ i("p", {
44
- className: "ttw:leading-snug",
45
- style: { color: _.primaryColor },
46
- children: u
47
- })]
48
- }),
49
- /* @__PURE__ */ a("div", {
50
- className: "ttw:flex ttw:flex-wrap ttw:gap-3",
51
- children: [/* @__PURE__ */ i(e, {
52
- type: "button",
53
- "data-testid": S?.applyNowButton,
54
- onClick: b,
55
- className: "ttw:h-auto ttw:rounded-xl ttw:px-6 ttw:py-2 ttw:text-base ttw:font-light ttw:transition-[filter] ttw:hover:brightness-90",
56
- style: {
57
- backgroundColor: _.primaryColor,
58
- color: _.primaryContrastColor
59
- },
60
- children: C.applyNow
61
- }), /* @__PURE__ */ i(e, {
62
- type: "button",
63
- variant: "outline",
64
- "data-testid": S?.learnMoreButton,
65
- onClick: v,
66
- className: "ttw:h-auto ttw:rounded-xl ttw:px-6 ttw:py-2 ttw:text-base ttw:font-light",
67
- children: C.learnMore
68
- })]
69
- })
32
+ }) : null,
33
+ f.map((e) => /* @__PURE__ */ r("p", {
34
+ className: "ttw:mt-1 ttw:text-sm ttw:text-muted-foreground",
35
+ children: e
36
+ }, e))
70
37
  ]
71
- }), /* @__PURE__ */ i(n, {
72
- open: o,
73
- vspLogo: s,
74
- providedByCaption: d,
75
- primaryModalHeader: f,
76
- howItWorksHeader: p,
77
- howItWorksSteps: m,
78
- fromDayOneHeader: h,
79
- benefits: g,
80
- appearance: _,
81
- onClose: y,
82
- onPrimaryCtaClick: b,
83
- labels: x,
84
- testIds: S?.modal
85
- })] });
38
+ });
86
39
  }
87
40
  //#endregion
88
- export { o as MarketingWidget };
41
+ export { o as MarketingWidgetStatus };
@@ -0,0 +1,92 @@
1
+ import { Button as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { MARKETING_WIDGET_LABELS_EN as t } from "./index2.js";
3
+ import { MarketingWidgetModal as n } from "./index7.js";
4
+ import { MarketingWidgetStatus as r } from "./index8.js";
5
+ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
6
+ //#region ../../libs/tesouro-embedded-components-react/marketing-widget/ui/dist/index9.js
7
+ function s({ open: s, vspLogo: c, bankingText: l, primaryCaption: u, secondaryCaption: d, providedByCaption: f, primaryModalHeader: p, howItWorksHeader: m, howItWorksSteps: h, fromDayOneHeader: g, benefits: _, appearance: v, onOpenMarketingModal: y, onCloseMarketingModal: b, onPrimaryCtaClick: x, statusMessage: S, labels: C, testIds: w }) {
8
+ let T = {
9
+ ...t,
10
+ ...C
11
+ };
12
+ return /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ o("div", {
13
+ "data-testid": w?.root,
14
+ className: "ttw:relative ttw:flex ttw:w-full ttw:flex-col ttw:items-start ttw:overflow-hidden ttw:border ttw:border-border ttw:p-6",
15
+ style: {
16
+ backgroundColor: v.cardBackgroundColor,
17
+ borderRadius: v.borderRadius,
18
+ boxShadow: v.boxShadow
19
+ },
20
+ children: [
21
+ /* @__PURE__ */ o("div", {
22
+ className: "ttw:mb-2 ttw:flex ttw:items-center ttw:gap-3",
23
+ children: [/* @__PURE__ */ a("img", {
24
+ src: c.src,
25
+ alt: c.alt,
26
+ height: 40,
27
+ width: c.width,
28
+ className: "ttw:h-10 ttw:w-auto ttw:object-contain"
29
+ }), /* @__PURE__ */ a("p", {
30
+ className: "ttw:text-xl ttw:font-semibold ttw:text-foreground",
31
+ children: l
32
+ })]
33
+ }),
34
+ /* @__PURE__ */ a("p", {
35
+ className: "ttw:mb-2 ttw:text-sm ttw:text-muted-foreground",
36
+ children: f
37
+ }),
38
+ S ? /* @__PURE__ */ a(r, {
39
+ statusMessage: S,
40
+ primaryColor: v.primaryColor,
41
+ testId: w?.statusMessage
42
+ }) : /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ o("div", {
43
+ className: "ttw:mb-2 ttw:flex ttw:flex-col",
44
+ children: [/* @__PURE__ */ a("p", {
45
+ className: "ttw:text-xl ttw:font-semibold",
46
+ style: { color: v.primaryColor },
47
+ children: u
48
+ }), /* @__PURE__ */ a("p", {
49
+ className: "ttw:leading-snug",
50
+ style: { color: v.primaryColor },
51
+ children: d
52
+ })]
53
+ }), /* @__PURE__ */ o("div", {
54
+ className: "ttw:flex ttw:flex-wrap ttw:gap-3",
55
+ children: [/* @__PURE__ */ a(e, {
56
+ type: "button",
57
+ "data-testid": w?.applyNowButton,
58
+ onClick: x,
59
+ className: "ttw:h-auto ttw:rounded-xl ttw:px-6 ttw:py-2 ttw:text-base ttw:font-light ttw:transition-[filter] ttw:hover:brightness-90",
60
+ style: {
61
+ backgroundColor: v.primaryColor,
62
+ color: v.primaryContrastColor
63
+ },
64
+ children: T.applyNow
65
+ }), /* @__PURE__ */ a(e, {
66
+ type: "button",
67
+ variant: "outline",
68
+ "data-testid": w?.learnMoreButton,
69
+ onClick: y,
70
+ className: "ttw:h-auto ttw:rounded-xl ttw:px-6 ttw:py-2 ttw:text-base ttw:font-light",
71
+ children: T.learnMore
72
+ })]
73
+ })] })
74
+ ]
75
+ }), /* @__PURE__ */ a(n, {
76
+ open: s,
77
+ vspLogo: c,
78
+ providedByCaption: f,
79
+ primaryModalHeader: p,
80
+ howItWorksHeader: m,
81
+ howItWorksSteps: h,
82
+ fromDayOneHeader: g,
83
+ benefits: _,
84
+ appearance: v,
85
+ onClose: b,
86
+ onPrimaryCtaClick: x,
87
+ labels: C,
88
+ testIds: w?.modal
89
+ })] });
90
+ }
91
+ //#endregion
92
+ export { s as MarketingWidget };
@@ -1,2 +1,2 @@
1
- import { ProductsWidget as e } from "./index8.js";
1
+ import { ProductsWidget as e } from "./index10.js";
2
2
  export { e as ProductsWidget };
@@ -0,0 +1,136 @@
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 { ProductFormSheet as n } from "../../../shared/product-catalog/ui/dist/index3.js";
9
+ import { MeasureUnitsManagerContainer as r } from "../../../shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js";
10
+ import "../../../shared/product-catalog/feature/dist/index.js";
11
+ import { ProductsWidgetAnalyticsEvent as i, WIDGET_NAME as a } from "./index2.js";
12
+ import { PAGE_SIZE_OPTIONS as o } from "./index3.js";
13
+ import { productsWidgetTestIds as s } from "./index4.js";
14
+ import { useProductsWidget as c } from "./index9.js";
15
+ import { ProductsScreen as l } from "../../ui/dist/index4.js";
16
+ import { ProductDetailsSheet as u } from "../../ui/dist/index5.js";
17
+ import { ProductDeleteDialog as d } from "../../ui/dist/index6.js";
18
+ import "../../ui/dist/index.js";
19
+ import { useEffect as f } from "react";
20
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
21
+ //#region ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/index10.js
22
+ function g({ pageSizeOptions: t = o, screenLabels: a, formLabels: g, detailsLabels: _, deleteLabels: v, measureUnitsLabels: y, measureUnitDeleteLabels: b, messageLabels: x }) {
23
+ let S = e();
24
+ f(() => {
25
+ S(i.Mounted);
26
+ }, [S]);
27
+ let { view: C, units: w, table: T, details: E, form: D, del: O, permissions: k, isPermissionLoading: A, isTableLoading: j, hasInitError: M, refetchWidgetInit: N, measureUnitsOpen: P, actionsSuspended: F, handleRowClick: I, openMeasureUnits: L, closeMeasureUnits: R, submitForm: z, confirmDelete: B } = c({ messageLabels: x });
28
+ return /* @__PURE__ */ h(p, { children: [
29
+ /* @__PURE__ */ m(l, {
30
+ products: T.rows,
31
+ isLoading: j,
32
+ isError: M || T.isError,
33
+ sorting: T.sorting,
34
+ onSortingChange: T.onSortingChange,
35
+ pageSize: T.pageSize,
36
+ onPageSizeChange: T.onPageSizeChange,
37
+ pageSizeOptions: t,
38
+ hasNextPage: T.hasNextPage,
39
+ hasPrevPage: T.hasPrevPage,
40
+ onNextPage: T.onNextPage,
41
+ onPrevPage: T.onPrevPage,
42
+ searchValue: T.searchValue,
43
+ onSearchChange: T.onSearchChange,
44
+ typeFilter: T.typeFilter,
45
+ onTypeFilterChange: T.onTypeFilterChange,
46
+ unitFilter: T.unitFilter,
47
+ onUnitFilterChange: T.onUnitFilterChange,
48
+ unitOptions: w.unitOptions,
49
+ isFiltering: T.isFiltering,
50
+ canCreate: k.canCreate,
51
+ canManageUnits: k.canCreate,
52
+ isAccessRestricted: !A && !M && !k.canRead,
53
+ onCreateClick: D.openCreate,
54
+ onManageUnitsClick: L,
55
+ onRowClick: I,
56
+ onRetry: M ? N : T.onRetry,
57
+ labels: a,
58
+ testIds: {
59
+ empty: s.empty,
60
+ accessRestricted: s.accessRestricted
61
+ }
62
+ }),
63
+ /* @__PURE__ */ m(n, {
64
+ open: C === "create" || C === "edit",
65
+ onOpenChange: (e) => {
66
+ e || D.close();
67
+ },
68
+ mode: C === "edit" ? "edit" : "create",
69
+ values: D.values,
70
+ errors: D.errors,
71
+ unitOptions: w.unitOptions,
72
+ currencyOptions: D.currencyOptions,
73
+ inProgress: D.isSubmitting || F,
74
+ onChange: (e) => D.setValues((t) => ({
75
+ ...t,
76
+ ...e
77
+ })),
78
+ onManageUnits: L,
79
+ onSubmit: z,
80
+ onCancel: D.close,
81
+ labels: g
82
+ }),
83
+ /* @__PURE__ */ m(u, {
84
+ open: C === "details",
85
+ onOpenChange: (e) => {
86
+ e || D.close();
87
+ },
88
+ product: E.detailsView,
89
+ isLoading: E.isLoading,
90
+ isError: E.isError,
91
+ onEdit: D.openEdit,
92
+ onDelete: O.requestDelete,
93
+ canEdit: k.canUpdate,
94
+ canDelete: k.canDelete,
95
+ labels: _
96
+ }),
97
+ /* @__PURE__ */ m(d, {
98
+ open: O.open,
99
+ onOpenChange: O.onOpenChange,
100
+ productName: E.productName,
101
+ isDeleting: O.isDeleting || F,
102
+ onConfirm: B,
103
+ onCancel: O.cancel,
104
+ labels: v
105
+ }),
106
+ /* @__PURE__ */ m(r, {
107
+ open: P,
108
+ onClose: R,
109
+ suspended: F,
110
+ managerLabels: y,
111
+ deleteLabels: b,
112
+ messageLabels: x
113
+ })
114
+ ] });
115
+ }
116
+ function _({ baseUrl: e, widgetToken: n, organizationId: r, configClient: i, gatewayRouting: o, linkComponent: s, implementation: c, uiFramework: l, errorFallback: u, onError: d, analytics: f, disclosuresAcceptance: p, providerLabels: h, ..._ }) {
117
+ return /* @__PURE__ */ m(t, {
118
+ widgetName: a,
119
+ baseUrl: e,
120
+ widgetToken: n,
121
+ organizationId: r,
122
+ configClient: i,
123
+ gatewayRouting: o,
124
+ linkComponent: s,
125
+ implementation: c,
126
+ uiFramework: l,
127
+ errorFallback: u,
128
+ onError: d,
129
+ analytics: f,
130
+ disclosuresAcceptance: p,
131
+ providerLabels: h,
132
+ children: /* @__PURE__ */ m(g, { ..._ })
133
+ });
134
+ }
135
+ //#endregion
136
+ export { _ as ProductsWidget, _ as default };
@@ -1,32 +1,7 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { useDeleteProductMutation as e } from "../../../shared/product-catalog/data-access/dist/index8.js";
6
- import "../../../shared/product-catalog/feature/dist/index.js";
7
- import { useCallback as t, useState as n } from "react";
8
1
  //#region ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/index4.js
9
- function r({ selectedProductId: r, setSelectedProductId: i, setView: a }) {
10
- let o = e(), [s, c] = n(!1), l = t(() => c(!0), []), u = t((e) => {
11
- e || c(!1);
12
- }, []), d = t(() => c(!1), []);
13
- return {
14
- open: s,
15
- requestDelete: l,
16
- onOpenChange: u,
17
- confirm: t(async () => {
18
- if (r) try {
19
- await o.mutateAsync({ path: { product_id: r } }), c(!1), a("none"), i(void 0);
20
- } catch {}
21
- }, [
22
- r,
23
- o,
24
- a,
25
- i
26
- ]),
27
- cancel: d,
28
- isDeleting: o.isPending
29
- };
30
- }
2
+ var e = {
3
+ empty: "products-widget-empty-state",
4
+ accessRestricted: "products-widget-access-restricted"
5
+ };
31
6
  //#endregion
32
- export { r as useProductDelete };
7
+ export { e as productsWidgetTestIds };
@@ -1,24 +1,14 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { buildProductDetailsView as e } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
6
- import { useProductQuery as t } from "../../../shared/product-catalog/data-access/dist/index4.js";
7
- import "../../../shared/product-catalog/feature/dist/index.js";
8
- import { useMemo as n } from "react";
1
+ import { Scope as e } from "../../../shared/data-access/dist/lib/scopes.js";
2
+ import "../../../shared/data-access/dist/index.js";
9
3
  //#region ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/index5.js
10
- function r({ selectedProductId: r, unitNamesById: i }) {
11
- let a = t(r), o = n(() => a.data ? e({
12
- product: a.data,
13
- unitNamesById: i
14
- }) : void 0, [a.data, i]);
4
+ function t(t) {
5
+ let n = new Set(t ?? []), r = n.has(e.InvoiceReadOrg), i = n.has(e.InvoiceWriteOrg);
15
6
  return {
16
- product: a.data,
17
- detailsView: o,
18
- isLoading: a.isLoading,
19
- isError: a.isError,
20
- productName: a.data?.name ?? ""
7
+ canRead: r,
8
+ canCreate: i,
9
+ canUpdate: i,
10
+ canDelete: i
21
11
  };
22
12
  }
23
13
  //#endregion
24
- export { r as useProductDetails };
14
+ export { t as getProductPermissions };