@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.
Files changed (33) 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/approval-policy/feature/dist/lib/labels.js +1 -2
  17. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/policyViewModel.js +8 -9
  18. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApprovalPolicyRules.js +127 -141
  19. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/util/dist/lib/validatePolicyDraft.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +13 -12
  22. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +2 -2
  23. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/ProductSelector.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js +41 -27
  25. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +70 -52
  26. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index.js +7 -6
  27. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +19 -8
  28. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +171 -218
  29. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +52 -180
  30. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js +188 -46
  31. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +47 -124
  32. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js +128 -0
  33. package/package.json +1 -1
@@ -1,234 +1,187 @@
1
- import { Button as e, Combobox as t, FieldRequirement as n, Input as r, InputGroup as i, InputGroupAddon as a, InputGroupInput as o, Label as s, RadioGroup as c, RadioGroupItem as l, RequiredFieldsLegend as u, Sheet as d, SheetContent as f, SheetDescription as p, SheetFooter as m, SheetHeader as h, SheetTitle as g, Textarea as _, Typography as v, mergeRequiredFieldsLegendLabels as y } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { PRODUCT_FORM_SHEET_LABELS_EN as b } from "./index2.js";
3
- import { useId as x } from "react";
4
- import { jsx as S, jsxs as C } from "react/jsx-runtime";
1
+ import { Combobox as e, FieldRequirement as t, Input as n, InputGroup as r, InputGroupAddon as i, InputGroupInput as a, Label as o, RadioGroup as s, RadioGroupItem as c, RequiredFieldsLegend as l, Textarea as u, Typography as d } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { mergeProductFormSheetLabels as f } from "./index2.js";
3
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
5
4
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js
6
- var w = "__no_unit__", T = "ttw:flex ttw:cursor-pointer ttw:items-center ttw:gap-2 ttw:rounded-full ttw:border ttw:border-border ttw:bg-background ttw:px-3 ttw:py-1.5 ttw:text-sm ttw:has-[:checked]:border-primary ttw:has-[:checked]:bg-primary/10";
7
- function E({ id: e, message: t }) {
8
- return t ? /* @__PURE__ */ S("p", {
5
+ var g = "__no_unit__", _ = "ttw:flex ttw:cursor-pointer ttw:items-center ttw:gap-2 ttw:rounded-full ttw:border ttw:border-border ttw:bg-background ttw:px-3 ttw:py-1.5 ttw:text-sm ttw:has-[:checked]:border-primary ttw:has-[:checked]:bg-primary/10", v = "ttw:bg-background!";
6
+ function y({ id: e, message: t }) {
7
+ return t ? /* @__PURE__ */ m("p", {
9
8
  id: e,
10
9
  className: "ttw:text-sm ttw:text-destructive",
11
10
  children: t
12
11
  }) : null;
13
12
  }
14
- function D({ open: D, onOpenChange: O, mode: k, values: A, errors: j, unitOptions: M, inProgress: N, onChange: P, onSubmit: F, onCancel: I, labels: L }) {
15
- let R = {
16
- ...b.fieldMarkers,
17
- ...L?.fieldMarkers
18
- }, z = {
19
- ...b,
20
- ...L,
21
- fieldMarkers: R,
22
- requiredFieldsLegend: y(R, L?.requiredFieldsLegend)
23
- }, B = x(), V = A.type === "service" ? z.typeService.toLowerCase() : z.typeProduct.toLowerCase(), H = k === "edit" ? z.editTitle.replace("{type}", V) : z.createTitle, U = z.createButton.replace("{type}", V);
24
- return /* @__PURE__ */ S(d, {
25
- open: D,
26
- onOpenChange: O,
27
- children: /* @__PURE__ */ C(f, {
28
- className: "ttw:w-150 ttw:sm:max-w-150 ttw:gap-0",
13
+ function b({ idPrefix: b, values: x, errors: S, unitOptions: C, pricePrefix: w, onChange: T, labels: E }) {
14
+ let D = f(E);
15
+ return /* @__PURE__ */ h(p, { children: [
16
+ /* @__PURE__ */ m(l, { labels: D.requiredFieldsLegend }),
17
+ S?.form && /* @__PURE__ */ m("p", {
18
+ role: "alert",
19
+ className: "ttw:rounded-md ttw:bg-destructive/10 ttw:px-3 ttw:py-2 ttw:text-sm ttw:text-destructive",
20
+ children: S.form
21
+ }),
22
+ /* @__PURE__ */ h("fieldset", {
23
+ className: "ttw:flex ttw:flex-col ttw:gap-2",
29
24
  children: [
30
- /* @__PURE__ */ C(h, {
31
- className: "ttw:border-b ttw:border-border",
32
- children: [/* @__PURE__ */ S(g, {
33
- className: "ttw:text-2xl",
34
- children: H
35
- }), k === "create" ? /* @__PURE__ */ S(p, {
36
- className: "ttw:max-w-130",
37
- children: z.headerDescription
38
- }) : /* @__PURE__ */ S(p, {
39
- className: "ttw:sr-only",
40
- children: H
41
- })]
25
+ /* @__PURE__ */ m("legend", {
26
+ className: "ttw:mb-1 ttw:text-sm ttw:font-medium",
27
+ children: D.typeLabel
28
+ }),
29
+ /* @__PURE__ */ m(s, {
30
+ className: "ttw:flex ttw:flex-wrap ttw:gap-2",
31
+ value: x.type,
32
+ "aria-describedby": S?.type ? `${b}-type-error` : void 0,
33
+ onValueChange: (e) => T({ type: e }),
34
+ children: [{
35
+ value: "product",
36
+ label: D.typeProduct
37
+ }, {
38
+ value: "service",
39
+ label: D.typeService
40
+ }].map((e) => /* @__PURE__ */ h(o, {
41
+ htmlFor: `${b}-type-${e.value}`,
42
+ className: _,
43
+ children: [/* @__PURE__ */ m(c, {
44
+ value: e.value,
45
+ id: `${b}-type-${e.value}`
46
+ }), /* @__PURE__ */ m("span", {
47
+ className: "ttw:font-medium",
48
+ children: e.label
49
+ })]
50
+ }, e.value))
51
+ }),
52
+ /* @__PURE__ */ m(y, {
53
+ id: `${b}-type-error`,
54
+ message: S?.type
55
+ })
56
+ ]
57
+ }),
58
+ /* @__PURE__ */ h("div", {
59
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
60
+ children: [
61
+ /* @__PURE__ */ m(o, {
62
+ htmlFor: `${b}-name`,
63
+ requirement: t.Required,
64
+ labels: D.fieldMarkers,
65
+ children: D.nameLabel
42
66
  }),
43
- /* @__PURE__ */ S("form", {
44
- id: B,
45
- onSubmit: (e) => {
46
- e.preventDefault(), e.stopPropagation(), F();
47
- },
48
- children: /* @__PURE__ */ C("div", {
49
- className: "ttw:flex ttw:flex-col ttw:gap-4 ttw:px-6 ttw:py-8 ttw:overflow-auto",
50
- children: [
51
- /* @__PURE__ */ S(u, { labels: z.requiredFieldsLegend }),
52
- j?.form && /* @__PURE__ */ S("p", {
53
- role: "alert",
54
- className: "ttw:rounded-md ttw:bg-destructive/10 ttw:px-3 ttw:py-2 ttw:text-sm ttw:text-destructive",
55
- children: j.form
56
- }),
57
- k === "edit" && /* @__PURE__ */ S("div", {
58
- className: "ttw:flex ttw:items-center ttw:gap-3 ttw:pt-6 ttw:pb-7 ttw:border-b ttw:border-border",
59
- children: /* @__PURE__ */ S(v, {
60
- variant: "body1",
61
- className: "ttw:font-medium",
62
- children: z.editingBanner.replace("{type}", V)
63
- })
64
- }),
65
- /* @__PURE__ */ C("fieldset", {
66
- className: "ttw:flex ttw:flex-col ttw:gap-2",
67
- children: [
68
- /* @__PURE__ */ S("legend", {
69
- className: "ttw:mb-1 ttw:text-sm ttw:font-medium",
70
- children: z.typeLabel
71
- }),
72
- /* @__PURE__ */ S(c, {
73
- className: "ttw:flex ttw:flex-wrap ttw:gap-2",
74
- value: A.type,
75
- onValueChange: (e) => P({ type: e }),
76
- children: [{
77
- value: "product",
78
- label: z.typeProduct
79
- }, {
80
- value: "service",
81
- label: z.typeService
82
- }].map((e) => /* @__PURE__ */ C(s, {
83
- htmlFor: `${B}-type-${e.value}`,
84
- className: T,
85
- children: [/* @__PURE__ */ S(l, {
86
- value: e.value,
87
- id: `${B}-type-${e.value}`
88
- }), /* @__PURE__ */ S("span", {
89
- className: "ttw:font-medium",
90
- children: e.label
91
- })]
92
- }, e.value))
93
- }),
94
- /* @__PURE__ */ S(E, { message: j?.type })
95
- ]
96
- }),
97
- /* @__PURE__ */ C("div", {
98
- className: "ttw:flex ttw:flex-col ttw:gap-1.5",
99
- children: [
100
- /* @__PURE__ */ S(s, {
101
- htmlFor: `${B}-name`,
102
- requirement: n.Required,
103
- labels: z.fieldMarkers,
104
- children: z.nameLabel
105
- }),
106
- /* @__PURE__ */ S(r, {
107
- id: `${B}-name`,
108
- autoFocus: !0,
109
- "aria-required": !0,
110
- placeholder: z.namePlaceholder,
111
- value: A.name,
112
- "aria-invalid": !!j?.name,
113
- onChange: (e) => P({ name: e.target.value })
114
- }),
115
- /* @__PURE__ */ S(E, { message: j?.name })
116
- ]
117
- }),
118
- /* @__PURE__ */ C("div", {
119
- className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
120
- children: [/* @__PURE__ */ C("div", {
121
- className: "ttw:flex ttw:flex-col ttw:gap-1.5",
122
- children: [
123
- /* @__PURE__ */ S(s, {
124
- htmlFor: `${B}-price`,
125
- requirement: n.Optional,
126
- labels: z.fieldMarkers,
127
- children: z.priceLabel
128
- }),
129
- /* @__PURE__ */ C(i, { children: [/* @__PURE__ */ S(a, {
130
- align: "inline-start",
131
- children: z.pricePrefix
132
- }), /* @__PURE__ */ S(o, {
133
- id: `${B}-price`,
134
- "data-has-start-addon": !0,
135
- inputMode: "decimal",
136
- placeholder: z.pricePlaceholder,
137
- value: A.pricePerUnit,
138
- "aria-invalid": !!j?.pricePerUnit || void 0,
139
- "aria-describedby": j?.pricePerUnit ? `${B}-price-error` : void 0,
140
- className: "ttw:text-end",
141
- onChange: (e) => P({ pricePerUnit: e.target.value })
142
- })] }),
143
- /* @__PURE__ */ S(E, {
144
- id: `${B}-price-error`,
145
- message: j?.pricePerUnit
146
- })
147
- ]
148
- }), /* @__PURE__ */ C("div", {
149
- className: "ttw:flex ttw:flex-col ttw:gap-1.5",
150
- children: [
151
- /* @__PURE__ */ S(s, {
152
- htmlFor: `${B}-unit`,
153
- requirement: n.Optional,
154
- labels: z.fieldMarkers,
155
- children: z.unitLabel
156
- }),
157
- /* @__PURE__ */ S(t, {
158
- inputId: `${B}-unit`,
159
- items: [{
160
- value: w,
161
- label: z.noUnit
162
- }, ...M],
163
- value: A.unitId || null,
164
- invalid: !!j?.unitId,
165
- describedBy: j?.unitId ? `${B}-unit-error` : void 0,
166
- labels: {
167
- placeholder: z.unitPlaceholder,
168
- emptyMessage: z.unitEmpty,
169
- clearAriaLabel: z.unitClearAriaLabel
170
- },
171
- onValueChange: (e) => P({ unitId: typeof e == "string" && e !== w ? e : "" })
172
- }),
173
- /* @__PURE__ */ S(E, {
174
- id: `${B}-unit-error`,
175
- message: j?.unitId
176
- })
177
- ]
178
- })]
179
- }),
180
- /* @__PURE__ */ C("div", {
181
- className: "ttw:flex ttw:flex-col ttw:gap-1.5",
182
- children: [
183
- /* @__PURE__ */ S(s, {
184
- htmlFor: `${B}-description`,
185
- requirement: n.Optional,
186
- labels: z.fieldMarkers,
187
- children: z.descriptionLabel
188
- }),
189
- /* @__PURE__ */ S(_, {
190
- id: `${B}-description`,
191
- rows: 4,
192
- placeholder: z.descriptionPlaceholder,
193
- value: A.description,
194
- maxLength: 255,
195
- "aria-invalid": !!j?.description,
196
- onChange: (e) => P({ description: e.target.value })
197
- }),
198
- /* @__PURE__ */ C("div", {
199
- className: "ttw:flex ttw:justify-between ttw:items-start",
200
- children: [/* @__PURE__ */ S(E, { message: j?.description }), /* @__PURE__ */ S(v, {
201
- variant: "caption",
202
- color: "muted",
203
- className: "ttw:ml-auto ttw:leading-none",
204
- children: z.descriptionCount.replace("{count}", String(A.description.length))
205
- })]
206
- })
207
- ]
208
- })
209
- ]
67
+ /* @__PURE__ */ m(n, {
68
+ id: `${b}-name`,
69
+ autoFocus: !0,
70
+ "aria-required": !0,
71
+ className: v,
72
+ placeholder: D.namePlaceholder,
73
+ value: x.name,
74
+ "aria-invalid": !!S?.name,
75
+ "aria-describedby": S?.name ? `${b}-name-error` : void 0,
76
+ onChange: (e) => T({ name: e.target.value })
77
+ }),
78
+ /* @__PURE__ */ m(y, {
79
+ id: `${b}-name-error`,
80
+ message: S?.name
81
+ })
82
+ ]
83
+ }),
84
+ /* @__PURE__ */ h("div", {
85
+ className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
86
+ children: [/* @__PURE__ */ h("div", {
87
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
88
+ children: [
89
+ /* @__PURE__ */ m(o, {
90
+ htmlFor: `${b}-price`,
91
+ requirement: t.Optional,
92
+ labels: D.fieldMarkers,
93
+ children: D.priceLabel
94
+ }),
95
+ /* @__PURE__ */ h(r, {
96
+ className: v,
97
+ children: [/* @__PURE__ */ m(i, {
98
+ align: "inline-start",
99
+ children: w
100
+ }), /* @__PURE__ */ m(a, {
101
+ id: `${b}-price`,
102
+ "data-has-start-addon": !0,
103
+ inputMode: "decimal",
104
+ placeholder: D.pricePlaceholder,
105
+ value: x.pricePerUnit,
106
+ "aria-invalid": !!S?.pricePerUnit || void 0,
107
+ "aria-describedby": S?.pricePerUnit ? `${b}-price-error` : void 0,
108
+ className: "ttw:text-end",
109
+ onChange: (e) => T({ pricePerUnit: e.target.value })
110
+ })]
111
+ }),
112
+ /* @__PURE__ */ m(y, {
113
+ id: `${b}-price-error`,
114
+ message: S?.pricePerUnit
210
115
  })
116
+ ]
117
+ }), /* @__PURE__ */ h("div", {
118
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
119
+ children: [
120
+ /* @__PURE__ */ m(o, {
121
+ htmlFor: `${b}-unit`,
122
+ requirement: t.Optional,
123
+ labels: D.fieldMarkers,
124
+ children: D.unitLabel
125
+ }),
126
+ /* @__PURE__ */ m(e, {
127
+ className: "ttw:rounded-md ttw:bg-background",
128
+ inputId: `${b}-unit`,
129
+ items: [{
130
+ value: g,
131
+ label: D.noUnit
132
+ }, ...C],
133
+ value: x.unitId || null,
134
+ invalid: !!S?.unitId,
135
+ describedBy: S?.unitId ? `${b}-unit-error` : void 0,
136
+ labels: {
137
+ placeholder: D.unitPlaceholder,
138
+ emptyMessage: D.unitEmpty,
139
+ clearAriaLabel: D.unitClearAriaLabel
140
+ },
141
+ onValueChange: (e) => T({ unitId: typeof e == "string" && e !== g ? e : "" })
142
+ }),
143
+ /* @__PURE__ */ m(y, {
144
+ id: `${b}-unit-error`,
145
+ message: S?.unitId
146
+ })
147
+ ]
148
+ })]
149
+ }),
150
+ /* @__PURE__ */ h("div", {
151
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
152
+ children: [
153
+ /* @__PURE__ */ m(o, {
154
+ htmlFor: `${b}-description`,
155
+ requirement: t.Optional,
156
+ labels: D.fieldMarkers,
157
+ children: D.descriptionLabel
158
+ }),
159
+ /* @__PURE__ */ m(u, {
160
+ id: `${b}-description`,
161
+ rows: 4,
162
+ className: v,
163
+ placeholder: D.descriptionPlaceholder,
164
+ value: x.description,
165
+ maxLength: 255,
166
+ "aria-invalid": !!S?.description,
167
+ "aria-describedby": S?.description ? `${b}-description-error` : void 0,
168
+ onChange: (e) => T({ description: e.target.value })
211
169
  }),
212
- /* @__PURE__ */ C(m, {
213
- className: "ttw:border-t ttw:border-border ttw:flex-row ttw:justify-end",
214
- children: [/* @__PURE__ */ S(e, {
215
- type: "button",
216
- variant: "outline",
217
- className: "ttw:w-fit ttw:border-border",
218
- onClick: I,
219
- children: z.cancelButton
220
- }), /* @__PURE__ */ S(e, {
221
- type: "submit",
222
- form: B,
223
- className: "ttw:w-fit",
224
- disabled: N,
225
- loading: N,
226
- children: k === "edit" ? z.saveButton : U
170
+ /* @__PURE__ */ h("div", {
171
+ className: "ttw:flex ttw:justify-between ttw:items-start",
172
+ children: [/* @__PURE__ */ m(y, {
173
+ id: `${b}-description-error`,
174
+ message: S?.description
175
+ }), /* @__PURE__ */ m(d, {
176
+ variant: "caption",
177
+ color: "muted",
178
+ className: "ttw:ml-auto ttw:leading-none",
179
+ children: D.descriptionCount.replace("{count}", String(x.description.length))
227
180
  })]
228
181
  })
229
182
  ]
230
183
  })
231
- });
184
+ ] });
232
185
  }
233
186
  //#endregion
234
- export { D as ProductFormSheet, D as default };
187
+ export { b as ProductFormFields, b as default };
@@ -1,193 +1,65 @@
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";
1
+ import { Button as e, Sheet as t, SheetContent as n, SheetDescription as r, SheetFooter as i, SheetHeader as a, SheetTitle as o } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { mergeProductFormSheetLabels as s } from "./index2.js";
3
+ import { ProductFormFields as c } from "./index3.js";
4
+ import { useId as l } from "react";
5
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
5
6
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js
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",
7
+ function f({ open: f, onOpenChange: p, values: m, errors: h, unitOptions: g, pricePrefix: _, inProgress: v, onChange: y, onSubmit: b, onCancel: x, labels: S }) {
8
+ let C = s(S), w = l(), T = m.type === "service" ? C.typeService.toLowerCase() : C.typeProduct.toLowerCase();
9
+ return /* @__PURE__ */ u(t, {
10
+ open: f,
11
+ onOpenChange: p,
12
+ children: /* @__PURE__ */ d(n, {
13
+ className: "ttw:w-150 ttw:sm:max-w-150 ttw:gap-0",
17
14
  children: [
18
- /* @__PURE__ */ S(f, {
15
+ /* @__PURE__ */ d(a, {
19
16
  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
17
+ children: [/* @__PURE__ */ u(o, {
18
+ className: "ttw:text-2xl",
19
+ children: C.createTitle
20
+ }), /* @__PURE__ */ u(r, {
21
+ className: "ttw:max-w-130",
22
+ children: C.headerDescription
23
23
  })]
24
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
- })]
25
+ /* @__PURE__ */ u("form", {
26
+ id: w,
27
+ onSubmit: (e) => {
28
+ e.preventDefault(), e.stopPropagation(), b();
29
+ },
30
+ children: /* @__PURE__ */ u("div", {
31
+ className: "ttw:flex ttw:flex-col ttw:gap-4 ttw:px-6 ttw:py-8 ttw:overflow-auto",
32
+ children: /* @__PURE__ */ u(c, {
33
+ idPrefix: w,
34
+ values: m,
35
+ errors: h,
36
+ unitOptions: g,
37
+ pricePrefix: _,
38
+ onChange: y,
39
+ labels: S
40
+ })
41
+ })
180
42
  }),
181
- /* @__PURE__ */ x(d, {
43
+ /* @__PURE__ */ d(i, {
182
44
  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
- })
45
+ children: [/* @__PURE__ */ u(e, {
46
+ type: "button",
47
+ variant: "outline",
48
+ className: "ttw:w-fit ttw:border-border",
49
+ onClick: x,
50
+ children: C.cancelButton
51
+ }), /* @__PURE__ */ u(e, {
52
+ type: "submit",
53
+ form: w,
54
+ className: "ttw:w-fit",
55
+ disabled: v,
56
+ loading: v,
57
+ children: C.createButton.replace("{type}", T)
58
+ })]
187
59
  })
188
60
  ]
189
61
  })
190
62
  });
191
63
  }
192
64
  //#endregion
193
- export { k as MeasureUnitsManager, k as default };
65
+ export { f as ProductFormSheet, f as default };