@tesouro/embedded-components-react 0.7.66 → 0.7.67

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