@tesouro/embedded-components-react 0.7.72 → 0.7.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.css +9 -0
- package/dist/index.d.ts +12 -6
- package/dist/lib/ProductsWidget.d.ts +12 -6
- package/dist/lib/ReceivablesWidget.d.ts +1 -5
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +23 -24
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/constants.js +6 -2
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsTable.js +112 -51
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsWidget.js +80 -56
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index.js +6 -5
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index2.js +15 -6
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js +170 -135
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js +49 -150
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index6.js +152 -24
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index7.js +28 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +13 -12
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/ProductSelector.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js +41 -27
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +70 -52
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index.js +7 -6
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +19 -8
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +171 -218
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +52 -180
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js +188 -46
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +47 -124
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js +128 -0
- 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
|
|
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
|
-
|
|
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
|
-
|
|
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/
|
|
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 {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
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,
|
|
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(
|
|
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
|
-
|
|
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:
|
|
58
|
-
onRowClick:
|
|
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"
|
|
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:
|
|
78
|
+
onSubmit: V,
|
|
81
79
|
onCancel: O.close,
|
|
82
80
|
labels: _
|
|
83
81
|
}),
|
|
84
|
-
/* @__PURE__ */ h(
|
|
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(
|
|
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:
|
|
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:
|
|
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 {
|
|
6
|
-
import {
|
|
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 {
|
|
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
|
|
11
|
-
let [
|
|
12
|
-
|
|
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
|
-
|
|
19
|
+
S(y), v(void 0);
|
|
15
20
|
}, 400);
|
|
16
21
|
return () => clearTimeout(e);
|
|
17
|
-
}, [
|
|
18
|
-
let
|
|
19
|
-
...
|
|
20
|
-
sort:
|
|
21
|
-
order:
|
|
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:
|
|
24
|
-
pagination_token:
|
|
25
|
-
name__icontains:
|
|
26
|
-
type:
|
|
27
|
-
measure_unit_id:
|
|
28
|
-
enabled:
|
|
29
|
-
}),
|
|
30
|
-
products:
|
|
31
|
-
unitNamesById:
|
|
32
|
-
}), [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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:
|
|
44
|
-
isLoading:
|
|
45
|
-
isError:
|
|
46
|
-
sorting:
|
|
47
|
-
onSortingChange:
|
|
48
|
-
pageSize:
|
|
49
|
-
onPageSizeChange:
|
|
50
|
-
hasNextPage: !!
|
|
51
|
-
hasPrevPage: !!
|
|
52
|
-
onNextPage:
|
|
53
|
-
onPrevPage:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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 {
|
|
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 {
|
|
10
|
-
import {
|
|
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
|
|
13
|
-
import { useProductDelete as
|
|
14
|
-
import { useProductDetails as
|
|
15
|
-
import { useProductsTable as
|
|
16
|
-
import {
|
|
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
|
|
19
|
-
let
|
|
21
|
+
function v({ messageLabels: v, screenLabels: y, formLabels: b }) {
|
|
22
|
+
let x = g(() => ({
|
|
20
23
|
...a,
|
|
21
|
-
...
|
|
22
|
-
}), [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}), F =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
selectedProductId:
|
|
38
|
-
setSelectedProductId:
|
|
39
|
-
|
|
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 (!
|
|
43
|
-
let { canRead: e, canCreate: t, canUpdate: n, canDelete: r } =
|
|
44
|
-
|
|
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
|
|
47
|
-
|
|
48
|
-
}, [
|
|
49
|
-
|
|
50
|
-
}, [
|
|
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:
|
|
53
|
-
units:
|
|
54
|
-
table:
|
|
55
|
-
details:
|
|
56
|
-
form:
|
|
57
|
-
del:
|
|
58
|
-
permissions:
|
|
59
|
-
isPermissionLoading:
|
|
60
|
-
isTableLoading:
|
|
61
|
-
hasInitError:
|
|
62
|
-
refetchWidgetInit:
|
|
63
|
-
measureUnitsOpen:
|
|
64
|
-
actionsSuspended:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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 {
|
|
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
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
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 };
|