@tesouro/embedded-components-react 0.7.70 → 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 +15 -12
- package/dist/index.css +24 -6
- package/dist/index.d.ts +76 -8
- package/dist/lib/LinkedAccountsWidget.d.ts +9 -0
- package/dist/lib/ProductsWidget.d.ts +12 -6
- package/dist/lib/ReceivablesWidget.d.ts +1 -5
- package/dist/lib/TransfersWidget.d.ts +55 -2
- package/dist/lib/WidgetSuite.d.ts +63 -1
- package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/lib/LinkedAccountsWidget.js +6 -4
- package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/lib/useLinkedAccountsWidget.js +199 -182
- 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/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetFeature.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetInner.js +99 -108
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/testIds.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/transferViews.js +135 -0
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/useTransferMoneyModalController.js +140 -153
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransferAccountTile.js +15 -0
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransferDetailSheet.js +111 -0
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransferStatusBadge.js +18 -0
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransfersWidget.js +181 -126
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/labels.js +33 -0
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/TransfersSection.js +16 -8
- package/dist/packages/shared-ui-shadcn/dist/index.js +328 -327
- package/package.json +1 -1
|
@@ -1,28 +1,156 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
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";
|
|
3
|
+
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";
|
|
4
10
|
//#region ../../libs/tesouro-embedded-components-react/products-widget/ui/dist/index6.js
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
variant: "
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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,
|
|
30
|
+
typeBadge: {
|
|
31
|
+
...h.typeBadge,
|
|
32
|
+
...P?.typeBadge
|
|
33
|
+
}
|
|
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
|
+
})]
|
|
76
|
+
})]
|
|
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
|
+
})
|
|
151
|
+
})]
|
|
152
|
+
})
|
|
25
153
|
});
|
|
26
154
|
}
|
|
27
155
|
//#endregion
|
|
28
|
-
export {
|
|
156
|
+
export { T as ProductDetailsSheet, T as default };
|
|
@@ -0,0 +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";
|
|
4
|
+
//#region ../../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
|
|
9
|
+
};
|
|
10
|
+
return /* @__PURE__ */ c(e, {
|
|
11
|
+
open: u,
|
|
12
|
+
onOpenChange: d,
|
|
13
|
+
children: /* @__PURE__ */ l(t, { 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, {
|
|
14
|
+
variant: "ghost",
|
|
15
|
+
onClick: h,
|
|
16
|
+
disabled: p,
|
|
17
|
+
children: _.cancelButton
|
|
18
|
+
}), /* @__PURE__ */ c(o, {
|
|
19
|
+
variant: "destructive",
|
|
20
|
+
onClick: m,
|
|
21
|
+
disabled: p,
|
|
22
|
+
loading: p,
|
|
23
|
+
children: _.confirmButton
|
|
24
|
+
})] })] })
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { u as ProductDeleteDialog, u as default };
|
package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
|
|
2
|
-
var e = "@tesouro/embedded-components-react", t = "0.7.
|
|
2
|
+
var e = "@tesouro/embedded-components-react", t = "0.7.73", n = "6460d41dcd6d9cc7806778015e14814d4bfd495d", r = Object.freeze({
|
|
3
3
|
library_name: e,
|
|
4
4
|
library_version: t,
|
|
5
5
|
library_sha: n
|
package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { extractApiErrorMessage as e } from "../../../util/dist/lib/apiErrors.js";
|
|
2
2
|
import { PRODUCT_MESSAGE_LABELS_EN as t } from "./lib/labels.js";
|
|
3
3
|
import { buildProductDetailsView as n, buildProductRows as r, formatPrice as i, hasSelectedText as a } from "./lib/helpers.js";
|
|
4
|
-
import {
|
|
5
|
-
import "../../ui/dist/index4.js";
|
|
4
|
+
import { PRODUCT_FORM_SHEET_LABELS_EN as o } from "../../ui/dist/index2.js";
|
|
5
|
+
import { ProductFormSheet as s } from "../../ui/dist/index4.js";
|
|
6
6
|
import "../../ui/dist/index5.js";
|
|
7
|
+
import "../../ui/dist/index6.js";
|
|
7
8
|
import "../../ui/dist/index.js";
|
|
8
|
-
import { useProductsQuery as
|
|
9
|
+
import { useProductsQuery as c } from "../../data-access/dist/index2.js";
|
|
9
10
|
import "../../data-access/dist/index3.js";
|
|
10
|
-
import { useProductQuery as
|
|
11
|
-
import { useCreateProductMutation as
|
|
11
|
+
import { useProductQuery as l } from "../../data-access/dist/index4.js";
|
|
12
|
+
import { useCreateProductMutation as u } from "../../data-access/dist/index6.js";
|
|
12
13
|
import "../../data-access/dist/index7.js";
|
|
13
|
-
import { useDeleteProductMutation as
|
|
14
|
-
import { useMeasureUnitsQuery as
|
|
14
|
+
import { useDeleteProductMutation as d } from "../../data-access/dist/index8.js";
|
|
15
|
+
import { useMeasureUnitsQuery as f } from "../../data-access/dist/index9.js";
|
|
15
16
|
import "../../data-access/dist/index10.js";
|
|
16
17
|
import "../../data-access/dist/index11.js";
|
|
17
18
|
import "../../data-access/dist/index12.js";
|
|
18
19
|
import "../../data-access/dist/index13.js";
|
|
19
20
|
import "../../data-access/dist/index.js";
|
|
20
|
-
import { MeasureUnitsManagerContainer as
|
|
21
|
-
import { useMeasureUnits as
|
|
22
|
-
import { useProductForm as
|
|
21
|
+
import { MeasureUnitsManagerContainer as p } from "./lib/MeasureUnitsManagerContainer.js";
|
|
22
|
+
import { useMeasureUnits as m } from "./lib/useMeasureUnits.js";
|
|
23
|
+
import { useProductForm as h } from "./lib/useProductForm.js";
|
|
23
24
|
import "./lib/useProductSelector.js";
|
|
24
|
-
import { ProductSelector as
|
|
25
|
-
export {
|
|
25
|
+
import { ProductSelector as g } from "./lib/ProductSelector.js";
|
|
26
|
+
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 };
|
|
@@ -8,8 +8,8 @@ import "../../../../ui/dist/index.js";
|
|
|
8
8
|
import { PRODUCT_MESSAGE_LABELS_EN as n } from "./labels.js";
|
|
9
9
|
import { formatPrice as r, validateMeasureUnit as i } from "./helpers.js";
|
|
10
10
|
import { toastSuccessWithName as a } from "./toasts.js";
|
|
11
|
-
import { MeasureUnitsManager as o } from "../../../ui/dist/
|
|
12
|
-
import { MeasureUnitDeleteDialog as s } from "../../../ui/dist/
|
|
11
|
+
import { MeasureUnitsManager as o } from "../../../ui/dist/index5.js";
|
|
12
|
+
import { MeasureUnitDeleteDialog as s } from "../../../ui/dist/index6.js";
|
|
13
13
|
import "../../../ui/dist/index.js";
|
|
14
14
|
import { useMeasureUnitsQuery as c } from "../../../data-access/dist/index9.js";
|
|
15
15
|
import { useProductsByMeasureUnitQuery as l } from "../../../data-access/dist/index10.js";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import { ProductSelector as e } from "../../../ui/dist/
|
|
5
|
+
import { ProductSelector as e } from "../../../ui/dist/index7.js";
|
|
6
6
|
import "../../../ui/dist/index.js";
|
|
7
7
|
import { useProductSelector as t } from "./useProductSelector.js";
|
|
8
8
|
import { jsx as n } from "react/jsx-runtime";
|
|
@@ -20,6 +20,17 @@ function a(e, t) {
|
|
|
20
20
|
return e / 10 ** r(t);
|
|
21
21
|
}
|
|
22
22
|
function o(e) {
|
|
23
|
+
try {
|
|
24
|
+
return new Intl.NumberFormat(void 0, {
|
|
25
|
+
style: "currency",
|
|
26
|
+
currency: e,
|
|
27
|
+
currencyDisplay: e.toUpperCase() === "USD" ? "narrowSymbol" : "symbol"
|
|
28
|
+
}).formatToParts(0).find((e) => e.type === "currency")?.value ?? e;
|
|
29
|
+
} catch {
|
|
30
|
+
return e;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function s(e) {
|
|
23
34
|
if (!e) return "";
|
|
24
35
|
let t = a(e.value, e.currency);
|
|
25
36
|
try {
|
|
@@ -31,49 +42,49 @@ function o(e) {
|
|
|
31
42
|
return `${t} ${e.currency}`;
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
|
-
var
|
|
45
|
+
var c = new Intl.DateTimeFormat(void 0, {
|
|
35
46
|
year: "numeric",
|
|
36
47
|
month: "short",
|
|
37
|
-
day: "
|
|
48
|
+
day: "2-digit"
|
|
38
49
|
});
|
|
39
|
-
function
|
|
50
|
+
function l(e) {
|
|
40
51
|
if (!e) return "";
|
|
41
52
|
let t = new Date(e);
|
|
42
|
-
return Number.isNaN(t.getTime()) ? "" :
|
|
53
|
+
return Number.isNaN(t.getTime()) ? "" : c.format(t);
|
|
43
54
|
}
|
|
44
|
-
function
|
|
55
|
+
function u(e) {
|
|
45
56
|
let t = {};
|
|
46
57
|
for (let n of e ?? []) t[n.id] = n.name;
|
|
47
58
|
return t;
|
|
48
59
|
}
|
|
49
|
-
function
|
|
60
|
+
function d(e) {
|
|
50
61
|
return (e ?? []).map((e) => ({
|
|
51
62
|
value: e.id,
|
|
52
63
|
label: e.name
|
|
53
64
|
}));
|
|
54
65
|
}
|
|
55
|
-
function
|
|
66
|
+
function f({ products: e, unitNamesById: t }) {
|
|
56
67
|
return e.map((e) => ({
|
|
57
68
|
id: e.id,
|
|
58
69
|
name: e.name,
|
|
59
70
|
type: e.type,
|
|
60
71
|
description: e.description ?? "",
|
|
61
72
|
unitLabel: e.measure_unit_id ? t[e.measure_unit_id] ?? "" : "",
|
|
62
|
-
priceLabel:
|
|
73
|
+
priceLabel: s(e.price)
|
|
63
74
|
}));
|
|
64
75
|
}
|
|
65
|
-
function
|
|
76
|
+
function p({ product: e, unitNamesById: t }) {
|
|
66
77
|
return {
|
|
67
78
|
name: e.name,
|
|
68
79
|
description: e.description ?? "",
|
|
69
80
|
type: e.type,
|
|
70
81
|
unitLabel: e.measure_unit_id ? t[e.measure_unit_id] ?? "" : "",
|
|
71
|
-
priceLabel:
|
|
72
|
-
createdAtLabel:
|
|
73
|
-
updatedAtLabel:
|
|
82
|
+
priceLabel: s(e.price),
|
|
83
|
+
createdAtLabel: l(e.created_at),
|
|
84
|
+
updatedAtLabel: l(e.updated_at)
|
|
74
85
|
};
|
|
75
86
|
}
|
|
76
|
-
var
|
|
87
|
+
var m = {
|
|
77
88
|
name: "",
|
|
78
89
|
description: "",
|
|
79
90
|
type: "product",
|
|
@@ -81,7 +92,10 @@ var p = {
|
|
|
81
92
|
pricePerUnit: "",
|
|
82
93
|
currency: "USD"
|
|
83
94
|
};
|
|
84
|
-
function
|
|
95
|
+
function h(e, t) {
|
|
96
|
+
return Object.keys(e).every((n) => e[n] === t[n]);
|
|
97
|
+
}
|
|
98
|
+
function g(e) {
|
|
85
99
|
let t = e.price?.currency ?? "USD";
|
|
86
100
|
return {
|
|
87
101
|
name: e.name,
|
|
@@ -92,7 +106,7 @@ function m(e) {
|
|
|
92
106
|
currency: t
|
|
93
107
|
};
|
|
94
108
|
}
|
|
95
|
-
function
|
|
109
|
+
function _(e) {
|
|
96
110
|
let t = e.pricePerUnit.trim();
|
|
97
111
|
return {
|
|
98
112
|
name: e.name.trim(),
|
|
@@ -105,7 +119,7 @@ function h(e) {
|
|
|
105
119
|
description: e.description.trim() ? e.description.trim() : void 0
|
|
106
120
|
};
|
|
107
121
|
}
|
|
108
|
-
function
|
|
122
|
+
function v(e) {
|
|
109
123
|
let t = e.pricePerUnit.trim();
|
|
110
124
|
return {
|
|
111
125
|
name: e.name.trim(),
|
|
@@ -118,18 +132,18 @@ function g(e) {
|
|
|
118
132
|
description: e.description.trim()
|
|
119
133
|
};
|
|
120
134
|
}
|
|
121
|
-
var
|
|
122
|
-
function
|
|
135
|
+
var y = 100, b = 255;
|
|
136
|
+
function x(e, t = n) {
|
|
123
137
|
let r = {};
|
|
124
|
-
e.name.trim().length === 0 ? r.name = t.nameRequired : e.name.trim().length >
|
|
138
|
+
e.name.trim().length === 0 ? r.name = t.nameRequired : e.name.trim().length > y && (r.name = t.nameTooLong), e.type !== "product" && e.type !== "service" && (r.type = t.typeRequired);
|
|
125
139
|
let i = e.pricePerUnit.trim();
|
|
126
140
|
if (i !== "") {
|
|
127
141
|
let e = Number(i);
|
|
128
142
|
(!Number.isFinite(e) || e < 0) && (r.pricePerUnit = t.priceInvalid);
|
|
129
143
|
}
|
|
130
|
-
return e.description.trim().length >
|
|
144
|
+
return e.description.trim().length > b && (r.description = t.descriptionTooLong), r;
|
|
131
145
|
}
|
|
132
|
-
var
|
|
146
|
+
var S = {
|
|
133
147
|
name: "name",
|
|
134
148
|
type: "type",
|
|
135
149
|
description: "description",
|
|
@@ -137,25 +151,25 @@ var b = {
|
|
|
137
151
|
"price.currency": "pricePerUnit",
|
|
138
152
|
measure_unit_id: "unitId"
|
|
139
153
|
};
|
|
140
|
-
function
|
|
154
|
+
function C(r, i = n) {
|
|
141
155
|
let a = t(r);
|
|
142
156
|
if (!a.length) return { form: e(r) ?? i.genericError };
|
|
143
157
|
let o = {}, s = [];
|
|
144
158
|
for (let { path: e, msg: t } of a) {
|
|
145
|
-
let n =
|
|
159
|
+
let n = S[e];
|
|
146
160
|
n ? o[n] = t : s.push(t);
|
|
147
161
|
}
|
|
148
162
|
return s.length && (o.form = [...new Set(s)].join("; ")), o;
|
|
149
163
|
}
|
|
150
|
-
function
|
|
164
|
+
function w(e) {
|
|
151
165
|
return Object.values(e).some(Boolean);
|
|
152
166
|
}
|
|
153
|
-
function
|
|
167
|
+
function T(e, t = n) {
|
|
154
168
|
return e.name.trim().length === 0 ? t.unitNameRequired : void 0;
|
|
155
169
|
}
|
|
156
|
-
function
|
|
170
|
+
function E() {
|
|
157
171
|
let e = globalThis.getSelection?.();
|
|
158
172
|
return !!(e && e.toString().length > 0);
|
|
159
173
|
}
|
|
160
174
|
//#endregion
|
|
161
|
-
export {
|
|
175
|
+
export { m as EMPTY_PRODUCT_FORM_VALUES, C as apiErrorToProductFormErrors, h as areProductFormValuesEqual, p as buildProductDetailsView, f as buildProductRows, u as buildUnitNamesById, d as buildUnitOptions, o as currencySymbol, s as formatPrice, l as formatProductDate, a as fromMinorUnits, w as hasProductFormErrors, E as hasSelectedText, _ as productFormValuesToRequest, v as productFormValuesToUpdateRequest, g as productToFormValues, i as toMinorUnits, T as validateMeasureUnit, x as validateProductForm };
|
|
@@ -2,62 +2,80 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import { EMPTY_PRODUCT_FORM_VALUES as e, apiErrorToProductFormErrors as t,
|
|
6
|
-
import { toastSuccessWithName as
|
|
7
|
-
import { useCreateProductMutation as
|
|
8
|
-
import { useUpdateProductMutation as
|
|
5
|
+
import { EMPTY_PRODUCT_FORM_VALUES as e, apiErrorToProductFormErrors as t, areProductFormValuesEqual as n, currencySymbol as r, hasProductFormErrors as i, productFormValuesToRequest as a, productFormValuesToUpdateRequest as o, productToFormValues as s, validateProductForm as c } from "./helpers.js";
|
|
6
|
+
import { toastSuccessWithName as l } from "./toasts.js";
|
|
7
|
+
import { useCreateProductMutation as u } from "../../../data-access/dist/index6.js";
|
|
8
|
+
import { useUpdateProductMutation as d } from "../../../data-access/dist/index7.js";
|
|
9
9
|
import "../../../data-access/dist/index.js";
|
|
10
|
-
import { useCallback as
|
|
10
|
+
import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
11
11
|
//#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
function _({ view: _, setView: v, selectedProductId: y, setSelectedProductId: b, product: x, messages: S }) {
|
|
13
|
+
let C = u(), w = d(), T = C.isPending || w.isPending, [E, D] = g(e), [O, k] = g({}), A = h({
|
|
14
|
+
view: _,
|
|
15
|
+
selectedProductId: y
|
|
16
|
+
});
|
|
17
|
+
p(() => {
|
|
18
|
+
A.current = {
|
|
19
|
+
view: _,
|
|
20
|
+
selectedProductId: y
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
let j = f(() => {
|
|
24
|
+
b(void 0), D(e), k({}), v("create");
|
|
25
|
+
}, [b, v]), M = f(() => {
|
|
26
|
+
x && (D(s(x)), k({}), v("edit"));
|
|
27
|
+
}, [x, v]), N = f(() => {
|
|
28
|
+
v("none"), b(void 0);
|
|
29
|
+
}, [b, v]), P = f(() => {
|
|
30
|
+
k({}), v("details");
|
|
31
|
+
}, [v]), F = m(() => _ === "edit" && x ? !n(E, s(x)) : !1, [
|
|
32
|
+
_,
|
|
33
|
+
x,
|
|
34
|
+
E
|
|
35
|
+
]), I = f(async () => {
|
|
36
|
+
let e = c(E, S);
|
|
37
|
+
if (i(e)) {
|
|
38
|
+
k(e);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
k({});
|
|
42
|
+
try {
|
|
43
|
+
if (_ === "edit" && y) {
|
|
44
|
+
let e = y, t = await w.mutateAsync({
|
|
45
|
+
path: { product_id: y },
|
|
46
|
+
body: o(E)
|
|
47
|
+
});
|
|
48
|
+
l(t.type === "service" ? S.serviceUpdated : S.productUpdated, t.name), A.current.view === "edit" && A.current.selectedProductId === e && v("details");
|
|
32
49
|
return;
|
|
33
50
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
let e = await C.mutateAsync({ body: a(E) });
|
|
52
|
+
l(S.productCreated, e.name), v("none"), b(void 0);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
k(t(e, S));
|
|
55
|
+
}
|
|
56
|
+
}, [
|
|
57
|
+
E,
|
|
58
|
+
_,
|
|
59
|
+
y,
|
|
60
|
+
C,
|
|
61
|
+
w,
|
|
62
|
+
S,
|
|
63
|
+
v,
|
|
64
|
+
b
|
|
65
|
+
]);
|
|
66
|
+
return {
|
|
67
|
+
values: E,
|
|
68
|
+
errors: O,
|
|
69
|
+
pricePrefix: r(E.currency),
|
|
70
|
+
setValues: D,
|
|
71
|
+
isSubmitting: T,
|
|
72
|
+
isDirty: F,
|
|
73
|
+
openCreate: j,
|
|
74
|
+
openEdit: M,
|
|
75
|
+
cancelEdit: P,
|
|
76
|
+
close: N,
|
|
77
|
+
submit: I
|
|
60
78
|
};
|
|
61
79
|
}
|
|
62
80
|
//#endregion
|
|
63
|
-
export {
|
|
81
|
+
export { _ as useProductForm };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import "./index2.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { PRODUCT_FORM_SHEET_LABELS_EN as e, mergeProductFormSheetLabels as t } from "./index2.js";
|
|
2
|
+
import { ProductFormFields as n } from "./index3.js";
|
|
3
|
+
import { ProductFormSheet as r } from "./index4.js";
|
|
4
|
+
import { MeasureUnitsManager as i } from "./index5.js";
|
|
5
|
+
import { MeasureUnitDeleteDialog as a } from "./index6.js";
|
|
6
|
+
import { ProductSelector as o } from "./index7.js";
|
|
7
|
+
export { a as MeasureUnitDeleteDialog, i as MeasureUnitsManager, e as PRODUCT_FORM_SHEET_LABELS_EN, n as ProductFormFields, r as ProductFormSheet, o as ProductSelector, t as mergeProductFormSheetLabels };
|