@tesouro/embedded-components-react 0.7.72 → 0.7.74

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 (33) hide show
  1. package/README.md +1 -1
  2. package/dist/index.css +9 -0
  3. package/dist/index.d.ts +12 -6
  4. package/dist/lib/ProductsWidget.d.ts +12 -6
  5. package/dist/lib/ReceivablesWidget.d.ts +1 -5
  6. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +23 -24
  7. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/constants.js +6 -2
  8. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsTable.js +112 -51
  9. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsWidget.js +80 -56
  10. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index.js +6 -5
  11. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index2.js +15 -6
  12. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js +170 -135
  13. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js +49 -150
  14. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index6.js +152 -24
  15. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index7.js +28 -0
  16. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/labels.js +1 -2
  17. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/policyViewModel.js +8 -9
  18. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApprovalPolicyRules.js +127 -141
  19. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/util/dist/lib/validatePolicyDraft.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +13 -12
  22. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +2 -2
  23. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/ProductSelector.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js +41 -27
  25. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +70 -52
  26. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index.js +7 -6
  27. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +19 -8
  28. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +171 -218
  29. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +52 -180
  30. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js +188 -46
  31. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +47 -124
  32. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js +128 -0
  33. package/package.json +1 -1
package/README.md CHANGED
@@ -572,7 +572,7 @@ Manages an organization's products and services: a filterable, sortable table wi
572
572
  | ------------------------- | ---------------------------------------- | ------------------- | ------------------------------------------------------------ |
573
573
  | `pageSizeOptions` | `number[]` | `[10, 25, 50, 100]` | Rows-per-page choices. |
574
574
  | `screenLabels` | `PartialDeep<ProductsScreenLabels>` | English labels | Table/header/filter/empty/error copy. |
575
- | `formLabels` | `PartialDeep<ProductFormSheetLabels>` | English labels | Create/edit form copy. |
575
+ | `formLabels` | `PartialDeep<ProductFormSheetLabels>` | English labels | Create sheet and inline edit form copy. |
576
576
  | `detailsLabels` | `PartialDeep<ProductDetailsSheetLabels>` | English labels | Details sheet copy. |
577
577
  | `deleteLabels` | `Partial<ProductDeleteDialogLabels>` | English labels | Product delete confirmation copy. |
578
578
  | `measureUnitsLabels` | `Partial<MeasureUnitsManagerLabels>` | English labels | Measure-units manager copy. |
package/dist/index.css CHANGED
@@ -1197,6 +1197,9 @@
1197
1197
  .ttw\:w-72 {
1198
1198
  width: calc(var(--ttw-spacing) * 72);
1199
1199
  }
1200
+ .ttw\:w-74 {
1201
+ width: calc(var(--ttw-spacing) * 74);
1202
+ }
1200
1203
  .ttw\:w-80 {
1201
1204
  width: calc(var(--ttw-spacing) * 80);
1202
1205
  }
@@ -1557,6 +1560,9 @@
1557
1560
  .ttw\:min-w-35 {
1558
1561
  min-width: calc(var(--ttw-spacing) * 35);
1559
1562
  }
1563
+ .ttw\:min-w-40 {
1564
+ min-width: calc(var(--ttw-spacing) * 40);
1565
+ }
1560
1566
  .ttw\:min-w-44 {
1561
1567
  min-width: calc(var(--ttw-spacing) * 44);
1562
1568
  }
@@ -2593,6 +2599,9 @@
2593
2599
  .ttw\:bg-background {
2594
2600
  background-color: var(--ttw-background);
2595
2601
  }
2602
+ .ttw\:bg-background\! {
2603
+ background-color: var(--ttw-background) !important;
2604
+ }
2596
2605
  .ttw\:bg-background\/80 {
2597
2606
  background-color: var(--ttw-background);
2598
2607
  @supports (color: color-mix(in lab, red, red)) {
package/dist/index.d.ts CHANGED
@@ -5035,9 +5035,7 @@ interface ProductFormSheetLabels {
5035
5035
  createTitle: string;
5036
5036
  /** Shown in the sheet description for the create form. */
5037
5037
  headerDescription: string;
5038
- /** `{type}` is replaced with the product/service word. */
5039
- editTitle: string;
5040
- /** `{type}` is replaced with the product/service word. */
5038
+ /** Heading of the inline edit form. `{type}` is replaced with the product/service word. */
5041
5039
  editingBanner: string;
5042
5040
  nameLabel: string;
5043
5041
  namePlaceholder: string;
@@ -5055,8 +5053,6 @@ interface ProductFormSheetLabels {
5055
5053
  unitEmpty: string;
5056
5054
  unitClearAriaLabel: string;
5057
5055
  priceLabel: string;
5058
- /** Shown before the price input; products are priced in USD only. */
5059
- pricePrefix: string;
5060
5056
  pricePlaceholder: string;
5061
5057
  cancelButton: string;
5062
5058
  /** `{type}` is replaced with the product/service word. */
@@ -5151,9 +5147,19 @@ interface ProductsScreenLabels {
5151
5147
  columnUnit: string;
5152
5148
  columnPrice: string;
5153
5149
  searchPlaceholder: string;
5154
- typeFilterAll: string;
5150
+ searchLabel: string;
5151
+ filtersButton: string;
5152
+ filterFieldType: string;
5153
+ filterFieldUnit: string;
5154
+ /** Accessible name of a chip's dismiss button. `{label}` is the chip's text. */
5155
+ filterChipRemove: string;
5156
+ typeChip: (value: string) => string;
5157
+ unitChip: (value: string) => string;
5158
+ searchChip: (value: string) => string;
5159
+ clearAllFilters: string;
5155
5160
  typeFilterProduct: string;
5156
5161
  typeFilterService: string;
5162
+ /** First choice in the unit panel; choosing it removes the unit filter. */
5157
5163
  unitFilterAll: string;
5158
5164
  emptyTitle: string;
5159
5165
  emptyDescription: string;
@@ -631,9 +631,7 @@ interface ProductFormSheetLabels {
631
631
  createTitle: string;
632
632
  /** Shown in the sheet description for the create form. */
633
633
  headerDescription: string;
634
- /** `{type}` is replaced with the product/service word. */
635
- editTitle: string;
636
- /** `{type}` is replaced with the product/service word. */
634
+ /** Heading of the inline edit form. `{type}` is replaced with the product/service word. */
637
635
  editingBanner: string;
638
636
  nameLabel: string;
639
637
  namePlaceholder: string;
@@ -651,8 +649,6 @@ interface ProductFormSheetLabels {
651
649
  unitEmpty: string;
652
650
  unitClearAriaLabel: string;
653
651
  priceLabel: string;
654
- /** Shown before the price input; products are priced in USD only. */
655
- pricePrefix: string;
656
652
  pricePlaceholder: string;
657
653
  cancelButton: string;
658
654
  /** `{type}` is replaced with the product/service word. */
@@ -747,9 +743,19 @@ interface ProductsScreenLabels {
747
743
  columnUnit: string;
748
744
  columnPrice: string;
749
745
  searchPlaceholder: string;
750
- typeFilterAll: string;
746
+ searchLabel: string;
747
+ filtersButton: string;
748
+ filterFieldType: string;
749
+ filterFieldUnit: string;
750
+ /** Accessible name of a chip's dismiss button. `{label}` is the chip's text. */
751
+ filterChipRemove: string;
752
+ typeChip: (value: string) => string;
753
+ unitChip: (value: string) => string;
754
+ searchChip: (value: string) => string;
755
+ clearAllFilters: string;
751
756
  typeFilterProduct: string;
752
757
  typeFilterService: string;
758
+ /** First choice in the unit panel; choosing it removes the unit filter. */
753
759
  unitFilterAll: string;
754
760
  emptyTitle: string;
755
761
  emptyDescription: string;
@@ -853,9 +853,7 @@ interface ProductFormSheetLabels {
853
853
  createTitle: string;
854
854
  /** Shown in the sheet description for the create form. */
855
855
  headerDescription: string;
856
- /** `{type}` is replaced with the product/service word. */
857
- editTitle: string;
858
- /** `{type}` is replaced with the product/service word. */
856
+ /** Heading of the inline edit form. `{type}` is replaced with the product/service word. */
859
857
  editingBanner: string;
860
858
  nameLabel: string;
861
859
  namePlaceholder: string;
@@ -873,8 +871,6 @@ interface ProductFormSheetLabels {
873
871
  unitEmpty: string;
874
872
  unitClearAriaLabel: string;
875
873
  priceLabel: string;
876
- /** Shown before the price input; products are priced in USD only. */
877
- pricePrefix: string;
878
874
  pricePlaceholder: string;
879
875
  cancelButton: string;
880
876
  /** `{type}` is replaced with the product/service word. */
@@ -7,17 +7,17 @@ import "../../../../../shared/ui/dist/index.js";
7
7
  import { useAnalyticsTrack as t } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
8
8
  import { WidgetProvider as n } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
9
9
  import "../../../../../shared/feature/dist/index.js";
10
- import { ProductFormSheet as r } from "../../../../../shared/product-catalog/ui/dist/index3.js";
10
+ import { ProductFormSheet as r } from "../../../../../shared/product-catalog/ui/dist/index4.js";
11
11
  import { MeasureUnitsManagerContainer as i } from "../../../../../shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js";
12
12
  import "../../../../../shared/product-catalog/feature/dist/index.js";
13
13
  import { ProductsWidgetAnalyticsEvent as a, WIDGET_NAME as o } from "../analytics/events.js";
14
14
  import { PAGE_SIZE_OPTIONS as s } from "./constants.js";
15
15
  import { productsWidgetTestIds as c } from "./testIds.js";
16
- import { useProductsWidget as l } from "./useProductsWidget.js";
17
- import { ProductsScreen as u } from "../../../../ui/dist/index4.js";
18
- import { ProductDetailsSheet as d } from "../../../../ui/dist/index5.js";
19
- import { ProductDeleteDialog as f } from "../../../../ui/dist/index6.js";
16
+ import { ProductsScreen as l } from "../../../../ui/dist/index4.js";
17
+ import { ProductDetailsSheet as u } from "../../../../ui/dist/index6.js";
18
+ import { ProductDeleteDialog as d } from "../../../../ui/dist/index7.js";
20
19
  import "../../../../ui/dist/index.js";
20
+ import { useProductsWidget as f } from "./useProductsWidget.js";
21
21
  import { useEffect as p } from "react";
22
22
  import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
23
23
  //#region ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js
@@ -26,10 +26,14 @@ function _({ pageSizeOptions: n = s, screenLabels: o, formLabels: _, detailsLabe
26
26
  p(() => {
27
27
  C(a.Mounted);
28
28
  }, [C]);
29
- let { view: w, units: T, table: E, details: D, form: O, del: k, permissions: A, isPermissionLoading: j, isTableLoading: M, hasInitError: N, refetchWidgetInit: P, measureUnitsOpen: F, actionsSuspended: I, handleRowClick: L, openMeasureUnits: R, closeMeasureUnits: z, submitForm: B, confirmDelete: V } = l({ messageLabels: S });
29
+ let { view: w, units: T, table: E, details: D, form: O, del: k, permissions: A, isPermissionLoading: j, isTableLoading: M, hasInitError: N, refetchWidgetInit: P, measureUnitsOpen: F, actionsSuspended: I, editForm: L, handleRowClick: R, openMeasureUnits: z, closeMeasureUnits: B, submitForm: V, confirmDelete: H } = f({
30
+ messageLabels: S,
31
+ screenLabels: o,
32
+ formLabels: _
33
+ });
30
34
  return /* @__PURE__ */ g(m, { children: [
31
35
  /* @__PURE__ */ h(e, {}),
32
- /* @__PURE__ */ h(u, {
36
+ /* @__PURE__ */ h(l, {
33
37
  products: E.rows,
34
38
  isLoading: M,
35
39
  isError: N || E.isError,
@@ -42,20 +46,14 @@ function _({ pageSizeOptions: n = s, screenLabels: o, formLabels: _, detailsLabe
42
46
  hasPrevPage: E.hasPrevPage,
43
47
  onNextPage: E.onNextPage,
44
48
  onPrevPage: E.onPrevPage,
45
- searchValue: E.searchValue,
46
- onSearchChange: E.onSearchChange,
47
- typeFilter: E.typeFilter,
48
- onTypeFilterChange: E.onTypeFilterChange,
49
- unitFilter: E.unitFilter,
50
- onUnitFilterChange: E.onUnitFilterChange,
51
- unitOptions: T.unitOptions,
49
+ filters: E.filters,
52
50
  isFiltering: E.isFiltering,
53
51
  canCreate: A.canCreate,
54
52
  canManageUnits: A.canCreate,
55
53
  isAccessRestricted: !j && !N && !A.canRead,
56
54
  onCreateClick: O.openCreate,
57
- onManageUnitsClick: R,
58
- onRowClick: L,
55
+ onManageUnitsClick: z,
56
+ onRowClick: R,
59
57
  onRetry: N ? P : E.onRetry,
60
58
  labels: o,
61
59
  testIds: {
@@ -64,25 +62,25 @@ function _({ pageSizeOptions: n = s, screenLabels: o, formLabels: _, detailsLabe
64
62
  }
65
63
  }),
66
64
  /* @__PURE__ */ h(r, {
67
- open: w === "create" || w === "edit",
65
+ open: w === "create",
68
66
  onOpenChange: (e) => {
69
67
  e || O.close();
70
68
  },
71
- mode: w === "edit" ? "edit" : "create",
72
69
  values: O.values,
73
70
  errors: O.errors,
74
71
  unitOptions: T.unitOptions,
72
+ pricePrefix: O.pricePrefix,
75
73
  inProgress: O.isSubmitting || I,
76
74
  onChange: (e) => O.setValues((t) => ({
77
75
  ...t,
78
76
  ...e
79
77
  })),
80
- onSubmit: B,
78
+ onSubmit: V,
81
79
  onCancel: O.close,
82
80
  labels: _
83
81
  }),
84
- /* @__PURE__ */ h(d, {
85
- open: w === "details",
82
+ /* @__PURE__ */ h(u, {
83
+ open: w === "details" || w === "edit",
86
84
  onOpenChange: (e) => {
87
85
  e || O.close();
88
86
  },
@@ -93,20 +91,21 @@ function _({ pageSizeOptions: n = s, screenLabels: o, formLabels: _, detailsLabe
93
91
  onDelete: k.requestDelete,
94
92
  canEdit: A.canUpdate,
95
93
  canDelete: A.canDelete,
94
+ editForm: L,
96
95
  labels: v
97
96
  }),
98
- /* @__PURE__ */ h(f, {
97
+ /* @__PURE__ */ h(d, {
99
98
  open: k.open,
100
99
  onOpenChange: k.onOpenChange,
101
100
  productName: D.productName,
102
101
  isDeleting: k.isDeleting || I,
103
- onConfirm: V,
102
+ onConfirm: H,
104
103
  onCancel: k.cancel,
105
104
  labels: y
106
105
  }),
107
106
  /* @__PURE__ */ h(i, {
108
107
  open: F,
109
- onClose: z,
108
+ onClose: B,
110
109
  suspended: I,
111
110
  managerLabels: b,
112
111
  deleteLabels: x,
@@ -4,6 +4,10 @@ var e = [
4
4
  25,
5
5
  50,
6
6
  100
7
- ];
7
+ ], t = ["product", "service"], n = {
8
+ Type: "type",
9
+ Unit: "unit",
10
+ Search: "search"
11
+ };
8
12
  //#endregion
9
- export { e as PAGE_SIZE_OPTIONS };
13
+ export { e as PAGE_SIZE_OPTIONS, n as ProductsFilterKey, t as TYPE_FILTER_OPTIONS };
@@ -2,64 +2,125 @@
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 { useFilterPanel as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { buildProductRows as t } from "../../../../../shared/product-catalog/feature/dist/lib/helpers.js";
7
+ import { useProductsQuery as n } from "../../../../../shared/product-catalog/data-access/dist/index2.js";
7
8
  import "../../../../../shared/product-catalog/feature/dist/index.js";
8
- import { useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
9
+ import { ProductsFilterKey as r, TYPE_FILTER_OPTIONS as i } from "./constants.js";
10
+ import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
9
11
  //#region ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsTable.js
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(() => {
12
+ function l({ unitNamesById: l, unitOptions: u, labels: d, enabled: f = !0 }) {
13
+ let [p, m] = c([]), [h, g] = c(10), [_, v] = c(), [y, b] = c(""), [x, S] = c(""), [C, w] = c([]), [T, E] = c("all"), D = e(), O = C.length === 1 ? C[0] : void 0;
14
+ T !== "all" && !l[T] && (E("all"), v(void 0));
15
+ let k = T === "all" ? void 0 : T;
16
+ o(() => {
17
+ if (y === x) return;
13
18
  let e = setTimeout(() => {
14
- _(m), p(void 0);
19
+ S(y), v(void 0);
15
20
  }, 400);
16
21
  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
+ }, [y, x]);
23
+ let A = p[0]?.id === "name" ? "name" : void 0, j = p[0] ? p[0].desc ? "desc" : "asc" : void 0, M = n({
24
+ ...A ? {
25
+ sort: A,
26
+ order: j
22
27
  } : {},
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
- }, []);
28
+ limit: h,
29
+ pagination_token: _,
30
+ name__icontains: x || void 0,
31
+ type: O,
32
+ measure_unit_id: k,
33
+ enabled: f
34
+ }), N = s(() => t({
35
+ products: M.data?.data ?? [],
36
+ unitNamesById: l
37
+ }), [M.data, l]), P = s(() => i.map((e) => ({
38
+ value: e,
39
+ label: e === "product" ? d.typeFilterProduct : d.typeFilterService
40
+ })), [d.typeFilterProduct, d.typeFilterService]), F = s(() => [{
41
+ value: "all",
42
+ label: d.unitFilterAll
43
+ }, ...u], [d.unitFilterAll, u]), I = s(() => {
44
+ let e = [], t = P.find((e) => e.value === O)?.label;
45
+ return t && e.push({
46
+ key: r.Type,
47
+ label: d.typeChip(t)
48
+ }), k && e.push({
49
+ key: r.Unit,
50
+ label: d.unitChip(l[k])
51
+ }), x && e.push({
52
+ key: r.Search,
53
+ label: d.searchChip(x)
54
+ }), e;
55
+ }, [
56
+ x,
57
+ O,
58
+ k,
59
+ d,
60
+ P,
61
+ l
62
+ ]), L = I.length > 0, R = a((e) => {
63
+ let t = typeof e == "function" ? e(p) : e;
64
+ m(t), v(void 0);
65
+ }, [p]), z = a((e) => {
66
+ g(e), v(void 0);
67
+ }, []), B = a(() => v(M.data?.next_pagination_token ?? void 0), [M.data?.next_pagination_token]), V = a(() => v(M.data?.prev_pagination_token ?? void 0), [M.data?.prev_pagination_token]), H = a(() => {
68
+ M.refetch();
69
+ }, [M]), U = a((e) => {
70
+ w(e), v(void 0);
71
+ }, []), W = a((e) => {
72
+ E(e), v(void 0);
73
+ }, []), G = a(() => {
74
+ b(""), S(""), v(void 0);
75
+ }, []), K = a((e) => {
76
+ e === r.Search ? G() : e === r.Unit ? W("all") : U([]);
77
+ }, [
78
+ G,
79
+ U,
80
+ W
81
+ ]), q = a(() => {
82
+ G(), w([]), E("all");
83
+ }, [G]), J = {
84
+ searchValue: y,
85
+ onSearchChange: b,
86
+ isPopoverOpen: D.isMenuOpen || !!D.activePanelId,
87
+ isMenuOpen: D.isMenuOpen,
88
+ isPanelOpen: !!D.activePanelId,
89
+ isTypePanelOpen: D.activePanelId === r.Type,
90
+ isUnitPanelOpen: D.activePanelId === r.Unit,
91
+ onMenuToggle: D.toggleMenu,
92
+ onPopoverClose: () => {
93
+ D.closeMenu(), D.closePanel();
94
+ },
95
+ onTypeFieldSelect: () => D.openPanel(r.Type),
96
+ onUnitFieldSelect: () => D.openPanel(r.Unit),
97
+ activeFilterCount: I.length,
98
+ chips: I,
99
+ onRemoveChip: K,
100
+ onClearAll: q,
101
+ typeOptions: P,
102
+ selectedTypes: C,
103
+ onTypeChange: U,
104
+ unitOptions: F,
105
+ selectedUnit: k ?? "all",
106
+ onUnitChange: W
107
+ };
42
108
  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
109
+ rows: N,
110
+ isLoading: M.isLoading,
111
+ isError: M.isError,
112
+ sorting: p,
113
+ onSortingChange: R,
114
+ pageSize: h,
115
+ onPageSizeChange: z,
116
+ hasNextPage: !!M.data?.next_pagination_token,
117
+ hasPrevPage: !!M.data?.prev_pagination_token,
118
+ onNextPage: B,
119
+ onPrevPage: V,
120
+ filters: J,
121
+ isFiltering: L,
122
+ onRetry: H
62
123
  };
63
124
  }
64
125
  //#endregion
65
- export { o as useProductsTable };
126
+ export { l as useProductsTable };
@@ -6,68 +6,92 @@ import { useRefetchWidget as e, useWidgetConfig as t, useWidgetError as n, useWi
6
6
  import "../../../../../shared/feature/dist/index.js";
7
7
  import { PRODUCT_MESSAGE_LABELS_EN as a } from "../../../../../shared/product-catalog/feature/dist/lib/labels.js";
8
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";
9
+ import { PRODUCT_FORM_SHEET_LABELS_EN as s } from "../../../../../shared/product-catalog/ui/dist/index2.js";
10
+ import { useMeasureUnits as c } from "../../../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
11
+ import { useProductForm as l } from "../../../../../shared/product-catalog/feature/dist/lib/useProductForm.js";
11
12
  import "../../../../../shared/product-catalog/feature/dist/index.js";
12
- import { getProductPermissions as l } from "./permissions.js";
13
- import { useProductDelete as u } from "./useProductDelete.js";
14
- import { useProductDetails as d } from "./useProductDetails.js";
15
- import { useProductsTable as f } from "./useProductsTable.js";
16
- import { useCallback as p, useMemo as m, useState as h } from "react";
13
+ import { getProductPermissions as u } from "./permissions.js";
14
+ import { useProductDelete as d } from "./useProductDelete.js";
15
+ import { useProductDetails as f } from "./useProductDetails.js";
16
+ import { useProductsTable as p } from "./useProductsTable.js";
17
+ import { PRODUCTS_SCREEN_LABELS_EN as m } from "../../../../ui/dist/index2.js";
18
+ import "../../../../ui/dist/index.js";
19
+ import { useCallback as h, useMemo as g, useState as _ } from "react";
17
20
  //#region ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsWidget.js
18
- function g({ messageLabels: g }) {
19
- let _ = m(() => ({
21
+ function v({ messageLabels: v, screenLabels: y, formLabels: b }) {
22
+ let x = g(() => ({
20
23
  ...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
- messages: _
24
+ ...v
25
+ }), [v]), S = g(() => ({
26
+ ...m,
27
+ ...y
28
+ }), [y]), { initResponse: C, widgetToken: w } = t(), T = i(), E = n(), D = r(), O = e(), k = g(() => u(D ? void 0 : C?.scopes), [D, C?.scopes]), A = !(!w || C || E) || T && !C || D, j = !!E && (!C || D), [M, N] = _("none"), [P, F] = _(), [I, L] = _(!1), R = c({ enabled: k.canRead }), z = p({
29
+ unitNamesById: R.unitNamesById,
30
+ unitOptions: R.unitOptions,
31
+ labels: S,
32
+ enabled: k.canRead
33
+ }), B = f({
34
+ selectedProductId: P,
35
+ unitNamesById: R.unitNamesById,
36
+ enabled: k.canRead
37
+ }), V = l({
38
+ view: M,
39
+ setView: N,
40
+ selectedProductId: P,
41
+ setSelectedProductId: F,
42
+ product: B.product,
43
+ messages: x
44
+ }), H = d({
45
+ selectedProductId: P,
46
+ setSelectedProductId: F,
47
+ setView: N,
48
+ messages: x
41
49
  });
42
- if (!S) {
43
- let { canRead: e, canCreate: t, canUpdate: n, canDelete: r } = w;
44
- (!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);
50
+ if (!D) {
51
+ let { canRead: e, canCreate: t, canUpdate: n, canDelete: r } = k;
52
+ !e && (M !== "none" || P) || M === "create" && !t ? (N("none"), F(void 0)) : M === "edit" && !n && N("details"), H.open && !(e && r) && H.cancel(), I && !(e && t) && L(!1);
45
53
  }
46
- let R = p((e) => {
47
- w.canRead && !o() && (A(e.id), O("details"));
48
- }, [w.canRead]), z = p(() => {
49
- w.canCreate && M(!0);
50
- }, [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]);
54
+ let U = h((e) => {
55
+ k.canRead && !o() && (F(e.id), N("details"));
56
+ }, [k.canRead]), W = h(() => {
57
+ k.canCreate && L(!0);
58
+ }, [k.canCreate]), G = h(() => L(!1), []), { submit: K } = V, q = h(() => D ? void 0 : K(), [D, K]), J = (B.product?.type === "service" ? b?.typeService ?? s.typeService : b?.typeProduct ?? s.typeProduct).toLowerCase(), Y = M === "edit" ? {
59
+ heading: (b?.editingBanner ?? s.editingBanner).replace("{type}", J),
60
+ values: V.values,
61
+ errors: V.errors,
62
+ unitOptions: R.unitOptions,
63
+ pricePrefix: V.pricePrefix,
64
+ inProgress: V.isSubmitting || D,
65
+ submitDisabled: !V.isDirty,
66
+ onChange: (e) => V.setValues((t) => ({
67
+ ...t,
68
+ ...e
69
+ })),
70
+ onSubmit: q,
71
+ onCancel: V.cancelEdit,
72
+ labels: b
73
+ } : void 0, { confirm: X } = H, Z = h(() => D ? void 0 : X(), [D, X]);
51
74
  return {
52
- view: D,
53
- units: N,
54
- table: P,
55
- details: F,
56
- form: I,
57
- del: L,
58
- permissions: w,
59
- isPermissionLoading: T,
60
- isTableLoading: P.isLoading || T && P.rows.length === 0,
61
- hasInitError: E,
62
- refetchWidgetInit: C,
63
- measureUnitsOpen: j,
64
- actionsSuspended: S,
65
- handleRowClick: R,
66
- openMeasureUnits: z,
67
- closeMeasureUnits: B,
68
- submitForm: V,
69
- confirmDelete: H
75
+ view: M,
76
+ units: R,
77
+ table: z,
78
+ details: B,
79
+ form: V,
80
+ del: H,
81
+ permissions: k,
82
+ isPermissionLoading: A,
83
+ isTableLoading: z.isLoading || A && z.rows.length === 0,
84
+ hasInitError: j,
85
+ refetchWidgetInit: O,
86
+ measureUnitsOpen: I,
87
+ actionsSuspended: D,
88
+ editForm: Y,
89
+ handleRowClick: U,
90
+ openMeasureUnits: W,
91
+ closeMeasureUnits: G,
92
+ submitForm: q,
93
+ confirmDelete: Z
70
94
  };
71
95
  }
72
96
  //#endregion
73
- export { g as useProductsWidget };
97
+ export { v as useProductsWidget };
@@ -1,6 +1,7 @@
1
- import "./index2.js";
1
+ import { PRODUCTS_SCREEN_LABELS_EN as e } from "./index2.js";
2
2
  import "./index3.js";
3
- import { ProductsScreen as e } from "./index4.js";
4
- import { ProductDetailsSheet as t } from "./index5.js";
5
- import { ProductDeleteDialog as n } from "./index6.js";
6
- export { n as ProductDeleteDialog, t as ProductDetailsSheet, e as ProductsScreen };
3
+ import { ProductsScreen as t } from "./index4.js";
4
+ import "./index5.js";
5
+ import { ProductDetailsSheet as n } from "./index6.js";
6
+ import { ProductDeleteDialog as r } from "./index7.js";
7
+ export { e as PRODUCTS_SCREEN_LABELS_EN, r as ProductDeleteDialog, n as ProductDetailsSheet, t as ProductsScreen };