@tesouro/embedded-components-react 0.7.72 → 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.
Files changed (29) hide show
  1. package/README.md +1 -1
  2. package/dist/index.css +9 -0
  3. package/dist/index.d.ts +12 -6
  4. package/dist/lib/ProductsWidget.d.ts +12 -6
  5. package/dist/lib/ReceivablesWidget.d.ts +1 -5
  6. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +23 -24
  7. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/constants.js +6 -2
  8. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsTable.js +112 -51
  9. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsWidget.js +80 -56
  10. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index.js +6 -5
  11. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index2.js +15 -6
  12. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js +170 -135
  13. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js +49 -150
  14. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index6.js +152 -24
  15. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index7.js +28 -0
  16. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  17. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +13 -12
  18. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +2 -2
  19. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/ProductSelector.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js +41 -27
  21. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +70 -52
  22. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index.js +7 -6
  23. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +19 -8
  24. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +171 -218
  25. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +52 -180
  26. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js +188 -46
  27. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +47 -124
  28. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js +128 -0
  29. package/package.json +1 -1
@@ -1,128 +1,51 @@
1
- import { cn as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { PRODUCT_SELECTOR_LABELS_EN as t } from "./index2.js";
3
- import { useCallback as n, useId as r, useRef as i, useState as a } from "react";
4
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
- import { CheckIcon as c, ChevronDownIcon as l, Loader2Icon as u } from "lucide-react";
1
+ import { AlertDialog as e, AlertDialogContent as t, AlertDialogDescription as n, AlertDialogFooter as r, AlertDialogHeader as i, AlertDialogTitle as a, Button as o, Spinner as s, Table as c, TableBody as l, TableCell as u, TableRow as d } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { MEASURE_UNIT_DELETE_DIALOG_LABELS_EN as f } from "./index2.js";
3
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
6
4
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js
7
- function d({ inputValue: d, onInputValueChange: f, options: p, value: m, onOptionSelect: h, isLoading: g, disabled: _, invalid: v, inputId: y, focusOnMount: b, maxLength: x, labels: S }) {
8
- let C = {
9
- ...t,
10
- ...S
11
- }, w = r(), [T, E] = a(!1), [D, O] = a(), k = p.findIndex((e) => e.value === D), A = () => {
12
- E(!1), O(void 0);
13
- }, j = (e) => {
14
- h(e), A();
15
- }, M = (e) => `${w}-option-${e}`, N = (e) => {
16
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
17
- if (e.preventDefault(), E(!0), !p.length) return;
18
- let t = e.key === "ArrowDown" ? Math.min(k + 1, p.length - 1) : Math.max(k - 1, 0);
19
- O(p[t].value), document.getElementById(M(t))?.scrollIntoView?.({ block: "nearest" });
20
- return;
21
- }
22
- if (e.key === "Enter") {
23
- e.preventDefault();
24
- let t = p[k];
25
- T && t ? j(t.value) : A();
26
- return;
27
- }
28
- if (e.key === "Tab" && T) {
29
- let e = d.trim().toLowerCase();
30
- if (!e) return;
31
- let t = p.find((t) => t.label.toLowerCase() === e) ?? (p.length === 1 ? p[0] : void 0);
32
- t ? j(t.value) : A();
33
- return;
34
- }
35
- e.key === "Escape" && T && (e.stopPropagation(), A());
36
- }, P = i(null), F = n((e) => {
37
- P.current = e, e && b && e.focus();
38
- }, [b]), I = () => {
39
- if (T) {
40
- A();
41
- return;
42
- }
43
- P.current?.focus(), E(!0);
44
- }, L = T && k >= 0 ? M(k) : void 0;
45
- return /* @__PURE__ */ s("div", {
46
- className: "ttw:relative ttw:w-full",
47
- children: [/* @__PURE__ */ s("div", {
48
- className: e("ttw:flex ttw:h-9 ttw:w-full ttw:min-w-0 ttw:items-center ttw:rounded-md ttw:border ttw:border-input ttw:shadow-xs ttw:transition-[color,box-shadow] ttw:has-[input:focus-visible]:border-ring ttw:has-[input:focus-visible]:ring-[3px] ttw:has-[input:focus-visible]:ring-ring/50 ttw:has-[[aria-invalid=true]]:border-destructive", _ && "ttw:opacity-50"),
49
- children: [
50
- g ? /* @__PURE__ */ o(u, { className: "ttw:pointer-events-none ttw:ml-3 ttw:size-4 ttw:shrink-0 ttw:animate-spin ttw:text-muted-foreground" }) : null,
51
- /* @__PURE__ */ o("input", {
52
- id: y,
53
- role: "combobox",
54
- "aria-label": C.fieldLabel,
55
- "aria-autocomplete": "list",
56
- "aria-expanded": T,
57
- "aria-controls": w,
58
- "aria-activedescendant": L,
59
- "aria-invalid": v || void 0,
60
- autoComplete: "off",
61
- ref: F,
62
- maxLength: x,
63
- disabled: _,
64
- placeholder: C.placeholder,
65
- className: e("ttw:h-full ttw:min-w-0 ttw:flex-1 ttw:text-ellipsis ttw:bg-transparent ttw:pr-2 ttw:text-base ttw:outline-none ttw:placeholder:text-muted-foreground ttw:disabled:cursor-not-allowed ttw:md:text-sm", g ? "ttw:pl-2" : "ttw:pl-3"),
66
- value: d,
67
- title: d || void 0,
68
- onFocus: () => E(!0),
69
- onClick: () => E(!0),
70
- onBlur: A,
71
- onChange: (e) => {
72
- f(e.target.value), E(!0), O(void 0);
73
- },
74
- onKeyDown: N
75
- }),
76
- /* @__PURE__ */ o("button", {
77
- type: "button",
78
- tabIndex: -1,
79
- "aria-label": C.toggleListButton,
80
- "aria-controls": w,
81
- "aria-expanded": T,
82
- disabled: _,
83
- className: "ttw:mr-[0.3rem] ttw:flex ttw:size-6 ttw:shrink-0 ttw:cursor-pointer ttw:items-center ttw:justify-center ttw:rounded-[calc(var(--radius)-5px)] ttw:text-muted-foreground ttw:transition-all ttw:hover:bg-accent ttw:hover:text-accent-foreground ttw:disabled:pointer-events-none",
84
- onMouseDown: (e) => e.preventDefault(),
85
- onClick: I,
86
- children: /* @__PURE__ */ o(l, { className: "ttw:pointer-events-none ttw:size-4" })
87
- })
88
- ]
89
- }), T && !_ ? /* @__PURE__ */ o("div", {
90
- role: "presentation",
91
- className: e("ttw:absolute ttw:left-0 ttw:top-full ttw:z-50 ttw:mt-1.5 ttw:w-full ttw:min-w-138 ttw:overflow-hidden ttw:rounded-md ttw:bg-popover ttw:text-popover-foreground ttw:shadow-md ttw:ring-1 ttw:ring-foreground/10", !p.length && "ttw:pointer-events-none"),
92
- onMouseDown: p.length ? (e) => e.preventDefault() : void 0,
93
- children: /* @__PURE__ */ s("ul", {
94
- id: w,
95
- role: "listbox",
96
- "aria-label": C.fieldLabel,
97
- className: "ttw:max-h-87 ttw:scroll-py-1 ttw:overflow-y-auto ttw:p-1",
98
- children: [p.map((t, n) => /* @__PURE__ */ s("li", {
99
- id: M(n),
100
- role: "option",
101
- "aria-selected": t.value === m,
102
- className: e("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 === k && "ttw:bg-accent ttw:text-accent-foreground"),
103
- onMouseEnter: () => O(t.value),
104
- onMouseDown: () => j(t.value),
105
- children: [
106
- /* @__PURE__ */ o("span", {
107
- className: "ttw:min-w-0 ttw:flex-1 ttw:truncate",
108
- children: t.label
109
- }),
110
- t.meta ? /* @__PURE__ */ o("span", {
111
- className: "ttw:shrink-0 ttw:text-right ttw:text-xs ttw:text-muted-foreground",
112
- children: t.meta
113
- }) : null,
114
- t.value === m ? /* @__PURE__ */ o("span", {
115
- className: "ttw:pointer-events-none ttw:absolute ttw:right-2 ttw:flex ttw:size-4 ttw:items-center ttw:justify-center",
116
- children: /* @__PURE__ */ o(c, { className: "ttw:size-4" })
117
- }) : null
118
- ]
119
- }, t.value)), p.length ? null : /* @__PURE__ */ o("li", {
120
- className: "ttw:py-2 ttw:text-center ttw:text-sm ttw:text-muted-foreground",
121
- children: C.emptyText
122
- })]
123
- })
124
- }) : null]
5
+ function h({ open: h, onOpenChange: g, unitName: _, affectedProducts: v, isLoadingProducts: y, isDeleting: b, onConfirm: x, onCancel: S, labels: C }) {
6
+ let w = {
7
+ ...f,
8
+ ...C
9
+ }, T = v.length > 0;
10
+ return /* @__PURE__ */ p(e, {
11
+ open: h,
12
+ onOpenChange: g,
13
+ children: /* @__PURE__ */ m(t, { children: [
14
+ /* @__PURE__ */ m(i, { children: [/* @__PURE__ */ p(a, { children: (T ? w.titleWithItems : w.titleNoItems).replace("{name}", _) }), /* @__PURE__ */ p(n, { children: T ? w.messageWithItems : w.messageNoItems })] }),
15
+ /* @__PURE__ */ p("p", {
16
+ className: "ttw:text-sm ttw:text-muted-foreground",
17
+ children: T ? w.messageWithItemsHint : w.messageNoItemsHint
18
+ }),
19
+ y ? /* @__PURE__ */ p("div", {
20
+ className: "ttw:flex ttw:justify-center ttw:py-4",
21
+ children: /* @__PURE__ */ p(s, {})
22
+ }) : T ? /* @__PURE__ */ p("div", {
23
+ className: "ttw:max-h-60 ttw:overflow-auto ttw:rounded-md ttw:border",
24
+ children: /* @__PURE__ */ p(c, { children: /* @__PURE__ */ p(l, { children: v.map((e) => /* @__PURE__ */ m(d, {
25
+ className: "ttw:border-border ttw:hover:bg-transparent",
26
+ children: [/* @__PURE__ */ p(u, {
27
+ className: "ttw:pl-0 ttw:whitespace-normal ttw:text-text ttw:font-medium",
28
+ children: e.name
29
+ }), /* @__PURE__ */ p(u, {
30
+ className: "ttw:pr-0 ttw:text-right ttw:text-text ttw:font-medium",
31
+ children: e.priceLabel
32
+ })]
33
+ }, e.id)) }) })
34
+ }) : null,
35
+ /* @__PURE__ */ m(r, { children: [/* @__PURE__ */ p(o, {
36
+ variant: "ghost",
37
+ onClick: S,
38
+ disabled: b,
39
+ children: w.cancelButton
40
+ }), /* @__PURE__ */ p(o, {
41
+ variant: "destructive",
42
+ onClick: x,
43
+ disabled: b || y,
44
+ loading: b,
45
+ children: w.confirmButton
46
+ })] })
47
+ ] })
125
48
  });
126
49
  }
127
50
  //#endregion
128
- export { d as ProductSelector, d as default };
51
+ export { h as MeasureUnitDeleteDialog, h as default };
@@ -0,0 +1,128 @@
1
+ import { cn as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { PRODUCT_SELECTOR_LABELS_EN as t } from "./index2.js";
3
+ import { useCallback as n, useId as r, useRef as i, useState as a } from "react";
4
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
+ import { CheckIcon as c, ChevronDownIcon as l, Loader2Icon as u } from "lucide-react";
6
+ //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js
7
+ function d({ inputValue: d, onInputValueChange: f, options: p, value: m, onOptionSelect: h, isLoading: g, disabled: _, invalid: v, inputId: y, focusOnMount: b, maxLength: x, labels: S }) {
8
+ let C = {
9
+ ...t,
10
+ ...S
11
+ }, w = r(), [T, E] = a(!1), [D, O] = a(), k = p.findIndex((e) => e.value === D), A = () => {
12
+ E(!1), O(void 0);
13
+ }, j = (e) => {
14
+ h(e), A();
15
+ }, M = (e) => `${w}-option-${e}`, N = (e) => {
16
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
17
+ if (e.preventDefault(), E(!0), !p.length) return;
18
+ let t = e.key === "ArrowDown" ? Math.min(k + 1, p.length - 1) : Math.max(k - 1, 0);
19
+ O(p[t].value), document.getElementById(M(t))?.scrollIntoView?.({ block: "nearest" });
20
+ return;
21
+ }
22
+ if (e.key === "Enter") {
23
+ e.preventDefault();
24
+ let t = p[k];
25
+ T && t ? j(t.value) : A();
26
+ return;
27
+ }
28
+ if (e.key === "Tab" && T) {
29
+ let e = d.trim().toLowerCase();
30
+ if (!e) return;
31
+ let t = p.find((t) => t.label.toLowerCase() === e) ?? (p.length === 1 ? p[0] : void 0);
32
+ t ? j(t.value) : A();
33
+ return;
34
+ }
35
+ e.key === "Escape" && T && (e.stopPropagation(), A());
36
+ }, P = i(null), F = n((e) => {
37
+ P.current = e, e && b && e.focus();
38
+ }, [b]), I = () => {
39
+ if (T) {
40
+ A();
41
+ return;
42
+ }
43
+ P.current?.focus(), E(!0);
44
+ }, L = T && k >= 0 ? M(k) : void 0;
45
+ return /* @__PURE__ */ s("div", {
46
+ className: "ttw:relative ttw:w-full",
47
+ children: [/* @__PURE__ */ s("div", {
48
+ className: e("ttw:flex ttw:h-9 ttw:w-full ttw:min-w-0 ttw:items-center ttw:rounded-md ttw:border ttw:border-input ttw:shadow-xs ttw:transition-[color,box-shadow] ttw:has-[input:focus-visible]:border-ring ttw:has-[input:focus-visible]:ring-[3px] ttw:has-[input:focus-visible]:ring-ring/50 ttw:has-[[aria-invalid=true]]:border-destructive", _ && "ttw:opacity-50"),
49
+ children: [
50
+ g ? /* @__PURE__ */ o(u, { className: "ttw:pointer-events-none ttw:ml-3 ttw:size-4 ttw:shrink-0 ttw:animate-spin ttw:text-muted-foreground" }) : null,
51
+ /* @__PURE__ */ o("input", {
52
+ id: y,
53
+ role: "combobox",
54
+ "aria-label": C.fieldLabel,
55
+ "aria-autocomplete": "list",
56
+ "aria-expanded": T,
57
+ "aria-controls": w,
58
+ "aria-activedescendant": L,
59
+ "aria-invalid": v || void 0,
60
+ autoComplete: "off",
61
+ ref: F,
62
+ maxLength: x,
63
+ disabled: _,
64
+ placeholder: C.placeholder,
65
+ className: e("ttw:h-full ttw:min-w-0 ttw:flex-1 ttw:text-ellipsis ttw:bg-transparent ttw:pr-2 ttw:text-base ttw:outline-none ttw:placeholder:text-muted-foreground ttw:disabled:cursor-not-allowed ttw:md:text-sm", g ? "ttw:pl-2" : "ttw:pl-3"),
66
+ value: d,
67
+ title: d || void 0,
68
+ onFocus: () => E(!0),
69
+ onClick: () => E(!0),
70
+ onBlur: A,
71
+ onChange: (e) => {
72
+ f(e.target.value), E(!0), O(void 0);
73
+ },
74
+ onKeyDown: N
75
+ }),
76
+ /* @__PURE__ */ o("button", {
77
+ type: "button",
78
+ tabIndex: -1,
79
+ "aria-label": C.toggleListButton,
80
+ "aria-controls": w,
81
+ "aria-expanded": T,
82
+ disabled: _,
83
+ className: "ttw:mr-[0.3rem] ttw:flex ttw:size-6 ttw:shrink-0 ttw:cursor-pointer ttw:items-center ttw:justify-center ttw:rounded-[calc(var(--radius)-5px)] ttw:text-muted-foreground ttw:transition-all ttw:hover:bg-accent ttw:hover:text-accent-foreground ttw:disabled:pointer-events-none",
84
+ onMouseDown: (e) => e.preventDefault(),
85
+ onClick: I,
86
+ children: /* @__PURE__ */ o(l, { className: "ttw:pointer-events-none ttw:size-4" })
87
+ })
88
+ ]
89
+ }), T && !_ ? /* @__PURE__ */ o("div", {
90
+ role: "presentation",
91
+ className: e("ttw:absolute ttw:left-0 ttw:top-full ttw:z-50 ttw:mt-1.5 ttw:w-full ttw:min-w-138 ttw:overflow-hidden ttw:rounded-md ttw:bg-popover ttw:text-popover-foreground ttw:shadow-md ttw:ring-1 ttw:ring-foreground/10", !p.length && "ttw:pointer-events-none"),
92
+ onMouseDown: p.length ? (e) => e.preventDefault() : void 0,
93
+ children: /* @__PURE__ */ s("ul", {
94
+ id: w,
95
+ role: "listbox",
96
+ "aria-label": C.fieldLabel,
97
+ className: "ttw:max-h-87 ttw:scroll-py-1 ttw:overflow-y-auto ttw:p-1",
98
+ children: [p.map((t, n) => /* @__PURE__ */ s("li", {
99
+ id: M(n),
100
+ role: "option",
101
+ "aria-selected": t.value === m,
102
+ className: e("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 === k && "ttw:bg-accent ttw:text-accent-foreground"),
103
+ onMouseEnter: () => O(t.value),
104
+ onMouseDown: () => j(t.value),
105
+ children: [
106
+ /* @__PURE__ */ o("span", {
107
+ className: "ttw:min-w-0 ttw:flex-1 ttw:truncate",
108
+ children: t.label
109
+ }),
110
+ t.meta ? /* @__PURE__ */ o("span", {
111
+ className: "ttw:shrink-0 ttw:text-right ttw:text-xs ttw:text-muted-foreground",
112
+ children: t.meta
113
+ }) : null,
114
+ t.value === m ? /* @__PURE__ */ o("span", {
115
+ className: "ttw:pointer-events-none ttw:absolute ttw:right-2 ttw:flex ttw:size-4 ttw:items-center ttw:justify-center",
116
+ children: /* @__PURE__ */ o(c, { className: "ttw:size-4" })
117
+ }) : null
118
+ ]
119
+ }, t.value)), p.length ? null : /* @__PURE__ */ o("li", {
120
+ className: "ttw:py-2 ttw:text-center ttw:text-sm ttw:text-muted-foreground",
121
+ children: C.emptyText
122
+ })]
123
+ })
124
+ }) : null]
125
+ });
126
+ }
127
+ //#endregion
128
+ export { d as ProductSelector, d as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.7.72",
3
+ "version": "0.7.73",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [