@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
@@ -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 { useDeleteProductMutation as n } from "../../../../../shared/product-catalog/data-access/dist/index8.js";
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 r, useState as i } from "react";
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 a({ selectedProductId: a, setSelectedProductId: o, setView: s, messages: c }) {
13
- let l = n(), [u, d] = i(!1), f = r(() => d(!0), []), p = r((e) => {
14
- e || d(!1);
15
- }, []), m = r(() => d(!1), []);
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: u,
18
- requestDelete: f,
19
- onOpenChange: p,
20
- confirm: r(async () => {
21
- if (a) try {
22
- await l.mutateAsync({ path: { product_id: a } }), e.success(c.productDeleted), d(!1), s("none"), o(void 0);
23
- } catch (n) {
24
- e.error(t(n) ?? c.deleteProductError);
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
- o
30
+ c,
31
+ f,
32
+ d,
33
+ u,
34
+ l
32
35
  ]),
33
- cancel: m,
34
- isDeleting: l.isPending
36
+ cancel: _,
37
+ isDeleting: f.isPending
35
38
  };
36
39
  }
37
- export { a as useProductDelete };
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 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";
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 h, useMemo as g, useState as _ } from "react";
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 v({ messageLabels: v, screenLabels: y, formLabels: b }) {
22
- let x = g(() => ({
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 = 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
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 (!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);
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 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]);
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: 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
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 { v as useProductsWidget };
100
+ export { _ as useProductsWidget };
@@ -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 adds units and renames or deletes them from each row’s actions menu. Changes last until you switch scenario.",
5
- empty: "The catalogue is empty, though the organization has units of measure. Press Add your first product or service, name it, pick a unit and a price, and save: it joins the list.",
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 Failed to load products. Try again re-issues the read, which fails again.",
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 Access restricted, You don’t have permission to view products, with no table, filters or buttons."
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 Product not found."
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 your first product or service",
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: "Failed to load products",
32
- errorDescription: "Something went wrong while fetching your products. Please try again.",
31
+ errorTitle: "Couldn't load products",
32
+ errorDescription: "Something went wrong while loading your products.",
33
33
  errorRetry: "Try again",
34
- accessRestrictedTitle: "Access restricted",
35
- accessRestrictedDescription: "You don't have permission to view products.",
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
- errorTitle: "Product not found",
61
- errorDescription: "We could not load this product. Please try again.",
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 i({ type: i, labels: a }) {
7
- let o = {
5
+ function r({ type: r, labels: i }) {
6
+ let a = {
8
7
  ...t,
9
- ...a
10
- }, s = i === "product";
8
+ ...i
9
+ };
11
10
  return /* @__PURE__ */ n(e, {
12
- variant: "secondary",
13
- className: r(s ? "ttw:bg-blue-100 ttw:text-blue-700" : "ttw:bg-pink-100 ttw:text-pink-700"),
14
- children: s ? o.product : o.service
11
+ tone: "neutral",
12
+ children: r === "product" ? a.product : a.service
15
13
  });
16
14
  }
17
- export { i as ProductTypeBadge, i as default };
15
+ export { r as ProductTypeBadge, r as default };