@tesouro/embedded-components-react 0.11.54 → 0.11.58

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 (38) hide show
  1. package/README.md +2 -2
  2. package/dist/index.css +0 -21
  3. package/dist/index.d.ts +31 -6
  4. package/dist/lib/ProductsWidget.d.ts +30 -5
  5. package/dist/lib/ReceivablesWidget.d.ts +27 -5
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +99 -92
  8. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductDelete.js +24 -21
  9. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsWidget.js +79 -75
  10. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/mocks/labels.js +5 -5
  11. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index2.js +9 -7
  12. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index3.js +7 -9
  13. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js +103 -118
  14. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js +28 -50
  15. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index6.js +118 -147
  16. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index7.js +24 -27
  17. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  18. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +16 -14
  19. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitCreateDialogContainer.js +38 -0
  20. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +73 -123
  21. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/ProductSelector.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js +6 -2
  23. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/labels.js +7 -7
  24. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useMeasureUnitForm.js +83 -0
  25. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +17 -4
  26. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index.js +6 -4
  27. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +45 -17
  28. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +121 -123
  29. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +36 -61
  30. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js +26 -194
  31. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +115 -49
  32. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js +62 -113
  33. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index8.js +51 -0
  34. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index9.js +117 -0
  35. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/index.js +14 -14
  36. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/StatePanel/NoAccessState.js +10 -2
  37. package/dist/packages/shared-ui-shadcn/dist/index.js +2393 -2373
  38. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { ProductSelector as e } from "../../../ui/dist/index7.js";
5
+ import { ProductSelector as e } from "../../../ui/dist/index9.js";
6
6
  import "../../../ui/dist/index.js";
7
7
  import { useProductSelector as t } from "./useProductSelector.js";
8
8
  import { jsx as n } from "react/jsx-runtime";
@@ -166,8 +166,12 @@ function T(e) {
166
166
  function E(e, t = r) {
167
167
  return e.name.trim().length === 0 ? t.unitNameRequired : void 0;
168
168
  }
169
- function D() {
169
+ function D(e, t, n) {
170
+ let r = e.replace("{name}", t);
171
+ return n ? `${r} ${n}` : r;
172
+ }
173
+ function O() {
170
174
  let e = globalThis.getSelection?.();
171
175
  return !!(e && e.toString().length > 0);
172
176
  }
173
- export { h as EMPTY_PRODUCT_FORM_VALUES, w as apiErrorToProductFormErrors, g as areProductFormValuesEqual, m as buildProductDetailsView, p as buildProductRows, d as buildUnitNamesById, f as buildUnitOptions, s as currencySymbol, c as formatPrice, u as formatProductDate, o as fromMinorUnits, T as hasProductFormErrors, D as hasSelectedText, v as productFormValuesToRequest, y as productFormValuesToUpdateRequest, _ as productToFormValues, a as toMinorUnits, E as validateMeasureUnit, S as validateProductForm };
177
+ export { h as EMPTY_PRODUCT_FORM_VALUES, w as apiErrorToProductFormErrors, g as areProductFormValuesEqual, m as buildProductDetailsView, p as buildProductRows, d as buildUnitNamesById, f as buildUnitOptions, s as currencySymbol, D as formatDeleteError, c as formatPrice, u as formatProductDate, o as fromMinorUnits, T as hasProductFormErrors, O as hasSelectedText, v as productFormValuesToRequest, y as productFormValuesToUpdateRequest, _ as productToFormValues, a as toMinorUnits, E as validateMeasureUnit, S as validateProductForm };
@@ -5,18 +5,18 @@ var e = {
5
5
  typeRequired: "Product type is required",
6
6
  priceInvalid: "Price per unit must be 0 or greater",
7
7
  descriptionTooLong: "Description must be 255 characters or less",
8
- unitNameRequired: "Unit label is required",
9
- genericError: "Something went wrong. Please try again.",
10
- createMeasureUnitError: "Failed to create measure unit.",
11
- updateMeasureUnitError: "Failed to update measure unit.",
8
+ unitNameRequired: "Unit name is required",
9
+ genericError: "Couldn't save this item. Try again.",
10
+ createMeasureUnitError: "Couldn't add unit.",
11
+ updateMeasureUnitError: "Couldn't update unit.",
12
12
  productCreated: "{name} has been added to the list.",
13
13
  productUpdated: "Product {name} was updated.",
14
14
  serviceUpdated: "Service {name} was updated.",
15
- productDeleted: "Product was deleted.",
16
- deleteProductError: "Failed to delete product.",
15
+ productDeleted: "{name} was deleted from the list.",
16
+ deleteProductError: "Couldn't delete {name}.",
17
17
  measureUnitCreated: "Unit {name} was added to the list.",
18
18
  measureUnitUpdated: "Unit {name} was updated.",
19
19
  measureUnitDeleted: "Unit {name} was deleted from the list.",
20
- deleteMeasureUnitError: "Failed to delete measure unit."
20
+ deleteMeasureUnitError: "Couldn't delete {name}."
21
21
  };
22
22
  export { e as PRODUCT_MESSAGE_LABELS_EN };
@@ -0,0 +1,83 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { extractApiErrorMessage as e } from "../../../../util/dist/lib/apiErrors.js";
6
+ import "../../../../util/dist/index.js";
7
+ import { validateMeasureUnit as t } from "./helpers.js";
8
+ import { toastSuccessWithName as n } from "./toasts.js";
9
+ import { MeasureUnitFormMode as r } from "../../../ui/dist/index7.js";
10
+ import "../../../ui/dist/index.js";
11
+ import { useCreateMeasureUnitMutation as i } from "../../../data-access/dist/index11.js";
12
+ import { useUpdateMeasureUnitMutation as a } from "../../../data-access/dist/index12.js";
13
+ import "../../../data-access/dist/index.js";
14
+ import { useCallback as o, useState as s } from "react";
15
+ // ../../libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useMeasureUnitForm.js
16
+ var c = {
17
+ name: "",
18
+ description: ""
19
+ };
20
+ function l({ messages: l, suspended: u = !1, onCreated: d, toastOnCreate: f = !0 }) {
21
+ let p = i(), m = a(), [h, g] = s(), [_, v] = s(), [y, b] = s(c), [x, S] = s(), C = o(() => {
22
+ v(void 0), b(c), S(void 0), g(r.Create);
23
+ }, []), w = o((e) => {
24
+ v(e.id), b({
25
+ name: e.name,
26
+ description: e.description
27
+ }), S(void 0), g(r.Edit);
28
+ }, []), T = o(() => g(void 0), []), E = o((e) => {
29
+ b((t) => ({
30
+ ...t,
31
+ ...e
32
+ })), "name" in e && S(void 0);
33
+ }, []), D = o(async () => {
34
+ if (u || !h) return;
35
+ let i = t(y, l);
36
+ if (i) {
37
+ S(i);
38
+ return;
39
+ }
40
+ S(void 0);
41
+ let a = {
42
+ name: y.name.trim(),
43
+ description: y.description.trim() || void 0
44
+ };
45
+ try {
46
+ if (h === r.Edit && _) {
47
+ let e = await m.mutateAsync({
48
+ path: { unit_id: _ },
49
+ body: a
50
+ });
51
+ n(l.measureUnitUpdated, e.name);
52
+ } else {
53
+ let e = await p.mutateAsync({ body: a });
54
+ f && n(l.measureUnitCreated, e.name), d?.(e);
55
+ }
56
+ g(void 0);
57
+ } catch (t) {
58
+ S(e(t) ?? (h === r.Edit ? l.updateMeasureUnitError : l.createMeasureUnitError));
59
+ }
60
+ }, [
61
+ u,
62
+ h,
63
+ y,
64
+ _,
65
+ p,
66
+ m,
67
+ l,
68
+ d,
69
+ f
70
+ ]);
71
+ return {
72
+ mode: h,
73
+ draft: y,
74
+ error: x,
75
+ isSubmitting: p.isPending || m.isPending,
76
+ openCreate: C,
77
+ openEdit: w,
78
+ close: T,
79
+ change: E,
80
+ submit: D
81
+ };
82
+ }
83
+ export { l as useMeasureUnitForm };
@@ -28,11 +28,23 @@ function _({ view: _, setView: v, selectedProductId: y, setSelectedProductId: b,
28
28
  v("none"), b(void 0);
29
29
  }, [b, v]), P = f(() => {
30
30
  k({}), v("details");
31
- }, [v]), F = m(() => _ === "edit" && x ? !n(E, s(x)) : !1, [
31
+ }, [v]), F = f((e) => {
32
+ D((t) => ({
33
+ ...t,
34
+ ...e
35
+ })), k((t) => {
36
+ let n = Object.keys(e);
37
+ if (!n.some((e) => e in t)) return t;
38
+ let r = { ...t };
39
+ return n.forEach((e) => {
40
+ delete r[e];
41
+ }), r;
42
+ });
43
+ }, []), I = m(() => _ === "edit" && x ? !n(E, s(x)) : !1, [
32
44
  _,
33
45
  x,
34
46
  E
35
- ]), I = f(async () => {
47
+ ]), L = f(async () => {
36
48
  let e = c(E, S);
37
49
  if (i(e)) k(e);
38
50
  else {
@@ -67,13 +79,14 @@ function _({ view: _, setView: v, selectedProductId: y, setSelectedProductId: b,
67
79
  errors: O,
68
80
  pricePrefix: r(E.currency),
69
81
  setValues: D,
82
+ change: F,
70
83
  isSubmitting: T,
71
- isDirty: F,
84
+ isDirty: I,
72
85
  openCreate: j,
73
86
  openEdit: M,
74
87
  cancelEdit: P,
75
88
  close: N,
76
- submit: I
89
+ submit: L
77
90
  };
78
91
  }
79
92
  export { _ as useProductForm };
@@ -1,7 +1,9 @@
1
1
  import { PRODUCT_FORM_SHEET_LABELS_EN as e, mergeProductFormSheetLabels as t } from "./index2.js";
2
2
  import { ProductFormFields as n } from "./index3.js";
3
3
  import { ProductFormSheet as r } from "./index4.js";
4
- import { MeasureUnitsManager as i } from "./index5.js";
5
- import { MeasureUnitDeleteDialog as a } from "./index6.js";
6
- import { ProductSelector as o } from "./index7.js";
7
- export { a as MeasureUnitDeleteDialog, i as MeasureUnitsManager, e as PRODUCT_FORM_SHEET_LABELS_EN, n as ProductFormFields, r as ProductFormSheet, o as ProductSelector, t as mergeProductFormSheetLabels };
4
+ import { ActionsMenu as i } from "./index5.js";
5
+ import { MeasureUnitsManager as a } from "./index6.js";
6
+ import { MeasureUnitFormDialog as o, MeasureUnitFormMode as s } from "./index7.js";
7
+ import { MeasureUnitDeleteDialog as c } from "./index8.js";
8
+ import { ProductSelector as l } from "./index9.js";
9
+ export { i as ActionsMenu, c as MeasureUnitDeleteDialog, o as MeasureUnitFormDialog, s as MeasureUnitFormMode, a as MeasureUnitsManager, e as PRODUCT_FORM_SHEET_LABELS_EN, n as ProductFormFields, r as ProductFormSheet, l as ProductSelector, t as mergeProductFormSheetLabels };
@@ -17,6 +17,7 @@ var r = {
17
17
  noUnit: "None",
18
18
  unitEmpty: "No units found",
19
19
  unitClearAriaLabel: "Clear unit",
20
+ addUnit: "+ Add unit",
20
21
  priceLabel: "Price per unit",
21
22
  pricePlaceholder: "0.00",
22
23
  cancelButton: "Cancel",
@@ -39,23 +40,49 @@ function i(e) {
39
40
  };
40
41
  }
41
42
  var a = {
42
- title: "Manage measure units",
43
- hiddenDescription: "Create, edit, and delete measure units",
43
+ title: "Manage units of measure",
44
+ hiddenDescription: "Add, rename and delete the units you sell in.",
44
45
  searchPlaceholder: "Search",
45
- columnLabel: "Unit label",
46
- columnDescription: "Description (optional)",
47
- namePlaceholder: "Unit label",
48
- descriptionPlaceholder: "Description",
49
- addButton: "Add",
46
+ searchLabel: "Search units",
47
+ columnLabel: "Name",
48
+ columnDescription: "Description",
49
+ noDescription: "—",
50
+ namePlaceholder: "",
51
+ descriptionPlaceholder: "",
52
+ addButton: "Add unit",
50
53
  doneButton: "Done",
51
- editAction: "Edit unit",
52
- deleteAction: "Delete unit",
53
- moreActionsLabel: "More actions",
54
- saveAction: "Save unit",
55
- cancelAction: "Cancel edit",
54
+ editAction: "Edit",
55
+ deleteAction: "Delete",
56
+ saveAction: "Save",
57
+ cancelAction: "Cancel",
56
58
  emptyText: "No measure units yet.",
57
- close: "Close"
58
- }, o = {
59
+ emptyTitle: "No measure units yet",
60
+ emptyDescription: "Add the units you sell in, like hours or boxes.",
61
+ searchEmptyTitle: "No units found",
62
+ searchEmptyDescription: "Try a different search.",
63
+ loadingLabel: "Loading measure units",
64
+ errorTitle: "Couldn't load units of measure",
65
+ errorDescription: "Something went wrong while loading your units.",
66
+ errorRetry: "Try again",
67
+ moreActionsLabel: "More actions",
68
+ close: "Close",
69
+ createTitle: "Add unit",
70
+ editTitle: "Edit unit",
71
+ nameLabel: "Name",
72
+ descriptionLabel: "Description",
73
+ fieldMarkers: e
74
+ };
75
+ function o(e) {
76
+ return {
77
+ ...a,
78
+ ...e,
79
+ fieldMarkers: {
80
+ ...a.fieldMarkers,
81
+ ...e?.fieldMarkers
82
+ }
83
+ };
84
+ }
85
+ var s = {
59
86
  title: "Delete \"{name}\"?",
60
87
  messageNoItems: "There are no items created with this measure unit.",
61
88
  messageNoItemsHint: "Deleting it won't affect your items.",
@@ -63,11 +90,12 @@ var a = {
63
90
  messageWithItemsHint: "Previously issued invoices will not be impacted.",
64
91
  confirmButton: "Delete",
65
92
  cancelButton: "Cancel",
66
- close: "Close"
67
- }, s = {
93
+ close: "Close",
94
+ loadingProducts: "Loading products that use this unit"
95
+ }, c = {
68
96
  fieldLabel: "Item name",
69
97
  placeholder: "e.g., Office supplies",
70
98
  emptyText: "No saved items found - type to add an item",
71
99
  toggleListButton: "Show saved items"
72
100
  };
73
- export { a as MEASURE_UNITS_MANAGER_LABELS_EN, o as MEASURE_UNIT_DELETE_DIALOG_LABELS_EN, r as PRODUCT_FORM_SHEET_LABELS_EN, s as PRODUCT_SELECTOR_LABELS_EN, i as mergeProductFormSheetLabels };
101
+ export { a as MEASURE_UNITS_MANAGER_LABELS_EN, s as MEASURE_UNIT_DELETE_DIALOG_LABELS_EN, r as PRODUCT_FORM_SHEET_LABELS_EN, c as PRODUCT_SELECTOR_LABELS_EN, o as mergeMeasureUnitsManagerLabels, i as mergeProductFormSheetLabels };
@@ -1,186 +1,184 @@
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";
1
+ import { Combobox as e, FieldError 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, Textarea as d, Typography as f } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { InlineErrorAlert as p } from "../../../ui/dist/lib/InlineErrorAlert/InlineErrorAlert.js";
3
+ import "../../../ui/dist/index.js";
4
+ import { mergeProductFormSheetLabels as m } from "./index2.js";
5
+ import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
4
6
  // ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js
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", {
7
+ var v = "__no_unit__", y = "__add_unit__", b = "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";
8
+ function x({ id: e, message: n }) {
9
+ return n ? /* @__PURE__ */ g(t, {
8
10
  id: e,
9
- className: "ttw:text-sm ttw:text-destructive",
10
- children: t
11
+ children: n
11
12
  }) : null;
12
13
  }
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", {
14
+ function S({ idPrefix: t, values: S, errors: C, unitOptions: w, pricePrefix: T, onChange: E, onAddUnit: D, labels: O }) {
15
+ let k = m(O);
16
+ return /* @__PURE__ */ _(h, { children: [
17
+ /* @__PURE__ */ g(u, { labels: k.requiredFieldsLegend }),
18
+ C?.form && /* @__PURE__ */ g(p, { children: C.form }),
19
+ /* @__PURE__ */ _("fieldset", {
23
20
  className: "ttw:flex ttw:flex-col ttw:gap-2",
24
21
  children: [
25
- /* @__PURE__ */ m("legend", {
22
+ /* @__PURE__ */ g("legend", {
26
23
  className: "ttw:mb-1 ttw:text-sm ttw:font-medium",
27
- children: D.typeLabel
24
+ children: k.typeLabel
28
25
  }),
29
- /* @__PURE__ */ m(s, {
26
+ /* @__PURE__ */ g(c, {
30
27
  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 }),
28
+ value: S.type,
29
+ "aria-describedby": C?.type ? `${t}-type-error` : void 0,
30
+ onValueChange: (e) => E({ type: e }),
34
31
  children: [{
35
32
  value: "product",
36
- label: D.typeProduct
33
+ label: k.typeProduct
37
34
  }, {
38
35
  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, {
36
+ label: k.typeService
37
+ }].map((e) => /* @__PURE__ */ _(s, {
38
+ htmlFor: `${t}-type-${e.value}`,
39
+ className: b,
40
+ children: [/* @__PURE__ */ g(l, {
44
41
  value: e.value,
45
- id: `${b}-type-${e.value}`
46
- }), /* @__PURE__ */ m("span", {
42
+ id: `${t}-type-${e.value}`
43
+ }), /* @__PURE__ */ g("span", {
47
44
  className: "ttw:font-medium",
48
45
  children: e.label
49
46
  })]
50
47
  }, e.value))
51
48
  }),
52
- /* @__PURE__ */ m(y, {
53
- id: `${b}-type-error`,
54
- message: S?.type
49
+ /* @__PURE__ */ g(x, {
50
+ id: `${t}-type-error`,
51
+ message: C?.type
55
52
  })
56
53
  ]
57
54
  }),
58
- /* @__PURE__ */ h("div", {
55
+ /* @__PURE__ */ _("div", {
59
56
  className: "ttw:flex ttw:flex-col ttw:gap-1.5",
60
57
  children: [
61
- /* @__PURE__ */ m(o, {
62
- htmlFor: `${b}-name`,
63
- requirement: t.Required,
64
- labels: D.fieldMarkers,
65
- children: D.nameLabel
58
+ /* @__PURE__ */ g(s, {
59
+ htmlFor: `${t}-name`,
60
+ requirement: n.Required,
61
+ labels: k.fieldMarkers,
62
+ children: k.nameLabel
66
63
  }),
67
- /* @__PURE__ */ m(n, {
68
- id: `${b}-name`,
64
+ /* @__PURE__ */ g(r, {
65
+ id: `${t}-name`,
69
66
  "data-autofocus": !0,
70
67
  "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 })
68
+ value: S.name,
69
+ "aria-invalid": !!C?.name,
70
+ "aria-describedby": C?.name ? `${t}-name-error` : void 0,
71
+ onChange: (e) => E({ name: e.target.value })
77
72
  }),
78
- /* @__PURE__ */ m(y, {
79
- id: `${b}-name-error`,
80
- message: S?.name
73
+ /* @__PURE__ */ g(x, {
74
+ id: `${t}-name-error`,
75
+ message: C?.name
81
76
  })
82
77
  ]
83
78
  }),
84
- /* @__PURE__ */ h("div", {
79
+ /* @__PURE__ */ _("div", {
85
80
  className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
86
- children: [/* @__PURE__ */ h("div", {
81
+ children: [/* @__PURE__ */ _("div", {
87
82
  className: "ttw:flex ttw:flex-col ttw:gap-1.5",
88
83
  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
- })]
84
+ /* @__PURE__ */ g(s, {
85
+ htmlFor: `${t}-price`,
86
+ requirement: n.Optional,
87
+ labels: k.fieldMarkers,
88
+ children: k.priceLabel
111
89
  }),
112
- /* @__PURE__ */ m(y, {
113
- id: `${b}-price-error`,
114
- message: S?.pricePerUnit
90
+ /* @__PURE__ */ _(i, { children: [/* @__PURE__ */ g(a, {
91
+ align: "inline-start",
92
+ children: T
93
+ }), /* @__PURE__ */ g(o, {
94
+ id: `${t}-price`,
95
+ "data-has-start-addon": !0,
96
+ inputMode: "decimal",
97
+ placeholder: k.pricePlaceholder,
98
+ value: S.pricePerUnit,
99
+ "aria-invalid": !!C?.pricePerUnit || void 0,
100
+ "aria-describedby": C?.pricePerUnit ? `${t}-price-error` : void 0,
101
+ className: "ttw:text-end",
102
+ onChange: (e) => E({ pricePerUnit: e.target.value })
103
+ })] }),
104
+ /* @__PURE__ */ g(x, {
105
+ id: `${t}-price-error`,
106
+ message: C?.pricePerUnit
115
107
  })
116
108
  ]
117
- }), /* @__PURE__ */ h("div", {
109
+ }), /* @__PURE__ */ _("div", {
118
110
  className: "ttw:flex ttw:flex-col ttw:gap-1.5",
119
111
  children: [
120
- /* @__PURE__ */ m(o, {
121
- htmlFor: `${b}-unit`,
122
- requirement: t.Optional,
123
- labels: D.fieldMarkers,
124
- children: D.unitLabel
112
+ /* @__PURE__ */ g(s, {
113
+ htmlFor: `${t}-unit`,
114
+ requirement: n.Optional,
115
+ labels: k.fieldMarkers,
116
+ children: k.unitLabel
125
117
  }),
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,
118
+ /* @__PURE__ */ g(e, {
119
+ inputId: `${t}-unit`,
120
+ items: [
121
+ {
122
+ value: v,
123
+ label: k.noUnit
124
+ },
125
+ ...w,
126
+ ...D ? [{
127
+ value: y,
128
+ label: k.addUnit
129
+ }] : []
130
+ ],
131
+ value: S.unitId || null,
132
+ invalid: !!C?.unitId,
133
+ describedBy: C?.unitId ? `${t}-unit-error` : void 0,
136
134
  labels: {
137
- placeholder: D.unitPlaceholder,
138
- emptyMessage: D.unitEmpty,
139
- clearAriaLabel: D.unitClearAriaLabel
135
+ placeholder: k.unitPlaceholder,
136
+ emptyMessage: k.unitEmpty,
137
+ clearAriaLabel: k.unitClearAriaLabel
140
138
  },
141
- onValueChange: (e) => T({ unitId: typeof e == "string" && e !== g ? e : "" })
139
+ onValueChange: (e) => {
140
+ e === y ? D?.() : E({ unitId: typeof e == "string" && e !== v ? e : "" });
141
+ }
142
142
  }),
143
- /* @__PURE__ */ m(y, {
144
- id: `${b}-unit-error`,
145
- message: S?.unitId
143
+ /* @__PURE__ */ g(x, {
144
+ id: `${t}-unit-error`,
145
+ message: C?.unitId
146
146
  })
147
147
  ]
148
148
  })]
149
149
  }),
150
- /* @__PURE__ */ h("div", {
150
+ /* @__PURE__ */ _("div", {
151
151
  className: "ttw:flex ttw:flex-col ttw:gap-1.5",
152
152
  children: [
153
- /* @__PURE__ */ m(o, {
154
- htmlFor: `${b}-description`,
155
- requirement: t.Optional,
156
- labels: D.fieldMarkers,
157
- children: D.descriptionLabel
153
+ /* @__PURE__ */ g(s, {
154
+ htmlFor: `${t}-description`,
155
+ requirement: n.Optional,
156
+ labels: k.fieldMarkers,
157
+ children: k.descriptionLabel
158
158
  }),
159
- /* @__PURE__ */ m(u, {
160
- id: `${b}-description`,
159
+ /* @__PURE__ */ g(d, {
160
+ id: `${t}-description`,
161
161
  rows: 4,
162
- className: v,
163
- placeholder: D.descriptionPlaceholder,
164
- value: x.description,
162
+ value: S.description,
165
163
  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 })
164
+ "aria-invalid": !!C?.description,
165
+ "aria-describedby": C?.description ? `${t}-description-error` : void 0,
166
+ onChange: (e) => E({ description: e.target.value })
169
167
  }),
170
- /* @__PURE__ */ h("div", {
168
+ /* @__PURE__ */ _("div", {
171
169
  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, {
170
+ children: [/* @__PURE__ */ g(x, {
171
+ id: `${t}-description-error`,
172
+ message: C?.description
173
+ }), /* @__PURE__ */ g(f, {
176
174
  variant: "caption",
177
175
  color: "muted",
178
176
  className: "ttw:ml-auto ttw:leading-none",
179
- children: D.descriptionCount.replace("{count}", String(x.description.length))
177
+ children: k.descriptionCount.replace("{count}", String(S.description.length))
180
178
  })]
181
179
  })
182
180
  ]
183
181
  })
184
182
  ] });
185
183
  }
186
- export { b as ProductFormFields, b as default };
184
+ export { S as ProductFormFields, S as default };