@tesouro/embedded-components-react 0.7.72 → 0.7.74
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 +9 -0
- package/dist/index.d.ts +12 -6
- package/dist/lib/ProductsWidget.d.ts +12 -6
- package/dist/lib/ReceivablesWidget.d.ts +1 -5
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +23 -24
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/constants.js +6 -2
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsTable.js +112 -51
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsWidget.js +80 -56
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index.js +6 -5
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index2.js +15 -6
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js +170 -135
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js +49 -150
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index6.js +152 -24
- package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index7.js +28 -0
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/labels.js +1 -2
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/policyViewModel.js +8 -9
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApprovalPolicyRules.js +127 -141
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/util/dist/lib/validatePolicyDraft.js +1 -1
- 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 +13 -12
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +2 -2
- 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 +41 -27
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +70 -52
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index.js +7 -6
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +19 -8
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +171 -218
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +52 -180
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js +188 -46
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +47 -124
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js +128 -0
- package/package.json +1 -1
package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js
CHANGED
|
@@ -1,51 +1,193 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { jsx as
|
|
1
|
+
import { Button as e, DropdownMenu as t, DropdownMenuContent as n, DropdownMenuItem as r, DropdownMenuTrigger as i, Input as a, InputGroup as o, InputGroupInput as s, Sheet as c, SheetContent as l, SheetDescription as u, SheetFooter as d, SheetHeader as f, SheetTitle as p, Table as m, TableBody as h, TableCell as g, TableHead as _, TableHeader as v, TableRow as y } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
2
|
+
import { MEASURE_UNITS_MANAGER_LABELS_EN as b } from "./index2.js";
|
|
3
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
4
|
+
import { CheckIcon as C, MoreVerticalIcon as w, PencilIcon as T, Trash2Icon as E, XIcon as D } from "lucide-react";
|
|
4
5
|
//#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
...
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
6
|
+
var O = "—";
|
|
7
|
+
function k({ open: k, onOpenChange: A, units: j, isLoading: M, searchValue: N, onSearchChange: P, createValues: F, createError: I, onCreateChange: L, onCreateSubmit: R, isCreating: z, editingUnitId: B, editValues: V, editError: H, onEditStart: U, onEditChange: W, onEditSubmit: G, onEditCancel: K, isUpdating: q, onDeleteClick: J, onDone: Y, labels: X }) {
|
|
8
|
+
let Z = {
|
|
9
|
+
...b,
|
|
10
|
+
...X
|
|
11
|
+
};
|
|
12
|
+
return /* @__PURE__ */ x(c, {
|
|
13
|
+
open: k,
|
|
14
|
+
onOpenChange: A,
|
|
15
|
+
children: /* @__PURE__ */ S(l, {
|
|
16
|
+
className: "ttw:w-150 ttw:sm:max-w-150 ttw:gap-0 ttw:p-0",
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ S(f, {
|
|
19
|
+
className: "ttw:border-b ttw:border-border",
|
|
20
|
+
children: [/* @__PURE__ */ x(p, { children: Z.title }), /* @__PURE__ */ x(u, {
|
|
21
|
+
className: "ttw:sr-only",
|
|
22
|
+
children: Z.hiddenDescription
|
|
32
23
|
})]
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
24
|
+
}),
|
|
25
|
+
/* @__PURE__ */ S("div", {
|
|
26
|
+
className: "ttw:flex-1 ttw:flex ttw:flex-col ttw:gap-4 ttw:overflow-y-auto ttw:px-6 ttw:py-4",
|
|
27
|
+
children: [/* @__PURE__ */ x(o, { children: /* @__PURE__ */ x(s, {
|
|
28
|
+
placeholder: Z.searchPlaceholder,
|
|
29
|
+
value: N,
|
|
30
|
+
onChange: (e) => P(e.target.value)
|
|
31
|
+
}) }), /* @__PURE__ */ S(m, {
|
|
32
|
+
className: "ttw:table-fixed ttw:border ttw:border-border ttw:rounded-md",
|
|
33
|
+
children: [/* @__PURE__ */ x(v, { children: /* @__PURE__ */ S(y, {
|
|
34
|
+
className: "ttw:hover:bg-transparent ttw:border-border",
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ x(_, {
|
|
37
|
+
className: "ttw:w-[30%]",
|
|
38
|
+
children: Z.columnLabel
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ x(_, {
|
|
41
|
+
className: "ttw:w-[50%]",
|
|
42
|
+
children: Z.columnDescription
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ x(_, { className: "ttw:w-[20%]" })
|
|
45
|
+
]
|
|
46
|
+
}) }), /* @__PURE__ */ S(h, { children: [
|
|
47
|
+
/* @__PURE__ */ S(y, {
|
|
48
|
+
className: "ttw:hover:bg-transparent ttw:border-border",
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ S(g, {
|
|
51
|
+
className: "ttw:align-top",
|
|
52
|
+
children: [/* @__PURE__ */ x(a, {
|
|
53
|
+
placeholder: Z.namePlaceholder,
|
|
54
|
+
value: F.name,
|
|
55
|
+
"aria-invalid": !!I,
|
|
56
|
+
disabled: z,
|
|
57
|
+
className: "ttw:h-8",
|
|
58
|
+
onChange: (e) => L({ name: e.target.value })
|
|
59
|
+
}), I && /* @__PURE__ */ x("p", {
|
|
60
|
+
className: "ttw:mt-1 ttw:text-sm ttw:text-destructive",
|
|
61
|
+
children: I
|
|
62
|
+
})]
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ x(g, {
|
|
65
|
+
className: "ttw:align-top",
|
|
66
|
+
children: /* @__PURE__ */ x(a, {
|
|
67
|
+
placeholder: Z.descriptionPlaceholder,
|
|
68
|
+
value: F.description,
|
|
69
|
+
disabled: z,
|
|
70
|
+
className: "ttw:h-8",
|
|
71
|
+
onChange: (e) => L({ description: e.target.value })
|
|
72
|
+
})
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ x(g, {
|
|
75
|
+
className: "ttw:align-top ttw:text-right",
|
|
76
|
+
children: /* @__PURE__ */ x(e, {
|
|
77
|
+
variant: "secondary",
|
|
78
|
+
size: "sm",
|
|
79
|
+
onClick: R,
|
|
80
|
+
disabled: z,
|
|
81
|
+
children: Z.addButton
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
}),
|
|
86
|
+
M ? null : j.map((o) => B === o.id ? /* @__PURE__ */ S(y, {
|
|
87
|
+
className: "ttw:hover:bg-transparent ttw:border-border",
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ S(g, {
|
|
90
|
+
className: "ttw:align-top",
|
|
91
|
+
children: [/* @__PURE__ */ x(a, {
|
|
92
|
+
value: V.name,
|
|
93
|
+
"aria-invalid": !!H,
|
|
94
|
+
disabled: q,
|
|
95
|
+
className: "ttw:h-8",
|
|
96
|
+
onChange: (e) => W({ name: e.target.value })
|
|
97
|
+
}), H && /* @__PURE__ */ x("p", {
|
|
98
|
+
className: "ttw:mt-1 ttw:text-sm ttw:text-destructive",
|
|
99
|
+
children: H
|
|
100
|
+
})]
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ x(g, {
|
|
103
|
+
className: "ttw:align-top",
|
|
104
|
+
children: /* @__PURE__ */ x(a, {
|
|
105
|
+
value: V.description,
|
|
106
|
+
disabled: q,
|
|
107
|
+
className: "ttw:h-8",
|
|
108
|
+
onChange: (e) => W({ description: e.target.value })
|
|
109
|
+
})
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ x(g, {
|
|
112
|
+
className: "ttw:align-top",
|
|
113
|
+
children: /* @__PURE__ */ S("div", {
|
|
114
|
+
className: "ttw:flex ttw:justify-end ttw:gap-1",
|
|
115
|
+
children: [/* @__PURE__ */ x(e, {
|
|
116
|
+
variant: "outline",
|
|
117
|
+
size: "icon",
|
|
118
|
+
"aria-label": Z.saveAction,
|
|
119
|
+
onClick: G,
|
|
120
|
+
disabled: q,
|
|
121
|
+
className: "ttw:size-8 ttw:border-border",
|
|
122
|
+
children: /* @__PURE__ */ x(C, { className: "ttw:size-4" })
|
|
123
|
+
}), /* @__PURE__ */ x(e, {
|
|
124
|
+
variant: "outline",
|
|
125
|
+
size: "icon",
|
|
126
|
+
"aria-label": Z.cancelAction,
|
|
127
|
+
onClick: K,
|
|
128
|
+
disabled: q,
|
|
129
|
+
className: "ttw:size-8 ttw:border-border",
|
|
130
|
+
children: /* @__PURE__ */ x(D, { className: "ttw:size-4" })
|
|
131
|
+
})]
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
}, o.id) : /* @__PURE__ */ S(y, {
|
|
136
|
+
className: "ttw:hover:bg-transparent ttw:border-border",
|
|
137
|
+
children: [
|
|
138
|
+
/* @__PURE__ */ x(g, {
|
|
139
|
+
className: "ttw:text-sm ttw:truncate",
|
|
140
|
+
children: o.name
|
|
141
|
+
}),
|
|
142
|
+
/* @__PURE__ */ x(g, {
|
|
143
|
+
className: "ttw:text-sm ttw:text-muted-foreground ttw:truncate",
|
|
144
|
+
children: o.description || O
|
|
145
|
+
}),
|
|
146
|
+
/* @__PURE__ */ x(g, {
|
|
147
|
+
className: "ttw:text-right",
|
|
148
|
+
children: /* @__PURE__ */ S(t, { children: [/* @__PURE__ */ x(i, {
|
|
149
|
+
asChild: !0,
|
|
150
|
+
children: /* @__PURE__ */ x(e, {
|
|
151
|
+
variant: "ghost",
|
|
152
|
+
size: "icon-sm",
|
|
153
|
+
"aria-label": Z.moreActionsLabel,
|
|
154
|
+
children: /* @__PURE__ */ x(w, { className: "ttw:size-4" })
|
|
155
|
+
})
|
|
156
|
+
}), /* @__PURE__ */ S(n, {
|
|
157
|
+
align: "end",
|
|
158
|
+
children: [/* @__PURE__ */ S(r, {
|
|
159
|
+
onClick: () => U(o),
|
|
160
|
+
children: [/* @__PURE__ */ x(T, { className: "ttw:size-4" }), Z.editAction]
|
|
161
|
+
}), /* @__PURE__ */ S(r, {
|
|
162
|
+
onClick: () => J(o),
|
|
163
|
+
variant: "destructive",
|
|
164
|
+
children: [/* @__PURE__ */ x(E, { className: "ttw:size-4" }), Z.deleteAction]
|
|
165
|
+
})]
|
|
166
|
+
})] })
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
}, o.id)),
|
|
170
|
+
!M && j.length === 0 && /* @__PURE__ */ x(y, {
|
|
171
|
+
className: "ttw:hover:bg-transparent",
|
|
172
|
+
children: /* @__PURE__ */ x(g, {
|
|
173
|
+
colSpan: 3,
|
|
174
|
+
className: "ttw:text-center ttw:text-muted-foreground",
|
|
175
|
+
children: Z.emptyText
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
] })]
|
|
179
|
+
})]
|
|
180
|
+
}),
|
|
181
|
+
/* @__PURE__ */ x(d, {
|
|
182
|
+
className: "ttw:border-t ttw:border-border ttw:flex-row ttw:justify-end",
|
|
183
|
+
children: /* @__PURE__ */ x(e, {
|
|
184
|
+
onClick: Y,
|
|
185
|
+
children: Z.doneButton
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
})
|
|
48
190
|
});
|
|
49
191
|
}
|
|
50
192
|
//#endregion
|
|
51
|
-
export {
|
|
193
|
+
export { k as MeasureUnitsManager, k as default };
|
package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js
CHANGED
|
@@ -1,128 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
|
8
|
-
let
|
|
9
|
-
...
|
|
10
|
-
...
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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 {
|
|
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 };
|