@tesouro/embedded-components-react 0.7.66 → 0.7.68
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 +3 -0
- package/dist/index.d.ts +10 -10
- package/dist/lib/ProductsWidget.d.ts +40 -10
- package/dist/lib/ReceivablesWidget.d.ts +9 -9
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/apiValidationErrors.js +34 -63
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +458 -457
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +0 -2
- 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/lib/helpers.js +33 -41
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/labels.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +42 -44
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +14 -13
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +128 -147
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +109 -92
- package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/apiValidationErrors.js +33 -0
- package/package.json +1 -1
|
@@ -72,13 +72,11 @@ function _({ pageSizeOptions: n = s, screenLabels: o, formLabels: _, detailsLabe
|
|
|
72
72
|
values: O.values,
|
|
73
73
|
errors: O.errors,
|
|
74
74
|
unitOptions: T.unitOptions,
|
|
75
|
-
currencyOptions: O.currencyOptions,
|
|
76
75
|
inProgress: O.isSubmitting || I,
|
|
77
76
|
onChange: (e) => O.setValues((t) => ({
|
|
78
77
|
...t,
|
|
79
78
|
...e
|
|
80
79
|
})),
|
|
81
|
-
onManageUnits: R,
|
|
82
80
|
onSubmit: B,
|
|
83
81
|
onCancel: O.close,
|
|
84
82
|
labels: _
|
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.68", n = "e699c3995375fcdb929a875f8fd98a07f2a785e4", r = Object.freeze({
|
|
3
3
|
library_name: e,
|
|
4
4
|
library_version: t,
|
|
5
5
|
library_sha: n
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { extractApiErrorMessage as e } from "../../../../util/dist/lib/apiErrors.js";
|
|
2
|
+
import { parseApiValidationErrors as t } from "../../../../util/dist/lib/apiValidationErrors.js";
|
|
3
|
+
import { PRODUCT_MESSAGE_LABELS_EN as n } from "./labels.js";
|
|
2
4
|
//#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js
|
|
3
|
-
var t = [
|
|
4
|
-
"USD",
|
|
5
|
-
"EUR",
|
|
6
|
-
"GBP",
|
|
7
|
-
"CAD",
|
|
8
|
-
"AUD",
|
|
9
|
-
"JPY",
|
|
10
|
-
"CHF",
|
|
11
|
-
"CNY",
|
|
12
|
-
"INR",
|
|
13
|
-
"BRL",
|
|
14
|
-
"MXN",
|
|
15
|
-
"SEK",
|
|
16
|
-
"NOK",
|
|
17
|
-
"DKK",
|
|
18
|
-
"NZD",
|
|
19
|
-
"SGD",
|
|
20
|
-
"HKD",
|
|
21
|
-
"ZAR",
|
|
22
|
-
"PLN",
|
|
23
|
-
"AED"
|
|
24
|
-
];
|
|
25
|
-
function n(e) {
|
|
26
|
-
return Array.from(/* @__PURE__ */ new Set([...t, ...e ? [e] : []])).sort().map((e) => ({
|
|
27
|
-
value: e,
|
|
28
|
-
label: e
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
5
|
function r(e) {
|
|
32
6
|
try {
|
|
33
7
|
return new Intl.NumberFormat("en-US", {
|
|
@@ -125,8 +99,8 @@ function h(e) {
|
|
|
125
99
|
type: e.type,
|
|
126
100
|
measure_unit_id: e.unitId || void 0,
|
|
127
101
|
price: t === "" ? void 0 : {
|
|
128
|
-
value: i(Number(t),
|
|
129
|
-
currency:
|
|
102
|
+
value: i(Number(t), "USD"),
|
|
103
|
+
currency: "USD"
|
|
130
104
|
},
|
|
131
105
|
description: e.description.trim() ? e.description.trim() : void 0
|
|
132
106
|
};
|
|
@@ -145,25 +119,43 @@ function g(e) {
|
|
|
145
119
|
};
|
|
146
120
|
}
|
|
147
121
|
var _ = 100, v = 255;
|
|
148
|
-
function y(
|
|
122
|
+
function y(e, t = n) {
|
|
149
123
|
let r = {};
|
|
150
|
-
|
|
151
|
-
let i =
|
|
124
|
+
e.name.trim().length === 0 ? r.name = t.nameRequired : e.name.trim().length > _ && (r.name = t.nameTooLong), e.type !== "product" && e.type !== "service" && (r.type = t.typeRequired);
|
|
125
|
+
let i = e.pricePerUnit.trim();
|
|
152
126
|
if (i !== "") {
|
|
153
127
|
let e = Number(i);
|
|
154
|
-
(!Number.isFinite(e) || e < 0) && (r.pricePerUnit =
|
|
128
|
+
(!Number.isFinite(e) || e < 0) && (r.pricePerUnit = t.priceInvalid);
|
|
129
|
+
}
|
|
130
|
+
return e.description.trim().length > v && (r.description = t.descriptionTooLong), r;
|
|
131
|
+
}
|
|
132
|
+
var b = {
|
|
133
|
+
name: "name",
|
|
134
|
+
type: "type",
|
|
135
|
+
description: "description",
|
|
136
|
+
"price.value": "pricePerUnit",
|
|
137
|
+
"price.currency": "pricePerUnit",
|
|
138
|
+
measure_unit_id: "unitId"
|
|
139
|
+
};
|
|
140
|
+
function x(r, i = n) {
|
|
141
|
+
let a = t(r);
|
|
142
|
+
if (!a.length) return { form: e(r) ?? i.genericError };
|
|
143
|
+
let o = {}, s = [];
|
|
144
|
+
for (let { path: e, msg: t } of a) {
|
|
145
|
+
let n = b[e];
|
|
146
|
+
n ? o[n] = t : s.push(t);
|
|
155
147
|
}
|
|
156
|
-
return
|
|
148
|
+
return s.length && (o.form = [...new Set(s)].join("; ")), o;
|
|
157
149
|
}
|
|
158
|
-
function
|
|
150
|
+
function S(e) {
|
|
159
151
|
return Object.values(e).some(Boolean);
|
|
160
152
|
}
|
|
161
|
-
function
|
|
162
|
-
return
|
|
153
|
+
function C(e, t = n) {
|
|
154
|
+
return e.name.trim().length === 0 ? t.unitNameRequired : void 0;
|
|
163
155
|
}
|
|
164
|
-
function
|
|
156
|
+
function w() {
|
|
165
157
|
let e = globalThis.getSelection?.();
|
|
166
158
|
return !!(e && e.toString().length > 0);
|
|
167
159
|
}
|
|
168
160
|
//#endregion
|
|
169
|
-
export { p as EMPTY_PRODUCT_FORM_VALUES, f as buildProductDetailsView, d as buildProductRows, l as buildUnitNamesById, u as buildUnitOptions, o as formatPrice, c as formatProductDate, a as fromMinorUnits,
|
|
161
|
+
export { p as EMPTY_PRODUCT_FORM_VALUES, x as apiErrorToProductFormErrors, f as buildProductDetailsView, d as buildProductRows, l as buildUnitNamesById, u as buildUnitOptions, o as formatPrice, c as formatProductDate, a as fromMinorUnits, S as hasProductFormErrors, w as hasSelectedText, h as productFormValuesToRequest, g as productFormValuesToUpdateRequest, m as productToFormValues, i as toMinorUnits, C as validateMeasureUnit, y as validateProductForm };
|
|
@@ -4,7 +4,6 @@ var e = {
|
|
|
4
4
|
nameTooLong: "Product name must be 100 characters or less",
|
|
5
5
|
typeRequired: "Product type is required",
|
|
6
6
|
priceInvalid: "Price per unit must be 0 or greater",
|
|
7
|
-
currencyRequired: "Currency is required",
|
|
8
7
|
descriptionTooLong: "Description must be 255 characters or less",
|
|
9
8
|
unitNameRequired: "Unit label is required",
|
|
10
9
|
genericError: "Something went wrong. Please try again.",
|
|
@@ -15,10 +14,10 @@ var e = {
|
|
|
15
14
|
serviceUpdated: "Service {name} was updated.",
|
|
16
15
|
productDeleted: "Product was deleted.",
|
|
17
16
|
deleteProductError: "Failed to delete product.",
|
|
18
|
-
measureUnitCreated: "Unit {name} was added to the list",
|
|
19
|
-
measureUnitUpdated: "Unit {name} was updated",
|
|
17
|
+
measureUnitCreated: "Unit {name} was added to the list.",
|
|
18
|
+
measureUnitUpdated: "Unit {name} was updated.",
|
|
20
19
|
measureUnitDeleted: "Unit {name} was deleted from the list.",
|
|
21
|
-
deleteMeasureUnitError: "Failed to delete
|
|
20
|
+
deleteMeasureUnitError: "Failed to delete measure unit."
|
|
22
21
|
};
|
|
23
22
|
//#endregion
|
|
24
23
|
export { e as PRODUCT_MESSAGE_LABELS_EN };
|
|
@@ -2,64 +2,62 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { useUpdateProductMutation as u } from "../../../data-access/dist/index7.js";
|
|
5
|
+
import { EMPTY_PRODUCT_FORM_VALUES as e, apiErrorToProductFormErrors as t, hasProductFormErrors as n, productFormValuesToRequest as r, productFormValuesToUpdateRequest as i, productToFormValues as a, validateProductForm as o } from "./helpers.js";
|
|
6
|
+
import { toastSuccessWithName as s } from "./toasts.js";
|
|
7
|
+
import { useCreateProductMutation as c } from "../../../data-access/dist/index6.js";
|
|
8
|
+
import { useUpdateProductMutation as l } from "../../../data-access/dist/index7.js";
|
|
10
9
|
import "../../../data-access/dist/index.js";
|
|
11
|
-
import { useCallback as
|
|
10
|
+
import { useCallback as u, useState as d } from "react";
|
|
12
11
|
//#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js
|
|
13
|
-
function
|
|
14
|
-
let
|
|
12
|
+
function f({ view: f, setView: p, selectedProductId: m, setSelectedProductId: h, product: g, messages: _ }) {
|
|
13
|
+
let v = c(), y = l(), b = v.isPending || y.isPending, [x, S] = d(e), [C, w] = d({});
|
|
15
14
|
return {
|
|
16
|
-
values:
|
|
17
|
-
errors:
|
|
18
|
-
setValues:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
E(t);
|
|
15
|
+
values: x,
|
|
16
|
+
errors: C,
|
|
17
|
+
setValues: S,
|
|
18
|
+
isSubmitting: b,
|
|
19
|
+
openCreate: u(() => {
|
|
20
|
+
h(void 0), S(e), w({}), p("create");
|
|
21
|
+
}, [h, p]),
|
|
22
|
+
openEdit: u(() => {
|
|
23
|
+
g && (S(a(g)), w({}), p("edit"));
|
|
24
|
+
}, [g, p]),
|
|
25
|
+
close: u(() => {
|
|
26
|
+
p("none"), h(void 0);
|
|
27
|
+
}, [h, p]),
|
|
28
|
+
submit: u(async () => {
|
|
29
|
+
let e = o(x, _);
|
|
30
|
+
if (n(e)) {
|
|
31
|
+
w(e);
|
|
34
32
|
return;
|
|
35
33
|
}
|
|
36
|
-
|
|
34
|
+
w({});
|
|
37
35
|
try {
|
|
38
|
-
if (
|
|
39
|
-
let e = await
|
|
40
|
-
path: { product_id:
|
|
41
|
-
body:
|
|
36
|
+
if (f === "edit" && m) {
|
|
37
|
+
let e = await y.mutateAsync({
|
|
38
|
+
path: { product_id: m },
|
|
39
|
+
body: i(x)
|
|
42
40
|
});
|
|
43
|
-
|
|
41
|
+
s(e.type === "service" ? _.serviceUpdated : _.productUpdated, e.name);
|
|
44
42
|
} else {
|
|
45
|
-
let e = await
|
|
46
|
-
|
|
43
|
+
let e = await v.mutateAsync({ body: r(x) });
|
|
44
|
+
s(_.productCreated, e.name);
|
|
47
45
|
}
|
|
48
|
-
|
|
49
|
-
} catch (
|
|
50
|
-
|
|
46
|
+
p("none"), h(void 0);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
w(t(e, _));
|
|
51
49
|
}
|
|
52
50
|
}, [
|
|
53
|
-
C,
|
|
54
|
-
m,
|
|
55
|
-
g,
|
|
56
|
-
b,
|
|
57
51
|
x,
|
|
52
|
+
f,
|
|
53
|
+
m,
|
|
54
|
+
v,
|
|
58
55
|
y,
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
_,
|
|
57
|
+
p,
|
|
58
|
+
h
|
|
61
59
|
])
|
|
62
60
|
};
|
|
63
61
|
}
|
|
64
62
|
//#endregion
|
|
65
|
-
export {
|
|
63
|
+
export { f as useProductForm };
|
package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { LABEL_LABELS_EN as e, REQUIRED_FIELDS_LEGEND_LABELS_EN as t } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
1
2
|
//#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js
|
|
2
|
-
var
|
|
3
|
+
var n = {
|
|
3
4
|
createTitle: "Add a product or service",
|
|
4
5
|
headerDescription: "Save the products and services you sell so you can quickly add them as line items on invoices.",
|
|
5
6
|
editTitle: "Edit {type}",
|
|
@@ -7,25 +8,25 @@ var e = {
|
|
|
7
8
|
nameLabel: "Name",
|
|
8
9
|
namePlaceholder: "e.g. House blend espresso beans",
|
|
9
10
|
descriptionLabel: "Description",
|
|
10
|
-
descriptionOptional: "(optional)",
|
|
11
11
|
descriptionPlaceholder: "e.g. 16oz whole bean, medium-dark roast, ground to order",
|
|
12
12
|
descriptionCount: "{count}/255 characters",
|
|
13
13
|
typeLabel: "Type",
|
|
14
14
|
typeProduct: "Product",
|
|
15
|
-
typeProductDescription: "A physical or digital item",
|
|
16
15
|
typeService: "Service",
|
|
17
|
-
typeServiceDescription: "Work or labor you provide",
|
|
18
16
|
unitLabel: "Unit",
|
|
19
17
|
unitPlaceholder: "Select a unit",
|
|
20
|
-
noUnit: "
|
|
21
|
-
|
|
18
|
+
noUnit: "None",
|
|
19
|
+
unitEmpty: "No units found",
|
|
20
|
+
unitClearAriaLabel: "Clear unit",
|
|
22
21
|
priceLabel: "Price per unit",
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
pricePrefix: "$",
|
|
23
|
+
pricePlaceholder: "0.00",
|
|
25
24
|
cancelButton: "Cancel",
|
|
26
25
|
createButton: "Save {type}",
|
|
27
|
-
saveButton: "Save"
|
|
28
|
-
|
|
26
|
+
saveButton: "Save",
|
|
27
|
+
fieldMarkers: e,
|
|
28
|
+
requiredFieldsLegend: t
|
|
29
|
+
}, r = {
|
|
29
30
|
title: "Manage measure units",
|
|
30
31
|
hiddenDescription: "Create, edit, and delete measure units",
|
|
31
32
|
searchPlaceholder: "Search",
|
|
@@ -41,7 +42,7 @@ var e = {
|
|
|
41
42
|
saveAction: "Save unit",
|
|
42
43
|
cancelAction: "Cancel edit",
|
|
43
44
|
emptyText: "No measure units yet."
|
|
44
|
-
},
|
|
45
|
+
}, i = {
|
|
45
46
|
titleNoItems: "Delete “{name}” unit?",
|
|
46
47
|
titleWithItems: "Delete “{name}” unit and associated items?",
|
|
47
48
|
messageNoItems: "There are no items created with this measure unit.",
|
|
@@ -50,11 +51,11 @@ var e = {
|
|
|
50
51
|
messageWithItemsHint: "Please, check the list of products and services that will get deleted:",
|
|
51
52
|
confirmButton: "Delete",
|
|
52
53
|
cancelButton: "Cancel"
|
|
53
|
-
},
|
|
54
|
+
}, a = {
|
|
54
55
|
fieldLabel: "Item name",
|
|
55
56
|
placeholder: "e.g., Office supplies",
|
|
56
57
|
emptyText: "No saved items found - type to add an item",
|
|
57
58
|
toggleListButton: "Show saved items"
|
|
58
59
|
};
|
|
59
60
|
//#endregion
|
|
60
|
-
export {
|
|
61
|
+
export { r as MEASURE_UNITS_MANAGER_LABELS_EN, i as MEASURE_UNIT_DELETE_DIALOG_LABELS_EN, n as PRODUCT_FORM_SHEET_LABELS_EN, a as PRODUCT_SELECTOR_LABELS_EN };
|