@tesouro/embedded-components-react 0.5.203 → 0.5.205

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 (65) hide show
  1. package/README.md +15 -14
  2. package/dist/index.css +9 -0
  3. package/dist/index.d.ts +42 -0
  4. package/dist/index.js +2 -2
  5. package/dist/lib/ProductsWidget.d.ts +4 -0
  6. package/dist/lib/ProductsWidget.js +1 -1
  7. package/dist/lib/ReceivablesWidget.d.ts +40 -0
  8. package/dist/lib/ReceivablesWidget.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +7 -7
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +26 -23
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +79 -2
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +53 -42
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +81 -283
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +47 -70
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +303 -99
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +68 -230
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +115 -0
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +253 -0
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +34 -19
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +14 -0
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +10 -9
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +18 -1
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +0 -3
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +0 -7
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +10 -0
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +1 -264
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +259 -67
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +61 -412
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +407 -89
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +73 -60
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +80 -331
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +20 -0
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +344 -0
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +183 -137
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +157 -20
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +24 -1
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +1 -3
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +1 -1
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +3 -18
  42. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index.js +1 -1
  43. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index10.js +136 -0
  44. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index4.js +5 -30
  45. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index5.js +9 -19
  46. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index6.js +22 -54
  47. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index7.js +14 -40
  48. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index8.js +57 -118
  49. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index9.js +72 -0
  50. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index2.js +2 -0
  51. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js +97 -93
  52. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js +35 -32
  53. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +38 -38
  54. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +213 -202
  55. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +136 -116
  56. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  57. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index10.js +8 -8
  58. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index4.js +8 -8
  59. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index9.js +8 -8
  60. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +79 -70
  61. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useMeasureUnits.js +4 -4
  62. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +1 -0
  63. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +109 -107
  64. package/dist/packages/shared-ui-shadcn/dist/index.js +1763 -1749
  65. package/package.json +1 -1
@@ -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",
@@ -4,104 +4,107 @@ import { ErrorState as d } from "../../../shared/ui/dist/lib/ErrorState/ErrorSta
4
4
  import "../../../shared/ui/dist/index.js";
5
5
  import { PRODUCTS_SCREEN_LABELS_EN as f } from "./index2.js";
6
6
  import { ProductTypeBadge as p } from "./index3.js";
7
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
8
- import { ArrowDownIcon as g, ArrowUpDownIcon as _, ArrowUpIcon as v, Plus as y, Search as b } from "lucide-react";
7
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
8
+ import { ArrowDownIcon as _, ArrowUpDownIcon as v, ArrowUpIcon as y, Plus as b, Search as x } from "lucide-react";
9
9
  //#region ../../libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js
10
- var x = [
10
+ var S = [
11
11
  10,
12
12
  25,
13
13
  50,
14
14
  100
15
- ], S = "all";
16
- function C({ labels: e, searchValue: t, onSearchChange: u, typeFilter: d, onTypeFilterChange: f, unitFilter: p, onUnitFilterChange: g, unitOptions: _ }) {
17
- return /* @__PURE__ */ h("div", {
15
+ ], C = "all";
16
+ function w({ labels: e, searchValue: t, onSearchChange: u, typeFilter: d, onTypeFilterChange: f, unitFilter: p, onUnitFilterChange: m, unitOptions: _, headerActions: v }) {
17
+ return /* @__PURE__ */ g("div", {
18
18
  className: "ttw:flex ttw:flex-wrap ttw:items-center ttw:gap-2 ttw:px-4",
19
19
  children: [
20
- /* @__PURE__ */ h(n, {
20
+ /* @__PURE__ */ g(n, {
21
21
  className: "ttw:w-80",
22
- children: [/* @__PURE__ */ m(r, {
22
+ children: [/* @__PURE__ */ h(r, {
23
23
  align: "inline-start",
24
- children: /* @__PURE__ */ m(b, { className: "ttw:size-4" })
25
- }), /* @__PURE__ */ m(i, {
24
+ children: /* @__PURE__ */ h(x, { className: "ttw:size-4" })
25
+ }), /* @__PURE__ */ h(i, {
26
26
  "data-has-start-addon": !0,
27
27
  placeholder: e.searchPlaceholder,
28
28
  value: t,
29
29
  onChange: (e) => u(e.target.value)
30
30
  })]
31
31
  }),
32
- /* @__PURE__ */ h(a, {
32
+ /* @__PURE__ */ g(a, {
33
33
  value: d,
34
34
  onValueChange: f,
35
- children: [/* @__PURE__ */ m(c, {
35
+ children: [/* @__PURE__ */ h(c, {
36
36
  className: "ttw:w-44",
37
- children: /* @__PURE__ */ m(l, {})
38
- }), /* @__PURE__ */ h(o, { children: [
39
- /* @__PURE__ */ m(s, {
40
- value: S,
37
+ children: /* @__PURE__ */ h(l, {})
38
+ }), /* @__PURE__ */ g(o, { children: [
39
+ /* @__PURE__ */ h(s, {
40
+ value: C,
41
41
  children: e.typeFilterAll
42
42
  }),
43
- /* @__PURE__ */ m(s, {
43
+ /* @__PURE__ */ h(s, {
44
44
  value: "product",
45
45
  children: e.typeFilterProduct
46
46
  }),
47
- /* @__PURE__ */ m(s, {
47
+ /* @__PURE__ */ h(s, {
48
48
  value: "service",
49
49
  children: e.typeFilterService
50
50
  })
51
51
  ] })]
52
52
  }),
53
- /* @__PURE__ */ h(a, {
54
- value: p,
55
- onValueChange: g,
56
- children: [/* @__PURE__ */ m(c, {
57
- className: "ttw:w-44",
58
- children: /* @__PURE__ */ m(l, {})
59
- }), /* @__PURE__ */ h(o, { children: [/* @__PURE__ */ m(s, {
60
- value: S,
61
- children: e.unitFilterAll
62
- }), _.map((e) => /* @__PURE__ */ m(s, {
63
- value: e.value,
64
- children: e.label
65
- }, e.value))] })]
53
+ /* @__PURE__ */ g("div", {
54
+ className: "ttw:ml-auto ttw:flex ttw:items-center ttw:gap-2",
55
+ children: [/* @__PURE__ */ g(a, {
56
+ value: p,
57
+ onValueChange: m,
58
+ children: [/* @__PURE__ */ h(c, {
59
+ className: "ttw:w-44",
60
+ children: /* @__PURE__ */ h(l, {})
61
+ }), /* @__PURE__ */ g(o, { children: [/* @__PURE__ */ h(s, {
62
+ value: C,
63
+ children: e.unitFilterAll
64
+ }), _.map((e) => /* @__PURE__ */ h(s, {
65
+ value: e.value,
66
+ children: e.label
67
+ }, e.value))] })]
68
+ }), v]
66
69
  })
67
70
  ]
68
71
  });
69
72
  }
70
- function w({ products: n, isLoading: r, isError: i, sorting: a, onSortingChange: o, pageSize: s, onPageSizeChange: c, pageSizeOptions: l = x, hasNextPage: b, hasPrevPage: S, onNextPage: w, onPrevPage: T, searchValue: E, onSearchChange: D, typeFilter: O, onTypeFilterChange: k, unitFilter: A, onUnitFilterChange: j, unitOptions: M, isFiltering: N, onCreateClick: P, onManageUnitsClick: F, onRowClick: I, onRetry: L, labels: R, emptyStateTestId: z }) {
71
- let B = {
73
+ function T({ products: n, isLoading: r, isError: i, sorting: a, onSortingChange: o, pageSize: s, onPageSizeChange: c, pageSizeOptions: l = S, hasNextPage: x, hasPrevPage: C, onNextPage: T, onPrevPage: E, searchValue: D, onSearchChange: O, typeFilter: k, onTypeFilterChange: A, unitFilter: j, onUnitFilterChange: M, unitOptions: N, isFiltering: P, onCreateClick: F, onManageUnitsClick: I, onRowClick: L, onRetry: R, canCreate: z = !0, canManageUnits: B = !0, isAccessRestricted: V, labels: H, testIds: U }) {
74
+ let W = {
72
75
  ...f,
73
- ...R
74
- }, V = [
76
+ ...H
77
+ }, G = [
75
78
  {
76
79
  accessorKey: "name",
77
80
  enableSorting: !0,
78
81
  header: ({ column: t }) => {
79
82
  let n = t.getIsSorted();
80
- return /* @__PURE__ */ h("div", {
83
+ return /* @__PURE__ */ g("div", {
81
84
  className: "ttw:flex ttw:items-center ttw:gap-2 ttw:text-inherit",
82
- children: [B.columnName, /* @__PURE__ */ m(e, {
85
+ children: [W.columnName, /* @__PURE__ */ h(e, {
83
86
  variant: "ghost",
84
87
  size: "icon-sm",
85
88
  onClick: () => t.toggleSorting(n === "asc"),
86
- children: m(n === "asc" ? v : n === "desc" ? g : _, { className: "ttw:size-4" })
89
+ children: h(n === "asc" ? y : n === "desc" ? _ : v, { className: "ttw:size-4" })
87
90
  })]
88
91
  });
89
92
  }
90
93
  },
91
94
  {
92
95
  accessorKey: "type",
93
- header: B.columnType,
94
- cell: ({ row: e }) => e.original.type ? /* @__PURE__ */ m(p, {
96
+ header: W.columnType,
97
+ cell: ({ row: e }) => e.original.type ? /* @__PURE__ */ h(p, {
95
98
  type: e.original.type,
96
- labels: B.typeBadge
99
+ labels: W.typeBadge
97
100
  }) : null
98
101
  },
99
102
  {
100
103
  accessorKey: "description",
101
- header: B.columnDescription,
102
- cell: ({ row: e }) => /* @__PURE__ */ m("div", {
104
+ header: W.columnDescription,
105
+ cell: ({ row: e }) => /* @__PURE__ */ h("div", {
103
106
  className: "ttw:w-120",
104
- children: /* @__PURE__ */ m("span", {
107
+ children: /* @__PURE__ */ h("span", {
105
108
  className: "ttw:w-full ttw:inline-block ttw:truncate",
106
109
  children: e.original.description
107
110
  })
@@ -109,42 +112,42 @@ function w({ products: n, isLoading: r, isError: i, sorting: a, onSortingChange:
109
112
  },
110
113
  {
111
114
  accessorKey: "priceLabel",
112
- header: () => /* @__PURE__ */ m("div", {
115
+ header: () => /* @__PURE__ */ h("div", {
113
116
  className: "ttw:text-right",
114
- children: B.columnPrice
117
+ children: W.columnPrice
115
118
  }),
116
- cell: ({ row: e }) => /* @__PURE__ */ h("div", {
119
+ cell: ({ row: e }) => /* @__PURE__ */ g("div", {
117
120
  className: "ttw:flex ttw:justify-end ttw:items-center ttw:gap-1",
118
- children: [/* @__PURE__ */ m("span", { children: e.original.priceLabel }), e.original.unitLabel && /* @__PURE__ */ m("span", {
121
+ children: [/* @__PURE__ */ h("span", { children: e.original.priceLabel }), e.original.unitLabel && /* @__PURE__ */ h("span", {
119
122
  className: "ttw:text-muted-foreground ttw:text-xs",
120
123
  children: e.original.unitLabel
121
124
  })]
122
125
  })
123
126
  }
124
- ];
127
+ ], K = /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(e, {
128
+ variant: "ghost",
129
+ className: "ttw:text-primary ttw:hover:text-primary",
130
+ onClick: I,
131
+ disabled: !B,
132
+ children: W.manageUnitsButton
133
+ }), /* @__PURE__ */ g(e, {
134
+ onClick: F,
135
+ disabled: !z,
136
+ children: [/* @__PURE__ */ h(b, { className: "ttw:size-4" }), W.createButton]
137
+ })] });
125
138
  return /* @__PURE__ */ h("div", {
126
139
  className: "ttw:flex ttw:flex-col ttw:gap-4",
127
- children: [/* @__PURE__ */ m("div", {
128
- className: "ttw:flex ttw:items-center ttw:justify-end",
129
- children: /* @__PURE__ */ h("div", {
130
- className: "ttw:flex ttw:gap-2",
131
- children: [/* @__PURE__ */ m(e, {
132
- variant: "ghost",
133
- className: "ttw:text-primary ttw:hover:text-primary",
134
- onClick: F,
135
- children: B.manageUnitsButton
136
- }), /* @__PURE__ */ h(e, {
137
- onClick: P,
138
- children: [/* @__PURE__ */ m(y, { className: "ttw:size-4" }), B.createButton]
139
- })]
140
- })
141
- }), i ? /* @__PURE__ */ m(d, {
142
- title: B.errorTitle,
143
- description: B.errorDescription,
144
- retryLabel: L ? B.errorRetry : void 0,
145
- onRetry: L
146
- }) : /* @__PURE__ */ m(t, {
147
- columns: V,
140
+ children: V ? /* @__PURE__ */ h(d, {
141
+ testId: U?.accessRestricted,
142
+ title: W.accessRestrictedTitle,
143
+ description: W.accessRestrictedDescription
144
+ }) : i ? /* @__PURE__ */ h(d, {
145
+ title: W.errorTitle,
146
+ description: W.errorDescription,
147
+ retryLabel: R ? W.errorRetry : void 0,
148
+ onRetry: R
149
+ }) : /* @__PURE__ */ h(t, {
150
+ columns: G,
148
151
  data: n,
149
152
  isLoading: r,
150
153
  sorting: a,
@@ -152,31 +155,32 @@ function w({ products: n, isLoading: r, isError: i, sorting: a, onSortingChange:
152
155
  pageSize: s,
153
156
  onPageSizeChange: c,
154
157
  pageSizeOptions: l,
155
- hasNextPage: b,
156
- hasPrevPage: S,
157
- onNextPage: w,
158
- onPrevPage: T,
159
- onRowClick: I,
160
- rowAriaLabel: (e) => B.openRow(e.name),
161
- filterComponent: /* @__PURE__ */ m(C, {
162
- labels: B,
163
- searchValue: E,
164
- onSearchChange: D,
165
- typeFilter: O,
166
- onTypeFilterChange: k,
167
- unitFilter: A,
168
- onUnitFilterChange: j,
169
- unitOptions: M
158
+ hasNextPage: x,
159
+ hasPrevPage: C,
160
+ onNextPage: T,
161
+ onPrevPage: E,
162
+ onRowClick: L,
163
+ rowAriaLabel: (e) => W.openRow(e.name),
164
+ filterComponent: /* @__PURE__ */ h(w, {
165
+ labels: W,
166
+ searchValue: D,
167
+ onSearchChange: O,
168
+ typeFilter: k,
169
+ onTypeFilterChange: A,
170
+ unitFilter: j,
171
+ onUnitFilterChange: M,
172
+ unitOptions: N,
173
+ headerActions: K
170
174
  }),
171
- children: /* @__PURE__ */ m(u, {
172
- testId: z,
173
- title: N ? B.filterEmptyTitle : B.emptyTitle,
174
- description: N ? B.filterEmptyDescription : B.emptyDescription,
175
- actionLabel: N ? void 0 : B.emptyAction,
176
- onAction: N ? void 0 : P
175
+ children: /* @__PURE__ */ h(u, {
176
+ testId: U?.empty,
177
+ title: P ? W.filterEmptyTitle : W.emptyTitle,
178
+ description: P ? W.filterEmptyDescription : W.emptyDescription,
179
+ actionLabel: P || !z ? void 0 : W.emptyAction,
180
+ onAction: P || !z ? void 0 : F
177
181
  })
178
- })]
182
+ })
179
183
  });
180
184
  }
181
185
  //#endregion
182
- export { w as ProductsScreen, w as default };
186
+ export { T as ProductsScreen, T as default };