@tesouro/embedded-components-react 0.11.55 → 0.11.59

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 (38) hide show
  1. package/README.md +2 -2
  2. package/dist/index.css +0 -21
  3. package/dist/index.d.ts +31 -6
  4. package/dist/lib/ProductsWidget.d.ts +30 -5
  5. package/dist/lib/ReceivablesWidget.d.ts +27 -5
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +99 -92
  8. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductDelete.js +24 -21
  9. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsWidget.js +79 -75
  10. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/mocks/labels.js +5 -5
  11. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index2.js +9 -7
  12. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index3.js +7 -9
  13. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js +103 -118
  14. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js +28 -50
  15. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index6.js +118 -147
  16. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index7.js +24 -27
  17. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  18. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +16 -14
  19. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitCreateDialogContainer.js +38 -0
  20. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +73 -123
  21. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/ProductSelector.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js +6 -2
  23. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/labels.js +7 -7
  24. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useMeasureUnitForm.js +83 -0
  25. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +17 -4
  26. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index.js +6 -4
  27. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +45 -17
  28. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +121 -123
  29. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +36 -61
  30. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js +26 -194
  31. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +115 -49
  32. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js +62 -113
  33. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index8.js +51 -0
  34. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index9.js +117 -0
  35. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/index.js +14 -14
  36. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/StatePanel/NoAccessState.js +10 -2
  37. package/dist/packages/shared-ui-shadcn/dist/index.js +1648 -1526
  38. package/package.json +1 -1
@@ -1,155 +1,126 @@
1
- import { Button as e, DropdownMenu as t, DropdownMenuContent as n, DropdownMenuItem as r, DropdownMenuTrigger as i, Sheet as a, SheetClose as o, SheetContent as s, SheetDescription as c, SheetHeader as l, SheetTitle as u, Skeleton as d, Spinner as f, Typography as p } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { ErrorState as m } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
1
+ import { Button as e, DescriptionList as t, FormSheet as n, Heading as r, Skeleton as i, Typography as a } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { ErrorState as o } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
3
+ import { LoadingRegion as s } from "../../../shared/ui/dist/lib/LoadingRegion/LoadingRegion.js";
3
4
  import "../../../shared/ui/dist/index.js";
4
- import { PRODUCT_DETAILS_SHEET_LABELS_EN as h } from "./index2.js";
5
- import { ProductTypeBadge as g } from "./index3.js";
6
- import { ProductEditForm as _ } from "./index5.js";
7
- import { jsx as v, jsxs as y } from "react/jsx-runtime";
8
- import { MoreVertical as b, Trash2 as x, X as S } from "lucide-react";
9
- import { twMerge as C } from "tailwind-merge";
5
+ import { mergeProductFormSheetLabels as c } from "../../../shared/product-catalog/ui/dist/index2.js";
6
+ import { ActionsMenu as l } from "../../../shared/product-catalog/ui/dist/index5.js";
7
+ import "../../../shared/product-catalog/ui/dist/index.js";
8
+ import { PRODUCT_DETAILS_SHEET_LABELS_EN as u } from "./index2.js";
9
+ import { ProductTypeBadge as d } from "./index3.js";
10
+ import { ProductEditForm as f } from "./index5.js";
11
+ import { useId as p } from "react";
12
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
10
13
  // ../../libs/tesouro-embedded-components-react/products-widget/ui/dist/index6.js
11
- function w({ label: e, value: t, isLast: n, emptyValue: r = "—" }) {
12
- return /* @__PURE__ */ y("li", {
13
- className: C("ttw:flex ttw:gap-4 ttw:py-2.5", !n && "ttw:border-b ttw:border-border"),
14
- children: [/* @__PURE__ */ v(p, {
15
- variant: "body2",
16
- color: "muted",
17
- className: "ttw:w-35 ttw:min-w-35 ttw:font-medium",
18
- children: e
19
- }), typeof t == "string" ? /* @__PURE__ */ v(p, {
20
- variant: "body2",
21
- className: "ttw:min-w-0 ttw:font-medium ttw:wrap-break-word",
22
- children: t || r
23
- }) : t]
24
- });
25
- }
26
- function T({ open: C, onOpenChange: T, product: E, isLoading: D, isError: O, onEdit: k, onDelete: A, canEdit: j = !0, canDelete: M = !0, editForm: N, labels: P }) {
27
- let F = {
28
- ...h,
29
- ...P,
14
+ var g = 7;
15
+ function _({ open: _, onOpenChange: v, product: y, isLoading: b, isError: x, onEdit: S, onDelete: C, canEdit: w = !0, canDelete: T = !0, editForm: E, labels: D }) {
16
+ let O = {
17
+ ...u,
18
+ ...D,
30
19
  typeBadge: {
31
- ...h.typeBadge,
32
- ...P?.typeBadge
20
+ ...u.typeBadge,
21
+ ...D?.typeBadge
33
22
  }
34
- }, I = E?.type !== "service", L = I ? F.typeBadge.product : F.typeBadge.service, R = E ? F.subtitle.replace("{type}", L).replace("{createdAt}", E.createdAtLabel) : F.hiddenDescription;
35
- return /* @__PURE__ */ v(a, {
36
- open: C,
37
- onOpenChange: T,
38
- children: /* @__PURE__ */ y(s, {
39
- className: "ttw:w-150 ttw:sm:max-w-150 ttw:gap-0",
40
- showCloseButton: !1,
41
- children: [/* @__PURE__ */ y(l, {
42
- className: "ttw:pt-6 ttw:pl-6 ttw:pr-4 ttw:pb-7 ttw:flex-row ttw:gap-3 ttw:border-b ttw:border-border",
43
- children: [/* @__PURE__ */ y("div", {
44
- className: "ttw:flex ttw:flex-col ttw:gap-1.5 ttw:flex-1 ttw:min-w-0",
45
- children: [/* @__PURE__ */ v(u, {
46
- className: "ttw:truncate ttw:text-2xl",
47
- children: D ? /* @__PURE__ */ v(d, { className: "ttw:h-7 ttw:w-40" }) : E?.name ?? F.loadingTitle
48
- }), /* @__PURE__ */ v(c, {
49
- asChild: !0,
50
- children: /* @__PURE__ */ v("div", { children: D ? /* @__PURE__ */ v(d, { className: "ttw:h-4 ttw:w-60" }) : R })
51
- })]
52
- }), /* @__PURE__ */ y("div", {
53
- className: "ttw:flex ttw:gap-2 ttw:shrink-0",
54
- children: [M && /* @__PURE__ */ y(t, { children: [/* @__PURE__ */ v(i, {
55
- asChild: !0,
56
- children: /* @__PURE__ */ v(e, {
57
- type: "button",
58
- variant: "outline",
59
- disabled: !E,
60
- "aria-label": F.moreActionsLabel,
61
- className: "ttw:p-2 ttw:size-9 ttw:border-none ttw:bg-muted",
62
- children: /* @__PURE__ */ v(b, { className: "ttw:size-4" })
63
- })
64
- }), /* @__PURE__ */ v(n, {
65
- align: "end",
66
- children: /* @__PURE__ */ y(r, {
67
- onClick: A,
68
- variant: "destructive",
69
- children: [/* @__PURE__ */ v(x, { className: "ttw:size-4" }), F.deleteProductOption.replace("{type}", L)]
70
- })
71
- })] }), /* @__PURE__ */ v(o, {
72
- "aria-label": F.closeLabel,
73
- className: "ttw:size-9 ttw:bg-muted ttw:p-2 ttw:flex ttw:items-center ttw:justify-center ttw:rounded-md ttw:cursor-pointer",
74
- children: /* @__PURE__ */ v(S, { className: "ttw:size-4" })
75
- })]
23
+ }, k = p(), A = c(E?.labels), j = y?.type !== "service", M = j ? O.typeBadge.product : O.typeBadge.service, N = (e) => e || O.rowEmptyValue, P = x ? /* @__PURE__ */ m(o, {
24
+ title: O.errorTitle,
25
+ description: O.errorDescription
26
+ }) : b || !y ? /* @__PURE__ */ m(s, {
27
+ isLoading: !0,
28
+ loadingLabel: O.loadingLabel,
29
+ className: "ttw:flex ttw:flex-col ttw:gap-4 ttw:py-4",
30
+ children: Array.from({ length: g }, (e, t) => /* @__PURE__ */ m(i, { className: "ttw:h-5 ttw:w-full" }, t))
31
+ }) : E ? /* @__PURE__ */ m("div", {
32
+ className: "ttw:py-4",
33
+ children: /* @__PURE__ */ m(f, {
34
+ form: E,
35
+ formId: k
36
+ })
37
+ }) : /* @__PURE__ */ h("section", {
38
+ className: "ttw:flex ttw:flex-col ttw:gap-2 ttw:py-4",
39
+ children: [/* @__PURE__ */ h("div", {
40
+ className: "ttw:flex ttw:items-start ttw:justify-between ttw:gap-3",
41
+ children: [/* @__PURE__ */ h("div", {
42
+ className: "ttw:flex ttw:flex-col ttw:gap-1",
43
+ children: [/* @__PURE__ */ m(r, {
44
+ variant: "subsection",
45
+ children: O.sectionHeading.replace("{type}", M)
46
+ }), /* @__PURE__ */ m(a, {
47
+ variant: "body2",
48
+ color: "muted",
49
+ children: j ? O.typeProductDescription : O.typeServiceDescription
76
50
  })]
77
- }), O ? /* @__PURE__ */ v(m, {
78
- title: F.errorTitle,
79
- description: F.errorDescription
80
- }) : D || !E ? /* @__PURE__ */ v("div", {
81
- className: "ttw:flex ttw:w-full ttw:h-full ttw:items-center ttw:justify-center",
82
- children: /* @__PURE__ */ v(f, {})
83
- }) : /* @__PURE__ */ v("main", {
84
- className: "ttw:p-6 ttw:overflow-auto ttw:flex ttw:flex-col ttw:gap-4",
85
- children: /* @__PURE__ */ y("div", {
86
- className: "ttw:flex ttw:flex-col ttw:gap-4",
87
- children: [/* @__PURE__ */ y("div", {
88
- className: "ttw:flex ttw:items-center ttw:justify-between ttw:gap-3 ttw:pt-6 ttw:pb-7 ttw:border-b ttw:border-border",
89
- children: [/* @__PURE__ */ y("div", {
90
- className: "ttw:flex ttw:flex-col ttw:gap-1.5",
91
- children: [/* @__PURE__ */ v(p, {
92
- variant: "body1",
93
- className: "ttw:font-medium",
94
- children: F.sectionHeading.replace("{type}", L)
95
- }), /* @__PURE__ */ v(p, {
96
- variant: "body2",
97
- color: "muted",
98
- children: I ? F.typeProductDescription : F.typeServiceDescription
99
- })]
100
- }), j && !N && /* @__PURE__ */ v(e, {
101
- type: "button",
102
- variant: "ghost",
103
- className: "ttw:text-primary ttw:hover:text-primary",
104
- onClick: k,
105
- children: F.editButton
106
- })]
107
- }), N ? /* @__PURE__ */ v(_, { form: N }) : /* @__PURE__ */ y("ul", {
108
- className: "ttw:list-none ttw:p-0 ttw:m-0",
109
- children: [
110
- /* @__PURE__ */ v(w, {
111
- label: F.rowName.replace("{type}", L),
112
- value: E.name,
113
- emptyValue: F.rowEmptyValue
114
- }),
115
- /* @__PURE__ */ v(w, {
116
- label: F.rowPrice,
117
- value: E.priceLabel,
118
- emptyValue: F.rowEmptyValue
119
- }),
120
- /* @__PURE__ */ v(w, {
121
- label: F.rowDescription,
122
- value: E.description,
123
- emptyValue: F.rowEmptyValue
124
- }),
125
- /* @__PURE__ */ v(w, {
126
- label: F.rowType,
127
- value: E.type ? /* @__PURE__ */ v(g, {
128
- type: E.type,
129
- labels: F.typeBadge
130
- }) : F.rowEmptyValue
131
- }),
132
- /* @__PURE__ */ v(w, {
133
- label: F.rowUnit,
134
- value: E.unitLabel,
135
- emptyValue: F.rowEmptyValue
136
- }),
137
- /* @__PURE__ */ v(w, {
138
- label: F.rowCreatedOn,
139
- value: E.createdAtLabel,
140
- emptyValue: F.rowEmptyValue
141
- }),
142
- /* @__PURE__ */ v(w, {
143
- label: F.rowLastUpdate,
144
- value: E.updatedAtLabel,
145
- emptyValue: F.rowEmptyValue,
146
- isLast: !0
147
- })
148
- ]
149
- })]
150
- })
51
+ }), w && /* @__PURE__ */ m(e, {
52
+ type: "button",
53
+ variant: "link",
54
+ size: "sm",
55
+ onClick: S,
56
+ children: O.editButton
151
57
  })]
152
- })
58
+ }), /* @__PURE__ */ m(t, { items: [
59
+ {
60
+ label: O.rowName.replace("{type}", M),
61
+ value: N(y.name)
62
+ },
63
+ {
64
+ label: O.rowPrice,
65
+ value: N(y.priceLabel)
66
+ },
67
+ {
68
+ label: O.rowDescription,
69
+ value: N(y.description)
70
+ },
71
+ {
72
+ label: O.rowType,
73
+ value: y.type ? /* @__PURE__ */ m(d, {
74
+ type: y.type,
75
+ labels: O.typeBadge
76
+ }) : O.rowEmptyValue
77
+ },
78
+ {
79
+ label: O.rowUnit,
80
+ value: N(y.unitLabel)
81
+ },
82
+ {
83
+ label: O.rowCreatedOn,
84
+ value: N(y.createdAtLabel)
85
+ },
86
+ {
87
+ label: O.rowLastUpdate,
88
+ value: N(y.updatedAtLabel)
89
+ }
90
+ ] })]
91
+ });
92
+ return /* @__PURE__ */ m(n, {
93
+ open: _,
94
+ onOpenChange: v,
95
+ title: x ? O.unavailableTitle : y?.name ?? O.loadingTitle,
96
+ description: y && !x ? O.subtitle.replace("{type}", M).replace("{createdAt}", y.createdAtLabel) : void 0,
97
+ headerActions: T && !x ? /* @__PURE__ */ m(l, {
98
+ size: "icon",
99
+ label: O.moreActionsLabel,
100
+ disabled: !y,
101
+ items: [{
102
+ key: "delete",
103
+ label: O.deleteProductOption.replace("{type}", M),
104
+ onSelect: C,
105
+ destructive: !0
106
+ }]
107
+ }) : null,
108
+ secondaryAction: E ? /* @__PURE__ */ m(e, {
109
+ type: "button",
110
+ variant: "ghost",
111
+ disabled: E.inProgress,
112
+ onClick: E.onCancel,
113
+ children: A.cancelButton
114
+ }) : void 0,
115
+ primaryAction: E ? /* @__PURE__ */ m(e, {
116
+ type: "submit",
117
+ form: k,
118
+ loading: E.inProgress,
119
+ children: A.saveButton
120
+ }) : void 0,
121
+ submitting: E?.inProgress,
122
+ labels: { close: O.closeLabel },
123
+ children: P
153
124
  });
154
125
  }
155
- export { T as ProductDetailsSheet, T as default };
126
+ export { _ as ProductDetailsSheet, _ as default };
@@ -1,31 +1,28 @@
1
- import { AlertDialog as e, AlertDialogContent as t, AlertDialogDescription as n, AlertDialogFooter as r, AlertDialogHeader as i, AlertDialogTitle as a, Button as o } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { PRODUCT_DELETE_DIALOG_LABELS_EN as s } from "./index2.js";
3
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
1
+ import { ConfirmDialog as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { PRODUCT_DELETE_DIALOG_LABELS_EN as t } from "./index2.js";
3
+ import { jsx as n } from "react/jsx-runtime";
4
4
  // ../../libs/tesouro-embedded-components-react/products-widget/ui/dist/index7.js
5
- function u({ open: u, onOpenChange: d, productName: f, isDeleting: p, onConfirm: m, onCancel: h, labels: g }) {
6
- let _ = {
7
- ...s,
8
- ...g
5
+ function r({ open: r, onOpenChange: i, productName: a, isDeleting: o, onConfirm: s, onCancel: c, labels: l }) {
6
+ let u = {
7
+ ...t,
8
+ ...l
9
9
  };
10
- return /* @__PURE__ */ c(e, {
11
- open: u,
12
- onOpenChange: d,
13
- children: /* @__PURE__ */ l(t, {
14
- closeDisabled: p,
15
- labels: { close: _.close },
16
- children: [/* @__PURE__ */ l(i, { children: [/* @__PURE__ */ c(a, { children: _.title.replace("{name}", f) }), /* @__PURE__ */ c(n, { children: _.message })] }), /* @__PURE__ */ l(r, { children: [/* @__PURE__ */ c(o, {
17
- variant: "ghost",
18
- onClick: h,
19
- disabled: p,
20
- children: _.cancelButton
21
- }), /* @__PURE__ */ c(o, {
22
- variant: "destructive",
23
- onClick: m,
24
- disabled: p,
25
- loading: p,
26
- children: _.confirmButton
27
- })] })]
28
- })
10
+ return /* @__PURE__ */ n(e, {
11
+ open: r,
12
+ onOpenChange: (e) => {
13
+ e || c(), i(e);
14
+ },
15
+ title: u.title.replace("{name}", a),
16
+ description: u.message,
17
+ onConfirm: s,
18
+ destructive: !0,
19
+ confirmDisabled: o,
20
+ loading: o,
21
+ labels: {
22
+ confirm: u.confirmButton,
23
+ cancel: u.cancelButton,
24
+ close: u.close
25
+ }
29
26
  });
30
27
  }
31
- export { u as ProductDeleteDialog, u as default };
28
+ export { r as ProductDeleteDialog, r as default };
@@ -1,5 +1,5 @@
1
1
  // ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.11.55", n = "ca55e4f94cee2cffe719837a6544ecc156c55279", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.11.59", n = "dd2e792f0445acb9ddf3e4d98c8b7a1f8b62db13", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -1,27 +1,29 @@
1
1
  import { extractApiErrorMessage as e } from "../../../util/dist/lib/apiErrors.js";
2
2
  import "../../../util/dist/index.js";
3
3
  import { PRODUCT_MESSAGE_LABELS_EN as t } from "./lib/labels.js";
4
- import { buildProductDetailsView as n, buildProductRows as r, formatPrice as i, hasSelectedText as a } from "./lib/helpers.js";
5
- import { PRODUCT_FORM_SHEET_LABELS_EN as o } from "../../ui/dist/index2.js";
6
- import { ProductFormSheet as s } from "../../ui/dist/index4.js";
7
- import "../../ui/dist/index5.js";
4
+ import { buildProductDetailsView as n, buildProductRows as r, formatDeleteError as i, formatPrice as a, hasSelectedText as o } from "./lib/helpers.js";
5
+ import { toastSuccessWithName as s } from "./lib/toasts.js";
6
+ import { PRODUCT_FORM_SHEET_LABELS_EN as c } from "../../ui/dist/index2.js";
7
+ import { ProductFormSheet as l } from "../../ui/dist/index4.js";
8
8
  import "../../ui/dist/index6.js";
9
+ import "../../ui/dist/index8.js";
9
10
  import "../../ui/dist/index.js";
10
- import { useProductsQuery as c } from "../../data-access/dist/index2.js";
11
+ import { useProductsQuery as u } from "../../data-access/dist/index2.js";
11
12
  import "../../data-access/dist/index3.js";
12
- import { useProductQuery as l } from "../../data-access/dist/index4.js";
13
- import { useCreateProductMutation as u } from "../../data-access/dist/index6.js";
13
+ import { useProductQuery as d } from "../../data-access/dist/index4.js";
14
+ import { useCreateProductMutation as f } from "../../data-access/dist/index6.js";
14
15
  import "../../data-access/dist/index7.js";
15
- import { useDeleteProductMutation as d } from "../../data-access/dist/index8.js";
16
- import { useMeasureUnitsQuery as f } from "../../data-access/dist/index9.js";
16
+ import { useDeleteProductMutation as p } from "../../data-access/dist/index8.js";
17
+ import { useMeasureUnitsQuery as m } from "../../data-access/dist/index9.js";
17
18
  import "../../data-access/dist/index10.js";
18
19
  import "../../data-access/dist/index11.js";
19
20
  import "../../data-access/dist/index12.js";
20
21
  import "../../data-access/dist/index13.js";
21
22
  import "../../data-access/dist/index.js";
22
- import { MeasureUnitsManagerContainer as p } from "./lib/MeasureUnitsManagerContainer.js";
23
- import { useMeasureUnits as m } from "./lib/useMeasureUnits.js";
24
- import { useProductForm as h } from "./lib/useProductForm.js";
23
+ import { MeasureUnitsManagerContainer as h } from "./lib/MeasureUnitsManagerContainer.js";
24
+ import { MeasureUnitCreateDialogContainer as g } from "./lib/MeasureUnitCreateDialogContainer.js";
25
+ import { useMeasureUnits as _ } from "./lib/useMeasureUnits.js";
26
+ import { useProductForm as v } from "./lib/useProductForm.js";
25
27
  import "./lib/useProductSelector.js";
26
- import { ProductSelector as g } from "./lib/ProductSelector.js";
27
- export { p as MeasureUnitsManagerContainer, o as PRODUCT_FORM_SHEET_LABELS_EN, t as PRODUCT_MESSAGE_LABELS_EN, s as ProductFormSheet, g as ProductSelector, n as buildProductDetailsView, r as buildProductRows, e as extractApiErrorMessage, i as formatPrice, a as hasSelectedText, u as useCreateProductMutation, d as useDeleteProductMutation, m as useMeasureUnits, f as useMeasureUnitsQuery, h as useProductForm, l as useProductQuery, c as useProductsQuery };
28
+ import { ProductSelector as y } from "./lib/ProductSelector.js";
29
+ export { g as MeasureUnitCreateDialogContainer, h as MeasureUnitsManagerContainer, c as PRODUCT_FORM_SHEET_LABELS_EN, t as PRODUCT_MESSAGE_LABELS_EN, l as ProductFormSheet, y as ProductSelector, n as buildProductDetailsView, r as buildProductRows, e as extractApiErrorMessage, i as formatDeleteError, a as formatPrice, o as hasSelectedText, s as toastSuccessWithName, f as useCreateProductMutation, p as useDeleteProductMutation, _ as useMeasureUnits, m as useMeasureUnitsQuery, v as useProductForm, d as useProductQuery, u as useProductsQuery };
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { PRODUCT_MESSAGE_LABELS_EN as e } from "./labels.js";
6
+ import { MeasureUnitFormDialog as t, MeasureUnitFormMode as n } from "../../../ui/dist/index7.js";
7
+ import "../../../ui/dist/index.js";
8
+ import { useMeasureUnitForm as r } from "./useMeasureUnitForm.js";
9
+ import { useMemo as i, useState as a } from "react";
10
+ import { jsx as o } from "react/jsx-runtime";
11
+ // ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitCreateDialogContainer.js
12
+ function s({ open: s, onClose: c, onCreated: l, suspended: u = !1, labels: d, messageLabels: f }) {
13
+ let p = i(() => ({
14
+ ...e,
15
+ ...f
16
+ }), [f]), m = r({
17
+ messages: p,
18
+ suspended: u,
19
+ toastOnCreate: !1,
20
+ onCreated: (e) => {
21
+ l(e), c();
22
+ }
23
+ }), [h, g] = a(!1);
24
+ return s !== h && (g(s), s && m.openCreate()), /* @__PURE__ */ o(t, {
25
+ open: s,
26
+ onOpenChange: (e) => {
27
+ e || c();
28
+ },
29
+ mode: n.Create,
30
+ values: m.draft,
31
+ error: m.error,
32
+ submitting: m.isSubmitting || u,
33
+ onChange: m.change,
34
+ onSubmit: m.submit,
35
+ labels: d
36
+ });
37
+ }
38
+ export { s as MeasureUnitCreateDialogContainer, s as default };
@@ -7,147 +7,97 @@ import { extractApiErrorMessage as t } from "../../../../util/dist/lib/apiErrors
7
7
  import "../../../../util/dist/index.js";
8
8
  import "../../../../ui/dist/index.js";
9
9
  import { PRODUCT_MESSAGE_LABELS_EN as n } from "./labels.js";
10
- import { formatPrice as r, validateMeasureUnit as i } from "./helpers.js";
10
+ import { formatDeleteError as r, formatPrice as i } from "./helpers.js";
11
11
  import { toastSuccessWithName as a } from "./toasts.js";
12
- import { MeasureUnitsManager as o } from "../../../ui/dist/index5.js";
13
- import { MeasureUnitDeleteDialog as s } from "../../../ui/dist/index6.js";
12
+ import { MeasureUnitsManager as o } from "../../../ui/dist/index6.js";
13
+ import { MeasureUnitFormDialog as s, MeasureUnitFormMode as c } from "../../../ui/dist/index7.js";
14
+ import { MeasureUnitDeleteDialog as l } from "../../../ui/dist/index8.js";
14
15
  import "../../../ui/dist/index.js";
15
- import { useMeasureUnitsQuery as c } from "../../../data-access/dist/index9.js";
16
- import { useProductsByMeasureUnitQuery as l } from "../../../data-access/dist/index10.js";
17
- import { useCreateMeasureUnitMutation as u } from "../../../data-access/dist/index11.js";
18
- import { useUpdateMeasureUnitMutation as d } from "../../../data-access/dist/index12.js";
16
+ import { useMeasureUnitsQuery as u } from "../../../data-access/dist/index9.js";
17
+ import { useProductsByMeasureUnitQuery as d } from "../../../data-access/dist/index10.js";
19
18
  import { useDeleteMeasureUnitMutation as f } from "../../../data-access/dist/index13.js";
20
19
  import "../../../data-access/dist/index.js";
21
- import { useCallback as p, useMemo as m, useState as h } from "react";
22
- import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
20
+ import { useMeasureUnitForm as p } from "./useMeasureUnitForm.js";
21
+ import { useCallback as m, useMemo as h, useState as g } from "react";
22
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
23
23
  // ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js
24
- var y = {
25
- name: "",
26
- description: ""
27
- };
28
24
  function b({ open: b, onClose: x, suspended: S = !1, managerLabels: C, deleteLabels: w, messageLabels: T }) {
29
- let E = m(() => ({
25
+ let E = h(() => ({
30
26
  ...n,
31
27
  ...T
32
- }), [T]), D = c({ enabled: b && !S }), O = u(), k = d(), A = f(), [j, M] = h(""), [N, P] = h(y), [F, I] = h(), [L, R] = h(), [z, B] = h(y), [V, H] = h(), [U, W] = h(), [G, K] = h(b);
33
- b !== G && (K(b), b || W(void 0));
34
- let q = m(() => (D.data?.data ?? []).map((e) => ({
28
+ }), [T]), D = u({ enabled: b && !S }), O = p({
29
+ messages: E,
30
+ suspended: S
31
+ }), k = f(), [A, j] = g(""), [M, N] = g(), [P, F] = g(b);
32
+ b !== P && (F(b), b || (N(void 0), O.close()));
33
+ let I = h(() => (D.data?.data ?? []).map((e) => ({
35
34
  id: e.id,
36
35
  name: e.name,
37
36
  description: e.description ?? ""
38
- })), [D.data]), J = m(() => {
39
- let e = j.trim().toLowerCase();
40
- return e ? q.filter((t) => t.name.toLowerCase().includes(e) || t.description.toLowerCase().includes(e)) : q;
41
- }, [q, j]), Y = l(U?.id, { enabled: b && !S }), X = m(() => (Y.data?.data ?? []).map((e) => ({
37
+ })), [D.data]), L = D.isError && D.data === void 0, R = L && D.isFetching, z = h(() => {
38
+ let e = A.trim().toLowerCase();
39
+ return e ? I.filter((t) => t.name.toLowerCase().includes(e) || t.description.toLowerCase().includes(e)) : I;
40
+ }, [I, A]), B = d(M?.id, { enabled: b && !S }), V = h(() => (B.data?.data ?? []).map((e) => ({
42
41
  id: e.id,
43
42
  name: e.name,
44
- priceLabel: r(e.price)
45
- })), [Y.data]), Z = p(async () => {
46
- if (S) return;
47
- let e = i(N, E);
48
- if (e) I(e);
49
- else {
50
- I(void 0);
51
- try {
52
- let e = await O.mutateAsync({ body: {
53
- name: N.name.trim(),
54
- description: N.description.trim() || void 0
55
- } });
56
- a(E.measureUnitCreated, e.name), P(y);
57
- } catch (e) {
58
- I(t(e) ?? E.createMeasureUnitError);
59
- }
60
- }
61
- }, [
62
- S,
63
- N,
64
- O,
65
- E
66
- ]), Q = p((e) => {
67
- R(e.id), B({
68
- name: e.name,
69
- description: e.description
70
- }), H(void 0);
71
- }, []), $ = p(async () => {
72
- if (S || !L) return;
73
- let e = i(z, E);
74
- if (e) H(e);
75
- else {
76
- H(void 0);
77
- try {
78
- let e = await k.mutateAsync({
79
- path: { unit_id: L },
80
- body: {
81
- name: z.name.trim(),
82
- description: z.description.trim() || void 0
83
- }
84
- });
85
- a(E.measureUnitUpdated, e.name), R(void 0);
86
- } catch (e) {
87
- H(t(e) ?? E.updateMeasureUnitError);
88
- }
89
- }
90
- }, [
91
- S,
92
- L,
93
- z,
94
- k,
95
- E
96
- ]), ee = p(async () => {
97
- if (!S && U) try {
98
- await A.mutateAsync({ path: { unit_id: U.id } }), a(E.measureUnitDeleted, U.name), W(void 0);
43
+ priceLabel: i(e.price)
44
+ })), [B.data]), H = m(async () => {
45
+ if (!S && M) try {
46
+ await k.mutateAsync({ path: { unit_id: M.id } }), a(E.measureUnitDeleted, M.name), N(void 0);
99
47
  } catch (n) {
100
- e.error(t(n) ?? E.deleteMeasureUnitError);
48
+ e.error(r(E.deleteMeasureUnitError, M.name, t(n)));
101
49
  }
102
50
  }, [
103
51
  S,
104
- U,
105
- A,
52
+ M,
53
+ k,
106
54
  E
107
55
  ]);
108
- return /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(o, {
109
- open: b,
110
- onOpenChange: (e) => {
111
- e || x();
112
- },
113
- units: J,
114
- isLoading: D.isLoading,
115
- searchValue: j,
116
- onSearchChange: M,
117
- createValues: N,
118
- createError: F,
119
- onCreateChange: (e) => P((t) => ({
120
- ...t,
121
- ...e
122
- })),
123
- onCreateSubmit: Z,
124
- isCreating: O.isPending || S,
125
- editingUnitId: L,
126
- editValues: z,
127
- editError: V,
128
- onEditStart: Q,
129
- onEditChange: (e) => B((t) => ({
130
- ...t,
131
- ...e
132
- })),
133
- onEditSubmit: $,
134
- onEditCancel: () => R(void 0),
135
- isUpdating: k.isPending || S,
136
- onDeleteClick: W,
137
- onDone: x,
138
- labels: C
139
- }), /* @__PURE__ */ _(s, {
140
- open: !!U,
141
- onOpenChange: (e) => {
142
- e || W(void 0);
143
- },
144
- unitName: U?.name ?? "",
145
- affectedProducts: X,
146
- isLoadingProducts: Y.isLoading,
147
- isDeleting: A.isPending || S,
148
- onConfirm: ee,
149
- onCancel: () => W(void 0),
150
- labels: w
151
- })] });
56
+ return /* @__PURE__ */ y(_, { children: [
57
+ /* @__PURE__ */ v(o, {
58
+ open: b,
59
+ onOpenChange: (e) => {
60
+ e || x();
61
+ },
62
+ units: z,
63
+ isLoading: D.isLoading || R,
64
+ isError: L && !R,
65
+ onRetry: S ? void 0 : () => void D.refetch(),
66
+ searchValue: A,
67
+ onSearchChange: j,
68
+ onAddClick: O.openCreate,
69
+ actionsDisabled: S,
70
+ onEditClick: O.openEdit,
71
+ onDeleteClick: N,
72
+ onDone: x,
73
+ labels: C
74
+ }),
75
+ /* @__PURE__ */ v(s, {
76
+ open: b && O.mode !== void 0,
77
+ onOpenChange: (e) => {
78
+ e || O.close();
79
+ },
80
+ mode: O.mode ?? c.Create,
81
+ values: O.draft,
82
+ error: O.error,
83
+ submitting: O.isSubmitting || S,
84
+ onChange: O.change,
85
+ onSubmit: O.submit,
86
+ labels: C
87
+ }),
88
+ /* @__PURE__ */ v(l, {
89
+ open: !!M,
90
+ onOpenChange: (e) => {
91
+ e || N(void 0);
92
+ },
93
+ unitName: M?.name ?? "",
94
+ affectedProducts: V,
95
+ isLoadingProducts: B.isLoading,
96
+ isDeleting: k.isPending || S,
97
+ onConfirm: H,
98
+ onCancel: () => N(void 0),
99
+ labels: w
100
+ })
101
+ ] });
152
102
  }
153
103
  export { b as MeasureUnitsManagerContainer, b as default };