@tesouro/embedded-components-react 0.7.64 → 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.
- package/README.md +1 -1
- package/dist/index.css +3 -0
- package/dist/index.d.ts +10 -10
- package/dist/lib/ProductsWidget.d.ts +40 -10
- package/dist/lib/ReceivablesWidget.d.ts +9 -9
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/apiValidationErrors.js +34 -63
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/currencyDisplay.js +6 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/discount.js +31 -30
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +89 -87
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/lineItems.js +84 -82
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +77 -75
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js +54 -53
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +458 -457
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +0 -2
- 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/lib/helpers.js +33 -41
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/labels.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +42 -44
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +14 -13
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +128 -147
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +109 -92
- package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/apiValidationErrors.js +33 -0
- package/package.json +1 -1
package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js
CHANGED
|
@@ -1,226 +1,207 @@
|
|
|
1
|
-
import { Button as e,
|
|
2
|
-
import { PRODUCT_FORM_SHEET_LABELS_EN as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { jsx as
|
|
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
|
|
8
|
-
function
|
|
9
|
-
return
|
|
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:
|
|
11
|
+
children: t
|
|
12
12
|
}) : null;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
let
|
|
16
|
-
...
|
|
17
|
-
...
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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__ */
|
|
30
|
+
/* @__PURE__ */ C(h, {
|
|
26
31
|
className: "ttw:border-b ttw:border-border",
|
|
27
|
-
children: [/* @__PURE__ */
|
|
32
|
+
children: [/* @__PURE__ */ S(g, {
|
|
28
33
|
className: "ttw:text-2xl",
|
|
29
34
|
children: H
|
|
30
|
-
}),
|
|
35
|
+
}), k === "create" ? /* @__PURE__ */ S(p, {
|
|
31
36
|
className: "ttw:max-w-130",
|
|
32
37
|
children: z.headerDescription
|
|
33
|
-
}) : /* @__PURE__ */
|
|
38
|
+
}) : /* @__PURE__ */ S(p, {
|
|
34
39
|
className: "ttw:sr-only",
|
|
35
40
|
children: H
|
|
36
41
|
})]
|
|
37
42
|
}),
|
|
38
|
-
/* @__PURE__ */
|
|
43
|
+
/* @__PURE__ */ S("form", {
|
|
39
44
|
id: B,
|
|
40
45
|
onSubmit: (e) => {
|
|
41
|
-
e.preventDefault(), e.stopPropagation(),
|
|
46
|
+
e.preventDefault(), e.stopPropagation(), F();
|
|
42
47
|
},
|
|
43
|
-
children: /* @__PURE__ */
|
|
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
|
-
|
|
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:
|
|
55
|
+
children: j.form
|
|
50
56
|
}),
|
|
51
|
-
|
|
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__ */
|
|
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__ */
|
|
60
|
-
className: "ttw:flex ttw:flex-col ttw:gap-
|
|
65
|
+
/* @__PURE__ */ C("fieldset", {
|
|
66
|
+
className: "ttw:flex ttw:flex-col ttw:gap-2",
|
|
61
67
|
children: [
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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__ */
|
|
94
|
+
/* @__PURE__ */ S(E, { message: j?.type })
|
|
99
95
|
]
|
|
100
96
|
}),
|
|
101
|
-
/* @__PURE__ */
|
|
97
|
+
/* @__PURE__ */ C("div", {
|
|
102
98
|
className: "ttw:flex ttw:flex-col ttw:gap-1.5",
|
|
103
99
|
children: [
|
|
104
|
-
/* @__PURE__ */
|
|
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__ */
|
|
106
|
+
/* @__PURE__ */ S(r, {
|
|
109
107
|
id: `${B}-name`,
|
|
110
108
|
autoFocus: !0,
|
|
109
|
+
"aria-required": !0,
|
|
111
110
|
placeholder: z.namePlaceholder,
|
|
112
|
-
value:
|
|
113
|
-
"aria-invalid": !!
|
|
111
|
+
value: A.name,
|
|
112
|
+
"aria-invalid": !!j?.name,
|
|
114
113
|
onChange: (e) => P({ name: e.target.value })
|
|
115
114
|
}),
|
|
116
|
-
/* @__PURE__ */
|
|
115
|
+
/* @__PURE__ */ S(E, { message: j?.name })
|
|
117
116
|
]
|
|
118
117
|
}),
|
|
119
|
-
/* @__PURE__ */
|
|
118
|
+
/* @__PURE__ */ C("div", {
|
|
120
119
|
className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
|
|
121
|
-
children: [/* @__PURE__ */
|
|
120
|
+
children: [/* @__PURE__ */ C("div", {
|
|
122
121
|
className: "ttw:flex ttw:flex-col ttw:gap-1.5",
|
|
123
122
|
children: [
|
|
124
|
-
/* @__PURE__ */
|
|
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__ */
|
|
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
|
-
|
|
132
|
-
|
|
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__ */
|
|
142
|
+
})] }),
|
|
143
|
+
/* @__PURE__ */ S(E, {
|
|
144
|
+
id: `${B}-price-error`,
|
|
145
|
+
message: j?.pricePerUnit
|
|
146
|
+
})
|
|
136
147
|
]
|
|
137
|
-
}), /* @__PURE__ */
|
|
148
|
+
}), /* @__PURE__ */ C("div", {
|
|
138
149
|
className: "ttw:flex ttw:flex-col ttw:gap-1.5",
|
|
139
150
|
children: [
|
|
140
|
-
/* @__PURE__ */
|
|
141
|
-
htmlFor: `${B}-
|
|
142
|
-
|
|
151
|
+
/* @__PURE__ */ S(s, {
|
|
152
|
+
htmlFor: `${B}-unit`,
|
|
153
|
+
requirement: n.Optional,
|
|
154
|
+
labels: z.fieldMarkers,
|
|
155
|
+
children: z.unitLabel
|
|
143
156
|
}),
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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__ */
|
|
173
|
+
/* @__PURE__ */ S(E, {
|
|
174
|
+
id: `${B}-unit-error`,
|
|
175
|
+
message: j?.unitId
|
|
176
|
+
})
|
|
157
177
|
]
|
|
158
178
|
})]
|
|
159
179
|
}),
|
|
160
|
-
/* @__PURE__ */
|
|
180
|
+
/* @__PURE__ */ C("div", {
|
|
161
181
|
className: "ttw:flex ttw:flex-col ttw:gap-1.5",
|
|
162
182
|
children: [
|
|
163
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
color: "muted",
|
|
205
|
-
children: z.descriptionOptional
|
|
206
|
-
})]
|
|
185
|
+
requirement: n.Optional,
|
|
186
|
+
labels: z.fieldMarkers,
|
|
187
|
+
children: z.descriptionLabel
|
|
207
188
|
}),
|
|
208
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ S(_, {
|
|
209
190
|
id: `${B}-description`,
|
|
210
191
|
rows: 4,
|
|
211
192
|
placeholder: z.descriptionPlaceholder,
|
|
212
|
-
value:
|
|
193
|
+
value: A.description,
|
|
213
194
|
maxLength: 255,
|
|
214
|
-
"aria-invalid": !!
|
|
195
|
+
"aria-invalid": !!j?.description,
|
|
215
196
|
onChange: (e) => P({ description: e.target.value })
|
|
216
197
|
}),
|
|
217
|
-
/* @__PURE__ */
|
|
198
|
+
/* @__PURE__ */ C("div", {
|
|
218
199
|
className: "ttw:flex ttw:justify-between ttw:items-start",
|
|
219
|
-
children: [/* @__PURE__ */
|
|
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(
|
|
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__ */
|
|
212
|
+
/* @__PURE__ */ C(m, {
|
|
232
213
|
className: "ttw:border-t ttw:border-border ttw:flex-row ttw:justify-end",
|
|
233
|
-
children: [/* @__PURE__ */
|
|
214
|
+
children: [/* @__PURE__ */ S(e, {
|
|
234
215
|
type: "button",
|
|
235
216
|
variant: "outline",
|
|
236
|
-
className: "ttw:
|
|
237
|
-
onClick:
|
|
217
|
+
className: "ttw:w-fit ttw:border-border",
|
|
218
|
+
onClick: I,
|
|
238
219
|
children: z.cancelButton
|
|
239
|
-
}), /* @__PURE__ */
|
|
220
|
+
}), /* @__PURE__ */ S(e, {
|
|
240
221
|
type: "submit",
|
|
241
222
|
form: B,
|
|
242
|
-
className: "ttw:
|
|
223
|
+
className: "ttw:w-fit",
|
|
243
224
|
disabled: N,
|
|
244
225
|
loading: N,
|
|
245
|
-
children:
|
|
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 {
|
|
234
|
+
export { D as ProductFormSheet, D as default };
|