@tesouro/embedded-components-react 0.5.194 → 0.5.195

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 (45) hide show
  1. package/README.md +1 -2
  2. package/dist/index.css +3 -3
  3. package/dist/index.d.ts +12 -3
  4. package/dist/index.js +1 -1
  5. package/dist/lib/ReceivablesWidget.d.ts +12 -3
  6. package/dist/lib/ReceivablesWidget.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +245 -65
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +66 -106
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +102 -223
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +225 -0
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +182 -371
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +401 -60
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +62 -193
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +184 -31
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +31 -149
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +292 -161
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +11 -3
  19. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index4.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index5.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index15.js +4 -1
  22. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +36 -36
  23. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index.js +12 -11
  25. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index10.js +16 -23
  26. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index11.js +7 -8
  27. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index12.js +17 -18
  28. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index13.js +36 -0
  29. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index3.js +43 -16
  30. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index4.js +23 -13
  31. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index5.js +13 -30
  32. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index6.js +18 -23
  33. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index7.js +22 -16
  34. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index8.js +22 -15
  35. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index9.js +10 -11
  36. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +10 -9
  37. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +5 -5
  38. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/ProductSelector.js +9 -13
  39. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useMeasureUnits.js +1 -1
  40. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +2 -2
  41. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductSelector.js +28 -41
  42. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index.js +6 -6
  43. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +7 -15
  44. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +100 -69
  45. package/package.json +1 -1
@@ -2,32 +2,38 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { deleteProductsId as e } from "../../../data-access/dist/lib/rest/sdk.gen.js";
5
+ import { patchProductsId as e } from "../../../data-access/dist/lib/rest/sdk.gen.js";
6
6
  import { invalidateAllClients as t } from "../../../data-access/dist/lib/clientRegistry.js";
7
7
  import { useEmbedApi as n } from "../../../data-access/dist/lib/EmbedApiContext.js";
8
8
  import { organizationHeaders as r } from "../../../data-access/dist/lib/organizationHeaders.js";
9
9
  import "../../../data-access/dist/index.js";
10
- import { productsInvalidationKey as i } from "./index4.js";
11
- import { useMutation as a } from "@tanstack/react-query";
10
+ import { productInvalidationKey as i, productsInvalidationKey as a } from "./index5.js";
11
+ import { useMutation as o } from "@tanstack/react-query";
12
12
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index7.js
13
- function o() {
14
- let { client: o, organizationId: s } = n();
15
- return a({
16
- mutationFn: async ({ path: t }) => {
17
- await e({
18
- client: o,
19
- headers: r(s),
13
+ function s() {
14
+ let { client: s, organizationId: c } = n();
15
+ return o({
16
+ mutationFn: async ({ path: t, body: n }) => {
17
+ let { data: i } = await e({
18
+ client: s,
19
+ headers: r(c),
20
20
  path: t,
21
+ body: n,
21
22
  throwOnError: !0
22
23
  });
24
+ return i;
23
25
  },
24
- onSuccess: async () => {
25
- await t(i({
26
- client: o,
27
- organizationId: s
28
- }));
26
+ onSuccess: async (e, n) => {
27
+ await Promise.all([t(a({
28
+ client: s,
29
+ organizationId: c
30
+ })), t(i({
31
+ client: s,
32
+ organizationId: c,
33
+ productId: n.path.product_id
34
+ }))]);
29
35
  }
30
36
  });
31
37
  }
32
38
  //#endregion
33
- export { o as useDeleteProductMutation };
39
+ export { s as useUpdateProductMutation };
@@ -2,25 +2,32 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { getMeasureUnitsOptions as e } from "../../../data-access/dist/lib/rest/@tanstack/react-query.gen.js";
6
- import { withAuthEpoch as t } from "../../../data-access/dist/lib/withAuthEpoch.js";
5
+ import { deleteProductsId as e } from "../../../data-access/dist/lib/rest/sdk.gen.js";
6
+ import { invalidateAllClients as t } from "../../../data-access/dist/lib/clientRegistry.js";
7
7
  import { useEmbedApi as n } from "../../../data-access/dist/lib/EmbedApiContext.js";
8
8
  import { organizationHeaders as r } from "../../../data-access/dist/lib/organizationHeaders.js";
9
9
  import "../../../data-access/dist/index.js";
10
- import { useQuery as i } from "@tanstack/react-query";
10
+ import { productsInvalidationKey as i } from "./index5.js";
11
+ import { useMutation as a } from "@tanstack/react-query";
11
12
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index8.js
12
- function a() {
13
- let { client: a, organizationId: o, widgetToken: s, authEpoch: c, organizationPending: l } = n(), u = !!(o && s), d = e({
14
- client: a,
15
- headers: r(o)
16
- });
17
- return i({
18
- ...t(d, {
19
- authEpoch: c,
20
- organizationPending: l
21
- }),
22
- enabled: u
13
+ function o() {
14
+ let { client: o, organizationId: s } = n();
15
+ return a({
16
+ mutationFn: async ({ path: t }) => {
17
+ await e({
18
+ client: o,
19
+ headers: r(s),
20
+ path: t,
21
+ throwOnError: !0
22
+ });
23
+ },
24
+ onSuccess: async () => {
25
+ await t(i({
26
+ client: o,
27
+ organizationId: s
28
+ }));
29
+ }
23
30
  });
24
31
  }
25
32
  //#endregion
26
- export { a as useMeasureUnitsQuery };
33
+ export { o as useDeleteProductMutation };
@@ -2,26 +2,25 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { getProductsOptions as e } from "../../../data-access/dist/lib/rest/@tanstack/react-query.gen.js";
5
+ import { getMeasureUnitsOptions as e } from "../../../data-access/dist/lib/rest/@tanstack/react-query.gen.js";
6
6
  import { withAuthEpoch as t } from "../../../data-access/dist/lib/withAuthEpoch.js";
7
7
  import { useEmbedApi as n } from "../../../data-access/dist/lib/EmbedApiContext.js";
8
8
  import { organizationHeaders as r } from "../../../data-access/dist/lib/organizationHeaders.js";
9
9
  import "../../../data-access/dist/index.js";
10
10
  import { useQuery as i } from "@tanstack/react-query";
11
11
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/data-access/dist/index9.js
12
- function a(a) {
13
- let { client: o, organizationId: s, widgetToken: c, authEpoch: l, organizationPending: u } = n(), d = !!(s && c && a), f = e({
14
- query: { measure_unit_id: a ?? "" },
15
- client: o,
16
- headers: r(s)
12
+ function a() {
13
+ let { client: a, organizationId: o, widgetToken: s, authEpoch: c, organizationPending: l } = n(), u = !!(o && s), d = e({
14
+ client: a,
15
+ headers: r(o)
17
16
  });
18
17
  return i({
19
- ...t(f, {
20
- authEpoch: l,
21
- organizationPending: u
18
+ ...t(d, {
19
+ authEpoch: c,
20
+ organizationPending: l
22
21
  }),
23
- enabled: d
22
+ enabled: u
24
23
  });
25
24
  }
26
25
  //#endregion
27
- export { a as useProductsByMeasureUnitQuery };
26
+ export { a as useMeasureUnitsQuery };
@@ -1,24 +1,25 @@
1
1
  import "../../../util/dist/lib/apiErrors.js";
2
2
  import { PRODUCT_MESSAGE_LABELS_EN as e } from "./lib/labels.js";
3
- import { EMPTY_PRODUCT_FORM_VALUES as t, buildProductDetailsView as n, buildProductRows as r, getCurrencyOptions as i, hasSelectedText as a } from "./lib/helpers.js";
4
- import { ProductFormSheet as o } from "../../ui/dist/index3.js";
3
+ import { buildProductDetailsView as t, buildProductRows as n, getCurrencyOptions as r, hasSelectedText as i } from "./lib/helpers.js";
4
+ import { ProductFormSheet as a } from "../../ui/dist/index3.js";
5
5
  import "../../ui/dist/index4.js";
6
6
  import "../../ui/dist/index5.js";
7
7
  import "../../ui/dist/index.js";
8
- import { useProductsQuery as s } from "../../data-access/dist/index2.js";
9
- import { useProductQuery as c } from "../../data-access/dist/index3.js";
10
- import "../../data-access/dist/index5.js";
8
+ import { useProductsQuery as o } from "../../data-access/dist/index2.js";
9
+ import "../../data-access/dist/index3.js";
10
+ import { useProductQuery as s } from "../../data-access/dist/index4.js";
11
11
  import "../../data-access/dist/index6.js";
12
- import { useDeleteProductMutation as l } from "../../data-access/dist/index7.js";
13
- import "../../data-access/dist/index8.js";
14
- import "../../data-access/dist/index9.js";
12
+ import "../../data-access/dist/index7.js";
13
+ import { useDeleteProductMutation as c } from "../../data-access/dist/index8.js";
14
+ import { useMeasureUnitsQuery as l } from "../../data-access/dist/index9.js";
15
15
  import "../../data-access/dist/index10.js";
16
16
  import "../../data-access/dist/index11.js";
17
17
  import "../../data-access/dist/index12.js";
18
+ import "../../data-access/dist/index13.js";
18
19
  import "../../data-access/dist/index.js";
19
20
  import { MeasureUnitsManagerContainer as u } from "./lib/MeasureUnitsManagerContainer.js";
20
21
  import { useMeasureUnits as d } from "./lib/useMeasureUnits.js";
21
22
  import { useProductForm as f } from "./lib/useProductForm.js";
22
23
  import "./lib/useProductSelector.js";
23
24
  import { ProductSelector as p } from "./lib/ProductSelector.js";
24
- export { t as EMPTY_PRODUCT_FORM_VALUES, u as MeasureUnitsManagerContainer, e as PRODUCT_MESSAGE_LABELS_EN, o as ProductFormSheet, p as ProductSelector, n as buildProductDetailsView, r as buildProductRows, i as getCurrencyOptions, a as hasSelectedText, l as useDeleteProductMutation, d as useMeasureUnits, f as useProductForm, c as useProductQuery, s as useProductsQuery };
25
+ export { u as MeasureUnitsManagerContainer, e as PRODUCT_MESSAGE_LABELS_EN, a as ProductFormSheet, p as ProductSelector, t as buildProductDetailsView, n as buildProductRows, r as getCurrencyOptions, i as hasSelectedText, c as useDeleteProductMutation, d as useMeasureUnits, l as useMeasureUnitsQuery, f as useProductForm, s as useProductQuery, o as useProductsQuery };
@@ -8,11 +8,11 @@ import { formatPrice as n, validateMeasureUnit as r } from "./helpers.js";
8
8
  import { MeasureUnitsManager as i } from "../../../ui/dist/index4.js";
9
9
  import { MeasureUnitDeleteDialog as a } from "../../../ui/dist/index5.js";
10
10
  import "../../../ui/dist/index.js";
11
- import { useMeasureUnitsQuery as o } from "../../../data-access/dist/index8.js";
12
- import { useProductsByMeasureUnitQuery as s } from "../../../data-access/dist/index9.js";
13
- import { useCreateMeasureUnitMutation as c } from "../../../data-access/dist/index10.js";
14
- import { useUpdateMeasureUnitMutation as l } from "../../../data-access/dist/index11.js";
15
- import { useDeleteMeasureUnitMutation as u } from "../../../data-access/dist/index12.js";
11
+ import { useMeasureUnitsQuery as o } from "../../../data-access/dist/index9.js";
12
+ import { useProductsByMeasureUnitQuery as s } from "../../../data-access/dist/index10.js";
13
+ import { useCreateMeasureUnitMutation as c } from "../../../data-access/dist/index11.js";
14
+ import { useUpdateMeasureUnitMutation as l } from "../../../data-access/dist/index12.js";
15
+ import { useDeleteMeasureUnitMutation as u } from "../../../data-access/dist/index13.js";
16
16
  import "../../../data-access/dist/index.js";
17
17
  import { useCallback as d, useMemo as f, useState as p } from "react";
18
18
  import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
@@ -7,20 +7,16 @@ import "../../../ui/dist/index.js";
7
7
  import { useProductSelector as t } from "./useProductSelector.js";
8
8
  import { jsx as n } from "react/jsx-runtime";
9
9
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/ProductSelector.js
10
- function r({ value: r, onValueChange: i, limit: a, debounceMs: o, type: s, disabled: c, onCreateClick: l, labels: u, typeLabels: d }) {
11
- let f = t({
12
- value: r,
13
- onValueChange: i,
14
- limit: a,
15
- debounceMs: o,
16
- type: s,
17
- typeLabels: d
18
- });
10
+ function r({ disabled: r, invalid: i, inputId: a, focusOnMount: o, maxLength: s, labels: c, ...l }) {
11
+ let u = t(l);
19
12
  return /* @__PURE__ */ n(e, {
20
- ...f,
21
- disabled: c,
22
- onCreateClick: l,
23
- labels: u
13
+ ...u,
14
+ disabled: r,
15
+ invalid: i,
16
+ inputId: a,
17
+ focusOnMount: o,
18
+ maxLength: s,
19
+ labels: c
24
20
  });
25
21
  }
26
22
  //#endregion
@@ -3,7 +3,7 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { buildUnitNamesById as e, buildUnitOptions as t } from "./helpers.js";
6
- import { useMeasureUnitsQuery as n } from "../../../data-access/dist/index8.js";
6
+ import { useMeasureUnitsQuery as n } from "../../../data-access/dist/index9.js";
7
7
  import "../../../data-access/dist/index.js";
8
8
  import { useMemo as r } from "react";
9
9
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useMeasureUnits.js
@@ -4,8 +4,8 @@
4
4
  "use client";
5
5
  import { extractApiErrorMessage as e } from "../../../../util/dist/lib/apiErrors.js";
6
6
  import { EMPTY_PRODUCT_FORM_VALUES as t, getCurrencyOptions as n, hasProductFormErrors as r, productFormValuesToRequest as i, productFormValuesToUpdateRequest as a, productToFormValues as o, validateProductForm as s } from "./helpers.js";
7
- import { useCreateProductMutation as c } from "../../../data-access/dist/index5.js";
8
- import { useUpdateProductMutation as l } from "../../../data-access/dist/index6.js";
7
+ import { useCreateProductMutation as c } from "../../../data-access/dist/index6.js";
8
+ import { useUpdateProductMutation as l } from "../../../data-access/dist/index7.js";
9
9
  import "../../../data-access/dist/index.js";
10
10
  import { useCallback as u, useMemo as d, useState as f } from "react";
11
11
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js
@@ -3,54 +3,41 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { formatPrice as e } from "./helpers.js";
6
- import { PRODUCT_TYPE_BADGE_LABELS_EN as t } from "../../../ui/dist/index2.js";
7
- import "../../../ui/dist/index.js";
8
- import { useProductsQuery as n } from "../../../data-access/dist/index2.js";
6
+ import { useAllProductsQuery as t } from "../../../data-access/dist/index3.js";
9
7
  import "../../../data-access/dist/index.js";
10
- import { useCallback as r, useEffect as i, useMemo as a, useState as o } from "react";
8
+ import { useMeasureUnits as n } from "./useMeasureUnits.js";
9
+ import { useCallback as r, useMemo as i } from "react";
11
10
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductSelector.js
12
- var s = 25, c = 300;
13
- function l(n, r) {
14
- let i = {
15
- ...t,
16
- ...r
17
- };
18
- return (n ?? []).map((t) => ({
11
+ function a(t, n = {}) {
12
+ return (t ?? []).map((t) => ({
19
13
  value: t.id,
20
14
  label: t.name,
21
- description: t.type === "service" ? i.service : i.product,
22
- meta: e(t.price)
15
+ meta: [e(t.price), t.measure_unit_id ? n[t.measure_unit_id] : ""].filter(Boolean).join(" ")
23
16
  }));
24
17
  }
25
- function u({ value: e, onValueChange: t, limit: u = s, debounceMs: d = c, type: f, typeLabels: p } = {}) {
26
- let [m, h] = o(e ?? ""), [g, _] = o(""), [v, y] = o("");
27
- i(() => {
28
- h(e ?? "");
29
- }, [e]), i(() => {
30
- let e = setTimeout(() => {
31
- y(g.trim());
32
- }, d);
33
- return () => clearTimeout(e);
34
- }, [d, g]);
35
- let b = n({
36
- limit: u,
37
- name__icontains: v || void 0,
38
- type: f
39
- }), x = a(() => l(b.data?.data, p), [b.data, p]), S = r((e) => {
40
- h(e), t?.(e);
41
- }, [t]), C = r(() => {
42
- b.refetch();
43
- }, [b]);
18
+ function o({ inputValue: e, onInputValueChange: o, onProductSelect: s, selectedProductId: c, currency: l }) {
19
+ let u = t({
20
+ currency: l || void 0,
21
+ enabled: !!l
22
+ }), { unitNamesById: d } = n(), f = i(() => [...u.data?.data ?? []].sort((e, t) => (e.name ?? "").localeCompare(t.name ?? "")), [u.data]), p = c ? f.find((e) => e.id === c) : void 0, m = i(() => {
23
+ let t = e.toLowerCase().trim();
24
+ return !t || p && p.name.toLowerCase() === t ? f : f.filter((e) => e.name.toLowerCase().includes(t));
25
+ }, [
26
+ e,
27
+ f,
28
+ p
29
+ ]), h = i(() => a(m, d), [m, d]), g = r((e) => {
30
+ let t = f.find((t) => t.id === e);
31
+ t && s(t);
32
+ }, [s, f]);
44
33
  return {
45
- value: m,
46
- options: x,
47
- searchValue: g,
48
- isLoading: b.isLoading,
49
- isError: b.isError,
50
- onSearchChange: _,
51
- onValueChange: S,
52
- onRetry: C
34
+ inputValue: e,
35
+ onInputValueChange: o,
36
+ options: h,
37
+ value: p?.id,
38
+ onOptionSelect: g,
39
+ isLoading: u.isLoading
53
40
  };
54
41
  }
55
42
  //#endregion
56
- export { l as buildProductSelectorOptions, u as useProductSelector };
43
+ export { a as buildProductSelectorOptions, o as useProductSelector };
@@ -1,6 +1,6 @@
1
- import { PRODUCT_TYPE_BADGE_LABELS_EN as e } from "./index2.js";
2
- import { ProductFormSheet as t } from "./index3.js";
3
- import { MeasureUnitsManager as n } from "./index4.js";
4
- import { MeasureUnitDeleteDialog as r } from "./index5.js";
5
- import { ProductSelector as i } from "./index6.js";
6
- export { r as MeasureUnitDeleteDialog, n as MeasureUnitsManager, e as PRODUCT_TYPE_BADGE_LABELS_EN, t as ProductFormSheet, i as ProductSelector };
1
+ import "./index2.js";
2
+ import { ProductFormSheet as e } from "./index3.js";
3
+ import { MeasureUnitsManager as t } from "./index4.js";
4
+ import { MeasureUnitDeleteDialog as n } from "./index5.js";
5
+ import { ProductSelector as r } from "./index6.js";
6
+ export { n as MeasureUnitDeleteDialog, t as MeasureUnitsManager, e as ProductFormSheet, r as ProductSelector };
@@ -1,8 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js
2
2
  var e = {
3
- product: "Product",
4
- service: "Service"
5
- }, t = {
6
3
  createTitle: "Add a product or service",
7
4
  headerDescription: "Save the products and services you sell so you can quickly add them as line items on invoices.",
8
5
  editTitle: "Edit {type}",
@@ -28,7 +25,7 @@ var e = {
28
25
  cancelButton: "Cancel",
29
26
  createButton: "Save {type}",
30
27
  saveButton: "Save"
31
- }, n = {
28
+ }, t = {
32
29
  title: "Manage measure units",
33
30
  hiddenDescription: "Create, edit, and delete measure units",
34
31
  searchPlaceholder: "Search",
@@ -43,7 +40,7 @@ var e = {
43
40
  saveAction: "Save unit",
44
41
  cancelAction: "Cancel edit",
45
42
  emptyText: "No measure units yet."
46
- }, r = {
43
+ }, n = {
47
44
  titleNoItems: "Delete “{name}” unit?",
48
45
  titleWithItems: "Delete “{name}” unit and associated items?",
49
46
  messageNoItems: "There are no items created with this measure unit.",
@@ -52,15 +49,10 @@ var e = {
52
49
  messageWithItemsHint: "Please, check the list of products and services that will get deleted:",
53
50
  confirmButton: "Delete",
54
51
  cancelButton: "Cancel"
55
- }, i = {
56
- fieldLabel: "Product or service",
57
- searchPlaceholder: "Search products and services",
58
- selectPlaceholder: "Select a product or service",
59
- loadingText: "Loading products...",
60
- emptyText: "No products found.",
61
- errorText: "Could not load products.",
62
- retryButton: "Retry",
63
- createButton: "Create product"
52
+ }, r = {
53
+ fieldLabel: "Item name",
54
+ placeholder: "e.g., Office supplies",
55
+ emptyText: "No saved items found - type to add an item"
64
56
  };
65
57
  //#endregion
66
- export { n as MEASURE_UNITS_MANAGER_LABELS_EN, r as MEASURE_UNIT_DELETE_DIALOG_LABELS_EN, t as PRODUCT_FORM_SHEET_LABELS_EN, i as PRODUCT_SELECTOR_LABELS_EN, e as PRODUCT_TYPE_BADGE_LABELS_EN };
58
+ export { t as MEASURE_UNITS_MANAGER_LABELS_EN, n as MEASURE_UNIT_DELETE_DIALOG_LABELS_EN, e as PRODUCT_FORM_SHEET_LABELS_EN, r as PRODUCT_SELECTOR_LABELS_EN };
@@ -1,76 +1,107 @@
1
- import { Button as e, Input as t, Label as n, Select as r, SelectContent as i, SelectItem as a, SelectTrigger as o, SelectValue as s } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { PRODUCT_SELECTOR_LABELS_EN as c } from "./index2.js";
3
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
4
- import { PlusIcon as d, RotateCwIcon as f, SearchIcon as p } from "lucide-react";
1
+ import { Input as e, cn as t } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { PRODUCT_SELECTOR_LABELS_EN as n } from "./index2.js";
3
+ import { useCallback as r, useId as i, useState as a } from "react";
4
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
+ import { CheckIcon as c, Loader2Icon as l } from "lucide-react";
5
6
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js
6
- function m({ value: m, options: h, searchValue: g, isLoading: _, isError: v, disabled: y, onSearchChange: b, onValueChange: x, onRetry: S, onCreateClick: C, labels: w }) {
7
- let T = {
8
- ...c,
9
- ...w
10
- }, E = h.length > 0;
11
- return /* @__PURE__ */ u("div", {
12
- className: "ttw:flex ttw:flex-col ttw:gap-2",
7
+ function u({ inputValue: u, onInputValueChange: d, options: f, value: p, onOptionSelect: m, isLoading: h, disabled: g, invalid: _, inputId: v, focusOnMount: y, maxLength: b, labels: x }) {
8
+ let S = {
9
+ ...n,
10
+ ...x
11
+ }, C = i(), [w, T] = a(!1), [E, D] = a(), O = f.findIndex((e) => e.value === E), k = () => {
12
+ T(!1), D(void 0);
13
+ }, A = (e) => {
14
+ m(e), k();
15
+ }, j = (e) => `${C}-option-${e}`, M = (e) => {
16
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
17
+ if (e.preventDefault(), T(!0), !f.length) return;
18
+ let t = e.key === "ArrowDown" ? Math.min(O + 1, f.length - 1) : Math.max(O - 1, 0);
19
+ D(f[t].value), document.getElementById(j(t))?.scrollIntoView?.({ block: "nearest" });
20
+ return;
21
+ }
22
+ if (e.key === "Enter") {
23
+ e.preventDefault();
24
+ let t = f[O];
25
+ w && t ? A(t.value) : k();
26
+ return;
27
+ }
28
+ if (e.key === "Tab" && w) {
29
+ let e = u.trim().toLowerCase();
30
+ if (!e) return;
31
+ let t = f.find((t) => t.label.toLowerCase() === e) ?? (f.length === 1 ? f[0] : void 0);
32
+ t ? A(t.value) : k();
33
+ return;
34
+ }
35
+ e.key === "Escape" && w && (e.stopPropagation(), k());
36
+ }, N = r((e) => {
37
+ e && y && e.focus();
38
+ }, [y]), P = w && O >= 0 ? j(O) : void 0;
39
+ return /* @__PURE__ */ s("div", {
40
+ className: "ttw:relative ttw:w-full",
13
41
  children: [
14
- /* @__PURE__ */ u("div", {
15
- className: "ttw:flex ttw:items-center ttw:justify-between ttw:gap-2",
16
- children: [/* @__PURE__ */ l(n, { children: T.fieldLabel }), C ? /* @__PURE__ */ u(e, {
17
- type: "button",
18
- variant: "ghost",
19
- size: "sm",
20
- onClick: C,
21
- disabled: y,
22
- children: [/* @__PURE__ */ l(d, { className: "ttw:size-4" }), T.createButton]
23
- }) : null]
42
+ h ? /* @__PURE__ */ o(l, { className: "ttw:pointer-events-none ttw:absolute ttw:left-3 ttw:top-1/2 ttw:size-4 ttw:-translate-y-1/2 ttw:animate-spin ttw:text-muted-foreground" }) : null,
43
+ /* @__PURE__ */ o(e, {
44
+ id: v,
45
+ role: "combobox",
46
+ "aria-label": S.fieldLabel,
47
+ "aria-autocomplete": "list",
48
+ "aria-expanded": w,
49
+ "aria-controls": C,
50
+ "aria-activedescendant": P,
51
+ "aria-invalid": _ || void 0,
52
+ autoComplete: "off",
53
+ ref: N,
54
+ maxLength: b,
55
+ disabled: g,
56
+ placeholder: S.placeholder,
57
+ className: t(h && "ttw:pl-9"),
58
+ value: u,
59
+ onFocus: () => T(!0),
60
+ onClick: () => T(!0),
61
+ onBlur: k,
62
+ onChange: (e) => {
63
+ d(e.target.value), T(!0), D(void 0);
64
+ },
65
+ onKeyDown: M
24
66
  }),
25
- /* @__PURE__ */ u("div", {
26
- className: "ttw:relative",
27
- children: [/* @__PURE__ */ l(p, { className: "ttw:pointer-events-none ttw:absolute ttw:left-3 ttw:top-1/2 ttw:size-4 ttw:-translate-y-1/2 ttw:text-muted-foreground" }), /* @__PURE__ */ l(t, {
28
- className: "ttw:pl-9",
29
- value: g,
30
- placeholder: T.searchPlaceholder,
31
- disabled: y,
32
- onChange: (e) => b(e.target.value)
33
- })]
34
- }),
35
- /* @__PURE__ */ u(r, {
36
- value: m || void 0,
37
- onValueChange: x,
38
- disabled: y || _ || v || !E,
39
- children: [/* @__PURE__ */ l(o, {
40
- className: "ttw:w-full",
41
- children: /* @__PURE__ */ l(s, { placeholder: T.selectPlaceholder })
42
- }), /* @__PURE__ */ l(i, { children: h.map((e) => /* @__PURE__ */ l(a, {
43
- value: e.value,
44
- children: /* @__PURE__ */ u("span", {
45
- className: "ttw:flex ttw:flex-col ttw:gap-0.5",
46
- children: [/* @__PURE__ */ l("span", { children: e.label }), e.description || e.meta ? /* @__PURE__ */ l("span", {
47
- className: "ttw:text-xs ttw:text-muted-foreground",
48
- children: [e.description, e.meta].filter(Boolean).join(" · ")
49
- }) : null]
50
- })
51
- }, e.value)) })]
52
- }),
53
- _ ? /* @__PURE__ */ l("p", {
54
- className: "ttw:text-sm ttw:text-muted-foreground",
55
- children: T.loadingText
56
- }) : v ? /* @__PURE__ */ u("div", {
57
- className: "ttw:flex ttw:items-center ttw:gap-2",
58
- children: [/* @__PURE__ */ l("p", {
59
- className: "ttw:text-sm ttw:text-destructive",
60
- children: T.errorText
61
- }), S ? /* @__PURE__ */ u(e, {
62
- type: "button",
63
- variant: "outline",
64
- size: "sm",
65
- onClick: S,
66
- children: [/* @__PURE__ */ l(f, { className: "ttw:size-4" }), T.retryButton]
67
- }) : null]
68
- }) : E ? null : /* @__PURE__ */ l("p", {
69
- className: "ttw:text-sm ttw:text-muted-foreground",
70
- children: T.emptyText
71
- })
67
+ w && !g ? /* @__PURE__ */ o("div", {
68
+ role: "presentation",
69
+ className: "ttw:absolute ttw:left-0 ttw:top-full ttw:z-50 ttw:mt-1 ttw:w-full ttw:min-w-138 ttw:overflow-hidden ttw:rounded-md ttw:border ttw:border-border ttw:bg-popover ttw:text-popover-foreground ttw:shadow-md",
70
+ onMouseDown: (e) => e.preventDefault(),
71
+ children: /* @__PURE__ */ s("ul", {
72
+ id: C,
73
+ role: "listbox",
74
+ "aria-label": S.fieldLabel,
75
+ className: "ttw:max-h-87 ttw:scroll-py-1 ttw:overflow-y-auto ttw:p-1",
76
+ children: [f.map((e, n) => /* @__PURE__ */ s("li", {
77
+ id: j(n),
78
+ role: "option",
79
+ "aria-selected": e.value === p,
80
+ className: t("ttw:relative ttw:flex ttw:w-full ttw:cursor-default ttw:items-center ttw:gap-2 ttw:rounded-sm ttw:py-1.5 ttw:pr-8 ttw:pl-2 ttw:text-sm ttw:select-none", n === O && "ttw:bg-accent ttw:text-accent-foreground"),
81
+ onMouseEnter: () => D(e.value),
82
+ onMouseDown: () => A(e.value),
83
+ children: [
84
+ /* @__PURE__ */ o("span", {
85
+ className: "ttw:min-w-0 ttw:flex-1 ttw:truncate",
86
+ children: e.label
87
+ }),
88
+ e.meta ? /* @__PURE__ */ o("span", {
89
+ className: "ttw:shrink-0 ttw:text-right ttw:text-xs ttw:text-muted-foreground",
90
+ children: e.meta
91
+ }) : null,
92
+ e.value === p ? /* @__PURE__ */ o("span", {
93
+ className: "ttw:pointer-events-none ttw:absolute ttw:right-2 ttw:flex ttw:size-4 ttw:items-center ttw:justify-center",
94
+ children: /* @__PURE__ */ o(c, { className: "ttw:size-4" })
95
+ }) : null
96
+ ]
97
+ }, e.value)), f.length ? null : /* @__PURE__ */ o("li", {
98
+ className: "ttw:py-2 ttw:text-center ttw:text-sm ttw:text-muted-foreground",
99
+ children: S.emptyText
100
+ })]
101
+ })
102
+ }) : null
72
103
  ]
73
104
  });
74
105
  }
75
106
  //#endregion
76
- export { m as ProductSelector, m as default };
107
+ export { u as ProductSelector, u as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.5.194",
3
+ "version": "0.5.195",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {