@tesouro/embedded-components-react 0.11.55 → 0.11.58
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 +2 -2
- package/dist/index.css +0 -21
- package/dist/index.d.ts +31 -6
- package/dist/lib/ProductsWidget.d.ts +30 -5
- package/dist/lib/ReceivablesWidget.d.ts +27 -5
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +99 -92
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductDelete.js +24 -21
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsWidget.js +79 -75
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/mocks/labels.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index2.js +9 -7
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index3.js +7 -9
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js +103 -118
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js +28 -50
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index6.js +118 -147
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index7.js +24 -27
- 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 +16 -14
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitCreateDialogContainer.js +38 -0
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +73 -123
- 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 +6 -2
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/labels.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useMeasureUnitForm.js +83 -0
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +17 -4
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index.js +6 -4
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +45 -17
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +121 -123
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +36 -61
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js +26 -194
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +115 -49
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js +62 -113
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index8.js +51 -0
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index9.js +117 -0
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/index.js +14 -14
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/StatePanel/NoAccessState.js +10 -2
- package/dist/packages/shared-ui-shadcn/dist/index.js +1648 -1526
- package/package.json +1 -1
|
@@ -5,33 +5,36 @@
|
|
|
5
5
|
import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
6
|
import { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib/apiErrors.js";
|
|
7
7
|
import "../../../../../shared/ui/dist/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { formatDeleteError as n } from "../../../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
9
|
+
import { toastSuccessWithName as r } from "../../../../../shared/product-catalog/feature/dist/lib/toasts.js";
|
|
10
|
+
import { useDeleteProductMutation as i } from "../../../../../shared/product-catalog/data-access/dist/index8.js";
|
|
9
11
|
import "../../../../../shared/product-catalog/feature/dist/index.js";
|
|
10
|
-
import { useCallback as
|
|
12
|
+
import { useCallback as a, useState as o } from "react";
|
|
11
13
|
// ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductDelete.js
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
e ||
|
|
15
|
-
}, []),
|
|
14
|
+
function s({ selectedProductId: s, productName: c, setSelectedProductId: l, setView: u, messages: d }) {
|
|
15
|
+
let f = i(), [p, m] = o(!1), h = a(() => m(!0), []), g = a((e) => {
|
|
16
|
+
e || m(!1);
|
|
17
|
+
}, []), _ = a(() => m(!1), []);
|
|
16
18
|
return {
|
|
17
|
-
open:
|
|
18
|
-
requestDelete:
|
|
19
|
-
onOpenChange:
|
|
20
|
-
confirm:
|
|
21
|
-
if (
|
|
22
|
-
await
|
|
23
|
-
} catch (
|
|
24
|
-
e.error(
|
|
19
|
+
open: p,
|
|
20
|
+
requestDelete: h,
|
|
21
|
+
onOpenChange: g,
|
|
22
|
+
confirm: a(async () => {
|
|
23
|
+
if (s) try {
|
|
24
|
+
await f.mutateAsync({ path: { product_id: s } }), r(d.productDeleted, c), m(!1), u("none"), l(void 0);
|
|
25
|
+
} catch (r) {
|
|
26
|
+
e.error(n(d.deleteProductError, c, t(r)));
|
|
25
27
|
}
|
|
26
28
|
}, [
|
|
27
|
-
a,
|
|
28
|
-
l,
|
|
29
|
-
c,
|
|
30
29
|
s,
|
|
31
|
-
|
|
30
|
+
c,
|
|
31
|
+
f,
|
|
32
|
+
d,
|
|
33
|
+
u,
|
|
34
|
+
l
|
|
32
35
|
]),
|
|
33
|
-
cancel:
|
|
34
|
-
isDeleting:
|
|
36
|
+
cancel: _,
|
|
37
|
+
isDeleting: f.isPending
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
|
-
export {
|
|
40
|
+
export { s as useProductDelete };
|
|
@@ -10,87 +10,91 @@ import { PRODUCT_FORM_SHEET_LABELS_EN as s } from "../../../../../shared/product
|
|
|
10
10
|
import { useMeasureUnits as c } from "../../../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
11
11
|
import { useProductForm as l } from "../../../../../shared/product-catalog/feature/dist/lib/useProductForm.js";
|
|
12
12
|
import "../../../../../shared/product-catalog/feature/dist/index.js";
|
|
13
|
-
import { getProductPermissions as
|
|
14
|
-
import { useProductDelete as
|
|
15
|
-
import { useProductDetails as
|
|
16
|
-
import { useProductsTable as
|
|
17
|
-
import { PRODUCTS_SCREEN_LABELS_EN as
|
|
13
|
+
import { getProductPermissions as ee } from "./permissions.js";
|
|
14
|
+
import { useProductDelete as u } from "./useProductDelete.js";
|
|
15
|
+
import { useProductDetails as d } from "./useProductDetails.js";
|
|
16
|
+
import { useProductsTable as f } from "./useProductsTable.js";
|
|
17
|
+
import { PRODUCTS_SCREEN_LABELS_EN as p } from "../../../../ui/dist/index2.js";
|
|
18
18
|
import "../../../../ui/dist/index.js";
|
|
19
|
-
import { useCallback as
|
|
19
|
+
import { useCallback as m, useMemo as h, useState as g } from "react";
|
|
20
20
|
// ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsWidget.js
|
|
21
|
-
function
|
|
22
|
-
let
|
|
21
|
+
function _({ messageLabels: _, screenLabels: v, formLabels: y }) {
|
|
22
|
+
let b = h(() => ({
|
|
23
23
|
...a,
|
|
24
|
+
..._
|
|
25
|
+
}), [_]), x = h(() => ({
|
|
26
|
+
...p,
|
|
24
27
|
...v
|
|
25
|
-
}), [v]), S =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
setView: N,
|
|
48
|
-
messages: x
|
|
28
|
+
}), [v]), { initResponse: S, widgetToken: C } = t(), w = i(), T = n(), E = r(), D = e(), O = h(() => ee(E ? void 0 : S?.scopes), [E, S?.scopes]), k = !(!C || S || T) || w && !S || E, A = !!T && (!S || E), [j, M] = g("none"), [N, P] = g(), [F, I] = g(!1), [L, R] = g(!1), z = c({ enabled: O.canRead }), B = f({
|
|
29
|
+
unitNamesById: z.unitNamesById,
|
|
30
|
+
unitOptions: z.unitOptions,
|
|
31
|
+
labels: x,
|
|
32
|
+
enabled: O.canRead
|
|
33
|
+
}), V = d({
|
|
34
|
+
selectedProductId: N,
|
|
35
|
+
unitNamesById: z.unitNamesById,
|
|
36
|
+
enabled: O.canRead
|
|
37
|
+
}), H = l({
|
|
38
|
+
view: j,
|
|
39
|
+
setView: M,
|
|
40
|
+
selectedProductId: N,
|
|
41
|
+
setSelectedProductId: P,
|
|
42
|
+
product: V.product,
|
|
43
|
+
messages: b
|
|
44
|
+
}), U = u({
|
|
45
|
+
selectedProductId: N,
|
|
46
|
+
productName: V.productName,
|
|
47
|
+
setSelectedProductId: P,
|
|
48
|
+
setView: M,
|
|
49
|
+
messages: b
|
|
49
50
|
});
|
|
50
|
-
if (!
|
|
51
|
-
let { canRead: e, canCreate: t, canUpdate: n, canDelete: r } =
|
|
52
|
-
!e && (
|
|
51
|
+
if (!E) {
|
|
52
|
+
let { canRead: e, canCreate: t, canUpdate: n, canDelete: r } = O;
|
|
53
|
+
!e && (j !== "none" || N) || j === "create" && !t ? (M("none"), P(void 0)) : j === "edit" && !n && M("details"), U.open && !(e && r) && U.cancel(), F && !(e && t) && I(!1), L && !(e && t) && R(!1);
|
|
53
54
|
}
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
}, [
|
|
57
|
-
|
|
58
|
-
}, [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} : void 0, { confirm: X } = H, Z = h(() => D ? void 0 : X(), [D, X]);
|
|
55
|
+
let W = m((e) => {
|
|
56
|
+
O.canRead && !o() && (P(e.id), M("details"));
|
|
57
|
+
}, [O.canRead]), G = m(() => {
|
|
58
|
+
O.canCreate && I(!0);
|
|
59
|
+
}, [O.canCreate]), K = m(() => I(!1), []), q = m(() => {
|
|
60
|
+
O.canCreate && R(!0);
|
|
61
|
+
}, [O.canCreate]), J = m(() => R(!1), []), { change: Y } = H, X = m((e) => Y({ unitId: e.id }), [Y]), { submit: Z } = H, Q = m(() => E ? void 0 : Z(), [E, Z]), te = (V.product?.type === "service" ? y?.typeService ?? s.typeService : y?.typeProduct ?? s.typeProduct).toLowerCase(), ne = j === "edit" ? {
|
|
62
|
+
heading: (y?.editingBanner ?? s.editingBanner).replace("{type}", te),
|
|
63
|
+
values: H.values,
|
|
64
|
+
errors: H.errors,
|
|
65
|
+
unitOptions: z.unitOptions,
|
|
66
|
+
pricePrefix: H.pricePrefix,
|
|
67
|
+
inProgress: H.isSubmitting || E,
|
|
68
|
+
onChange: H.change,
|
|
69
|
+
onSubmit: H.isDirty ? Q : H.cancelEdit,
|
|
70
|
+
onCancel: H.cancelEdit,
|
|
71
|
+
onAddUnit: O.canCreate ? q : void 0,
|
|
72
|
+
labels: y
|
|
73
|
+
} : void 0, { confirm: $ } = U, re = m(() => E ? void 0 : $(), [E, $]);
|
|
74
74
|
return {
|
|
75
|
-
view:
|
|
76
|
-
units:
|
|
77
|
-
table:
|
|
78
|
-
details:
|
|
79
|
-
form:
|
|
80
|
-
del:
|
|
81
|
-
permissions:
|
|
82
|
-
isPermissionLoading:
|
|
83
|
-
isTableLoading:
|
|
84
|
-
hasInitError:
|
|
85
|
-
refetchWidgetInit:
|
|
86
|
-
measureUnitsOpen:
|
|
87
|
-
actionsSuspended:
|
|
88
|
-
editForm:
|
|
89
|
-
handleRowClick:
|
|
90
|
-
openMeasureUnits:
|
|
91
|
-
closeMeasureUnits:
|
|
92
|
-
|
|
93
|
-
|
|
75
|
+
view: j,
|
|
76
|
+
units: z,
|
|
77
|
+
table: B,
|
|
78
|
+
details: V,
|
|
79
|
+
form: H,
|
|
80
|
+
del: U,
|
|
81
|
+
permissions: O,
|
|
82
|
+
isPermissionLoading: k,
|
|
83
|
+
isTableLoading: B.isLoading || k && B.rows.length === 0,
|
|
84
|
+
hasInitError: A,
|
|
85
|
+
refetchWidgetInit: D,
|
|
86
|
+
measureUnitsOpen: F,
|
|
87
|
+
actionsSuspended: E,
|
|
88
|
+
editForm: ne,
|
|
89
|
+
handleRowClick: W,
|
|
90
|
+
openMeasureUnits: G,
|
|
91
|
+
closeMeasureUnits: K,
|
|
92
|
+
addUnitOpen: L,
|
|
93
|
+
openAddUnit: q,
|
|
94
|
+
closeAddUnit: J,
|
|
95
|
+
selectAddedUnit: X,
|
|
96
|
+
submitForm: Q,
|
|
97
|
+
confirmDelete: re
|
|
94
98
|
};
|
|
95
99
|
}
|
|
96
|
-
export {
|
|
100
|
+
export { _ as useProductsWidget };
|
package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/mocks/labels.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
// ../../libs/tesouro-embedded-components-react/products-widget/feature/dist/mocks/labels.js
|
|
2
2
|
var e = {
|
|
3
3
|
blurbs: {
|
|
4
|
-
populated: "Eight products and services, one with no unit or price. Search by name, filter by type or unit, sort by name, or click a row to open it, then edit or delete it. Add product or service creates one, and Manage units of measure
|
|
5
|
-
empty: "The catalogue is empty, though the organization has units of measure. Press Add
|
|
4
|
+
populated: "Eight products and services, one with no unit or price. Search by name, filter by type or unit, sort by name, or click a row to open it, then edit or delete it. Add product or service creates one, and Manage units of measure lists the units: Add unit and each row’s Edit open a small form dialog, and Delete asks first. Changes last until you switch scenario.",
|
|
5
|
+
empty: "The catalogue is empty, though the organization has units of measure. Press Add product or service in the empty state, name it, pick a unit and a price, and save: it joins the list.",
|
|
6
6
|
loading: "The products read is held open, so the table skeleton stays on screen.",
|
|
7
|
-
error: "The products read fails with a 500, so the table shows
|
|
7
|
+
error: "The products read fails with a 500, so the table shows Couldn’t load products. Try again re-issues the read, which fails again.",
|
|
8
8
|
paginated: "Eighteen items at ten a page. The next and previous arrows follow the pagination token; a search, filter or new page size starts again from page one.",
|
|
9
9
|
"control-hidden": "The token has invoice:read:org but not invoice:write:org. The catalogue reads and every item opens, but Add product or service and Manage units of measure are disabled, and the sheet has neither an Edit button nor the actions menu that holds Delete."
|
|
10
10
|
},
|
|
11
11
|
scenarios: {
|
|
12
12
|
"access-restricted": {
|
|
13
13
|
label: "Access restricted",
|
|
14
|
-
blurb: "The token carries no invoice scope at all. The widget reads nothing past init and shows
|
|
14
|
+
blurb: "The token carries no invoice scope at all. The widget reads nothing past init and shows You don’t have access to products, Ask a company admin for access, with no table, filters or buttons."
|
|
15
15
|
},
|
|
16
16
|
"product-not-found": {
|
|
17
17
|
label: "Product not found",
|
|
18
|
-
blurb: "The list loads, but every item has since been deleted elsewhere: click a row and the sheet says
|
|
18
|
+
blurb: "The list loads, but every item has since been deleted elsewhere: click a row and the sheet says Couldn’t load product."
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
};
|
|
@@ -25,14 +25,14 @@ var n = {
|
|
|
25
25
|
unitFilterAll: "All units",
|
|
26
26
|
emptyTitle: "Build your products & services list.",
|
|
27
27
|
emptyDescription: "Save the products and services you sell so you can quickly add them as line items on invoices.",
|
|
28
|
-
emptyAction: "Add
|
|
28
|
+
emptyAction: "Add product or service",
|
|
29
29
|
filterEmptyTitle: "No product or service found",
|
|
30
30
|
filterEmptyDescription: "Try adjusting your search or filter criteria.",
|
|
31
|
-
errorTitle: "
|
|
32
|
-
errorDescription: "Something went wrong while
|
|
31
|
+
errorTitle: "Couldn't load products",
|
|
32
|
+
errorDescription: "Something went wrong while loading your products.",
|
|
33
33
|
errorRetry: "Try again",
|
|
34
|
-
accessRestrictedTitle: "
|
|
35
|
-
accessRestrictedDescription: "
|
|
34
|
+
accessRestrictedTitle: "You don't have access to products",
|
|
35
|
+
accessRestrictedDescription: "Ask a company admin for access.",
|
|
36
36
|
openRow: (e) => `View product — ${e}`,
|
|
37
37
|
typeBadge: {
|
|
38
38
|
product: "Product",
|
|
@@ -57,8 +57,10 @@ var n = {
|
|
|
57
57
|
deleteProductOption: "Delete {type}",
|
|
58
58
|
editButton: "Edit",
|
|
59
59
|
loadingTitle: "Loading…",
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
unavailableTitle: "Product details",
|
|
61
|
+
loadingLabel: "Loading product",
|
|
62
|
+
errorTitle: "Couldn't load product",
|
|
63
|
+
errorDescription: "It may have been deleted. Close this and pick another.",
|
|
62
64
|
typeBadge: {
|
|
63
65
|
product: "Product",
|
|
64
66
|
service: "Service"
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { Badge as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
2
2
|
import { PRODUCT_TYPE_BADGE_LABELS_EN as t } from "./index2.js";
|
|
3
3
|
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
-
import { twMerge as r } from "tailwind-merge";
|
|
5
4
|
// ../../libs/tesouro-embedded-components-react/products-widget/ui/dist/index3.js
|
|
6
|
-
function
|
|
7
|
-
let
|
|
5
|
+
function r({ type: r, labels: i }) {
|
|
6
|
+
let a = {
|
|
8
7
|
...t,
|
|
9
|
-
...
|
|
10
|
-
}
|
|
8
|
+
...i
|
|
9
|
+
};
|
|
11
10
|
return /* @__PURE__ */ n(e, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
children: s ? o.product : o.service
|
|
11
|
+
tone: "neutral",
|
|
12
|
+
children: r === "product" ? a.product : a.service
|
|
15
13
|
});
|
|
16
14
|
}
|
|
17
|
-
export {
|
|
15
|
+
export { r as ProductTypeBadge, r as default };
|