@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
@@ -2,63 +2,31 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { buildProductRows as e } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
6
- import { useProductsQuery as t } from "../../../shared/product-catalog/data-access/dist/index2.js";
5
+ import { useDeleteProductMutation as e } from "../../../shared/product-catalog/data-access/dist/index8.js";
7
6
  import "../../../shared/product-catalog/feature/dist/index.js";
8
- import { useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
7
+ import { useCallback as t, useState as n } from "react";
9
8
  //#region ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/index6.js
10
- function o({ unitNamesById: o }) {
11
- let [s, c] = a([]), [l, u] = a(10), [d, f] = a(), [p, m] = a(""), [h, g] = a(""), [_, v] = a("all"), [y, b] = a("all");
12
- r(() => {
13
- let e = setTimeout(() => {
14
- g(p), f(void 0);
15
- }, 400);
16
- return () => clearTimeout(e);
17
- }, [p]);
18
- let x = s[0]?.id === "name" ? "name" : void 0, S = s[0] ? s[0].desc ? "desc" : "asc" : void 0, C = t({
19
- ...x ? {
20
- sort: x,
21
- order: S
22
- } : {},
23
- limit: l,
24
- pagination_token: d,
25
- name__icontains: h || void 0,
26
- type: _ === "all" ? void 0 : _,
27
- measure_unit_id: y === "all" ? void 0 : y
28
- }), w = i(() => e({
29
- products: C.data?.data ?? [],
30
- unitNamesById: o
31
- }), [C.data, o]), T = !!h || _ !== "all" || y !== "all", E = n((e) => {
32
- let t = typeof e == "function" ? e(s) : e;
33
- c(t), f(void 0);
34
- }, [s]), D = n((e) => {
35
- u(e), f(void 0);
36
- }, []), O = n(() => f(C.data?.next_pagination_token ?? void 0), [C.data?.next_pagination_token]), k = n(() => f(C.data?.prev_pagination_token ?? void 0), [C.data?.prev_pagination_token]), A = n(() => {
37
- C.refetch();
38
- }, [C]), j = n((e) => (t) => {
39
- e(t), f(void 0);
40
- }, []);
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), []);
41
13
  return {
42
- rows: w,
43
- isLoading: C.isLoading,
44
- isError: C.isError,
45
- sorting: s,
46
- onSortingChange: E,
47
- pageSize: l,
48
- onPageSizeChange: D,
49
- hasNextPage: !!C.data?.next_pagination_token,
50
- hasPrevPage: !!C.data?.prev_pagination_token,
51
- onNextPage: O,
52
- onPrevPage: k,
53
- searchValue: p,
54
- onSearchChange: m,
55
- typeFilter: _,
56
- onTypeFilterChange: j(v),
57
- unitFilter: y,
58
- onUnitFilterChange: j(b),
59
- isFiltering: T,
60
- onRetry: A
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
61
29
  };
62
30
  }
63
31
  //#endregion
64
- export { o as useProductsTable };
32
+ export { r as useProductDelete };
@@ -2,49 +2,23 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { PRODUCT_MESSAGE_LABELS_EN as e } from "../../../shared/product-catalog/feature/dist/lib/labels.js";
6
- import { hasSelectedText as t } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
7
- import { useMeasureUnits as n } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
8
- import { useProductForm as r } from "../../../shared/product-catalog/feature/dist/lib/useProductForm.js";
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";
9
7
  import "../../../shared/product-catalog/feature/dist/index.js";
10
- import { useProductDelete as i } from "./index4.js";
11
- import { useProductDetails as a } from "./index5.js";
12
- import { useProductsTable as o } from "./index6.js";
13
- import { useCallback as s, useMemo as c, useState as l } from "react";
8
+ import { useMemo as n } from "react";
14
9
  //#region ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/index7.js
15
- function u({ messageLabels: u }) {
16
- let d = c(() => ({
17
- ...e,
18
- ...u
19
- }), [u]), [f, p] = l("none"), [m, h] = l(), [g, _] = l(!1), v = n(), y = o({ unitNamesById: v.unitNamesById }), b = a({
20
- selectedProductId: m,
21
- unitNamesById: v.unitNamesById
22
- });
10
+ function r({ selectedProductId: r, unitNamesById: i, enabled: a = !0 }) {
11
+ let o = t(r, { enabled: a }), s = n(() => o.data ? e({
12
+ product: o.data,
13
+ unitNamesById: i
14
+ }) : void 0, [o.data, i]);
23
15
  return {
24
- view: f,
25
- units: v,
26
- table: y,
27
- details: b,
28
- form: r({
29
- view: f,
30
- setView: p,
31
- selectedProductId: m,
32
- setSelectedProductId: h,
33
- product: b.product,
34
- messages: d
35
- }),
36
- del: i({
37
- selectedProductId: m,
38
- setSelectedProductId: h,
39
- setView: p
40
- }),
41
- measureUnitsOpen: g,
42
- handleRowClick: s((e) => {
43
- t() || (h(e.id), p("details"));
44
- }, []),
45
- openMeasureUnits: s(() => _(!0), []),
46
- closeMeasureUnits: s(() => _(!1), [])
16
+ product: o.data,
17
+ detailsView: s,
18
+ isLoading: o.isLoading,
19
+ isError: o.isError,
20
+ productName: o.data?.name ?? ""
47
21
  };
48
22
  }
49
23
  //#endregion
50
- export { u as useProductsWidget };
24
+ export { r as useProductDetails };
@@ -2,125 +2,64 @@
2
2
  "use client";
3
3
  "use client";
4
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";
5
+ import { buildProductRows as e } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
6
+ import { useProductsQuery as t } from "../../../shared/product-catalog/data-access/dist/index2.js";
10
7
  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 { useProductsWidget as s } from "./index7.js";
14
- import { ProductsScreen as c } from "../../ui/dist/index4.js";
15
- import { ProductDetailsSheet as l } from "../../ui/dist/index5.js";
16
- import { ProductDeleteDialog as u } from "../../ui/dist/index6.js";
17
- import "../../ui/dist/index.js";
18
- import { useEffect as d } from "react";
19
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
8
+ import { useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
20
9
  //#region ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/index8.js
21
- function h({ pageSizeOptions: t = o, screenLabels: a, formLabels: h, detailsLabels: g, deleteLabels: _, measureUnitsLabels: v, measureUnitDeleteLabels: y, messageLabels: b }) {
22
- let x = e();
23
- d(() => {
24
- x(i.Mounted);
25
- }, [x]);
26
- let { view: S, units: C, table: w, details: T, form: E, del: D, measureUnitsOpen: O, handleRowClick: k, openMeasureUnits: A, closeMeasureUnits: j } = s({ messageLabels: b });
27
- return /* @__PURE__ */ m(f, { children: [
28
- /* @__PURE__ */ p(c, {
29
- products: w.rows,
30
- isLoading: w.isLoading,
31
- isError: w.isError,
32
- sorting: w.sorting,
33
- onSortingChange: w.onSortingChange,
34
- pageSize: w.pageSize,
35
- onPageSizeChange: w.onPageSizeChange,
36
- pageSizeOptions: t,
37
- hasNextPage: w.hasNextPage,
38
- hasPrevPage: w.hasPrevPage,
39
- onNextPage: w.onNextPage,
40
- onPrevPage: w.onPrevPage,
41
- searchValue: w.searchValue,
42
- onSearchChange: w.onSearchChange,
43
- typeFilter: w.typeFilter,
44
- onTypeFilterChange: w.onTypeFilterChange,
45
- unitFilter: w.unitFilter,
46
- onUnitFilterChange: w.onUnitFilterChange,
47
- unitOptions: C.unitOptions,
48
- isFiltering: w.isFiltering,
49
- onCreateClick: E.openCreate,
50
- onManageUnitsClick: A,
51
- onRowClick: k,
52
- onRetry: w.onRetry,
53
- labels: a,
54
- emptyStateTestId: "products-widget-empty-state"
55
- }),
56
- /* @__PURE__ */ p(n, {
57
- open: S === "create" || S === "edit",
58
- onOpenChange: (e) => {
59
- e || E.close();
60
- },
61
- mode: S === "edit" ? "edit" : "create",
62
- values: E.values,
63
- errors: E.errors,
64
- unitOptions: C.unitOptions,
65
- currencyOptions: E.currencyOptions,
66
- inProgress: E.isSubmitting,
67
- onChange: (e) => E.setValues((t) => ({
68
- ...t,
69
- ...e
70
- })),
71
- onManageUnits: A,
72
- onSubmit: E.submit,
73
- onCancel: E.close,
74
- labels: h
75
- }),
76
- /* @__PURE__ */ p(l, {
77
- open: S === "details",
78
- onOpenChange: (e) => {
79
- e || E.close();
80
- },
81
- product: T.detailsView,
82
- isLoading: T.isLoading,
83
- isError: T.isError,
84
- onEdit: E.openEdit,
85
- onDelete: D.requestDelete,
86
- labels: g
87
- }),
88
- /* @__PURE__ */ p(u, {
89
- open: D.open,
90
- onOpenChange: D.onOpenChange,
91
- productName: T.productName,
92
- isDeleting: D.isDeleting,
93
- onConfirm: D.confirm,
94
- onCancel: D.cancel,
95
- labels: _
96
- }),
97
- /* @__PURE__ */ p(r, {
98
- open: O,
99
- onClose: j,
100
- managerLabels: v,
101
- deleteLabels: y,
102
- messageLabels: b
103
- })
104
- ] });
105
- }
106
- function g({ baseUrl: e, widgetToken: n, organizationId: r, configClient: i, gatewayRouting: o, linkComponent: s, implementation: c, uiFramework: l, errorFallback: u, onError: d, analytics: f, disclosuresAcceptance: m, providerLabels: g, ..._ }) {
107
- return /* @__PURE__ */ p(t, {
108
- widgetName: a,
109
- baseUrl: e,
110
- widgetToken: n,
111
- organizationId: r,
112
- configClient: i,
113
- gatewayRouting: o,
114
- linkComponent: s,
115
- implementation: c,
116
- uiFramework: l,
117
- errorFallback: u,
118
- onError: d,
119
- analytics: f,
120
- disclosuresAcceptance: m,
121
- providerLabels: g,
122
- children: /* @__PURE__ */ p(h, { ..._ })
123
- });
10
+ function o({ unitNamesById: o, enabled: s = !0 }) {
11
+ let [c, l] = a([]), [u, d] = a(10), [f, p] = a(), [m, h] = a(""), [g, _] = a(""), [v, y] = a("all"), [b, x] = a("all");
12
+ r(() => {
13
+ let e = setTimeout(() => {
14
+ _(m), p(void 0);
15
+ }, 400);
16
+ return () => clearTimeout(e);
17
+ }, [m]);
18
+ let S = c[0]?.id === "name" ? "name" : void 0, C = c[0] ? c[0].desc ? "desc" : "asc" : void 0, w = t({
19
+ ...S ? {
20
+ sort: S,
21
+ order: C
22
+ } : {},
23
+ limit: u,
24
+ pagination_token: f,
25
+ name__icontains: g || void 0,
26
+ type: v === "all" ? void 0 : v,
27
+ measure_unit_id: b === "all" ? void 0 : b,
28
+ enabled: s
29
+ }), T = i(() => e({
30
+ products: w.data?.data ?? [],
31
+ unitNamesById: o
32
+ }), [w.data, o]), E = !!g || v !== "all" || b !== "all", D = n((e) => {
33
+ let t = typeof e == "function" ? e(c) : e;
34
+ l(t), p(void 0);
35
+ }, [c]), O = n((e) => {
36
+ d(e), p(void 0);
37
+ }, []), k = n(() => p(w.data?.next_pagination_token ?? void 0), [w.data?.next_pagination_token]), A = n(() => p(w.data?.prev_pagination_token ?? void 0), [w.data?.prev_pagination_token]), j = n(() => {
38
+ w.refetch();
39
+ }, [w]), M = n((e) => (t) => {
40
+ e(t), p(void 0);
41
+ }, []);
42
+ return {
43
+ rows: T,
44
+ isLoading: w.isLoading,
45
+ isError: w.isError,
46
+ sorting: c,
47
+ onSortingChange: D,
48
+ pageSize: u,
49
+ onPageSizeChange: O,
50
+ hasNextPage: !!w.data?.next_pagination_token,
51
+ hasPrevPage: !!w.data?.prev_pagination_token,
52
+ onNextPage: k,
53
+ onPrevPage: A,
54
+ searchValue: m,
55
+ onSearchChange: h,
56
+ typeFilter: v,
57
+ onTypeFilterChange: M(y),
58
+ unitFilter: b,
59
+ onUnitFilterChange: M(x),
60
+ isFiltering: E,
61
+ onRetry: j
62
+ };
124
63
  }
125
64
  //#endregion
126
- export { g as ProductsWidget, g as default };
65
+ export { o as useProductsTable };
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useRefetchWidget as e, useWidgetConfig as t, useWidgetError as n, useWidgetInitStaleForToken as r, useWidgetLoading as i } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
6
+ import "../../../shared/feature/dist/index.js";
7
+ import { PRODUCT_MESSAGE_LABELS_EN as a } from "../../../shared/product-catalog/feature/dist/lib/labels.js";
8
+ import { hasSelectedText as o } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
9
+ import { useMeasureUnits as s } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
10
+ import { useProductForm as c } from "../../../shared/product-catalog/feature/dist/lib/useProductForm.js";
11
+ import "../../../shared/product-catalog/feature/dist/index.js";
12
+ import { getProductPermissions as l } from "./index5.js";
13
+ import { useProductDelete as u } from "./index6.js";
14
+ import { useProductDetails as d } from "./index7.js";
15
+ import { useProductsTable as f } from "./index8.js";
16
+ import { useCallback as p, useMemo as m, useState as h } from "react";
17
+ //#region ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/index9.js
18
+ function g({ messageLabels: g }) {
19
+ let _ = m(() => ({
20
+ ...a,
21
+ ...g
22
+ }), [g]), { initResponse: v, widgetToken: y } = t(), b = i(), x = n(), S = r(), C = e(), w = m(() => l(S ? void 0 : v?.scopes), [S, v?.scopes]), T = !(!y || v || x) || b && !v || S, E = !!x && (!v || S), [D, O] = h("none"), [k, A] = h(), [j, M] = h(!1), N = s({ enabled: w.canRead }), P = f({
23
+ unitNamesById: N.unitNamesById,
24
+ enabled: w.canRead
25
+ }), F = d({
26
+ selectedProductId: k,
27
+ unitNamesById: N.unitNamesById,
28
+ enabled: w.canRead
29
+ }), I = c({
30
+ view: D,
31
+ setView: O,
32
+ selectedProductId: k,
33
+ setSelectedProductId: A,
34
+ product: F.product,
35
+ messages: _
36
+ }), L = u({
37
+ selectedProductId: k,
38
+ setSelectedProductId: A,
39
+ setView: O
40
+ });
41
+ if (!S) {
42
+ let { canRead: e, canCreate: t, canUpdate: n, canDelete: r } = w;
43
+ (!e && (D !== "none" || k) || D === "create" && !t || D === "edit" && !n) && (O("none"), A(void 0)), L.open && !(e && r) && L.cancel(), j && !(e && t) && M(!1);
44
+ }
45
+ let R = p((e) => {
46
+ w.canRead && !o() && (A(e.id), O("details"));
47
+ }, [w.canRead]), z = p(() => {
48
+ w.canCreate && M(!0);
49
+ }, [w.canCreate]), B = p(() => M(!1), []), V = p(() => S ? void 0 : I.submit(), [S, I.submit]), H = p(() => S ? void 0 : L.confirm(), [S, L.confirm]);
50
+ return {
51
+ view: D,
52
+ units: N,
53
+ table: P,
54
+ details: F,
55
+ form: I,
56
+ del: L,
57
+ permissions: w,
58
+ isPermissionLoading: T,
59
+ isTableLoading: P.isLoading || T && P.rows.length === 0,
60
+ hasInitError: E,
61
+ refetchWidgetInit: C,
62
+ measureUnitsOpen: j,
63
+ actionsSuspended: S,
64
+ handleRowClick: R,
65
+ openMeasureUnits: z,
66
+ closeMeasureUnits: B,
67
+ submitForm: V,
68
+ confirmDelete: H
69
+ };
70
+ }
71
+ //#endregion
72
+ export { g as useProductsWidget };
@@ -23,6 +23,8 @@ var e = {
23
23
  errorTitle: "Failed to load products",
24
24
  errorDescription: "Something went wrong while fetching your products. Please try again.",
25
25
  errorRetry: "Try again",
26
+ accessRestrictedTitle: "Access restricted",
27
+ accessRestrictedDescription: "You don't have permission to view products.",
26
28
  openRow: (e) => `View product — ${e}`,
27
29
  typeBadge: {
28
30
  product: "Product",