@tesouro/embedded-components-react 0.5.227 → 0.5.228

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 (59) hide show
  1. package/README.md +21 -21
  2. package/dist/index.d.ts +54 -34
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +54 -34
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +4 -4
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +29 -59
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +36 -141
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +26 -16
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +58 -37
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +228 -122
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +300 -147
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +34 -37
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +126 -122
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +150 -58
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +38 -91
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +113 -107
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +98 -231
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +111 -27
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +25 -624
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +631 -39
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +41 -40
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +35 -74
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +73 -115
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +115 -313
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +325 -0
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +15 -2
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +11 -12
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +42 -1
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +19 -3
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +73 -3
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +3 -1
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +16 -1
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +32 -4
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +304 -11
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +42 -258
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +62 -38
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +485 -61
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +90 -480
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +2 -0
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +3 -1
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +0 -3
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +100 -1
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +23 -95
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +231 -23
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +3 -236
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +249 -3
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +78 -234
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +53 -87
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +343 -49
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +29 -20
  53. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
  54. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +189 -211
  55. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +43 -59
  56. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  57. package/package.json +1 -1
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +0 -106
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +0 -353
@@ -1,48 +1,72 @@
1
- import { cn as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { jsx as t, jsxs as n } from "react/jsx-runtime";
1
+ import { Field as e, FieldContent as t, FieldDescription as n, FieldError as r, FieldLabel as i, Textarea as a, Typography as o } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
3
3
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js
4
- function r({ label: r, value: i, className: a }) {
5
- return /* @__PURE__ */ n("li", {
6
- className: e("ttw:flex ttw:items-center ttw:justify-between", a),
7
- children: [/* @__PURE__ */ t("span", { children: r }), /* @__PURE__ */ t("span", { children: i })]
8
- });
4
+ function l({ id: l, value: u, error: d, disabled: f, label: p, optionalSuffix: m, placeholder: h, description: g, onChange: _ }) {
5
+ return /* @__PURE__ */ s(e, { children: /* @__PURE__ */ c(t, { children: [
6
+ /* @__PURE__ */ c(i, {
7
+ htmlFor: l,
8
+ className: "ttw:text-nowrap",
9
+ children: [p, /* @__PURE__ */ s(o, {
10
+ variant: "body2",
11
+ component: "span",
12
+ color: "muted",
13
+ className: "ttw:leading-snug",
14
+ children: m
15
+ })]
16
+ }),
17
+ /* @__PURE__ */ s(a, {
18
+ id: l,
19
+ value: u,
20
+ disabled: f,
21
+ placeholder: h,
22
+ className: "ttw:h-26 ttw:resize-none",
23
+ "aria-invalid": !!d,
24
+ onChange: (e) => _(e.target.value)
25
+ }),
26
+ /* @__PURE__ */ s(n, { children: g }),
27
+ /* @__PURE__ */ s(r, { errors: d ? [{ message: d }] : [] })
28
+ ] }) });
9
29
  }
10
- function i({ totals: e, labels: i }) {
11
- return /* @__PURE__ */ n("ul", {
12
- className: "ttw:flex ttw:w-full ttw:list-none ttw:flex-col ttw:gap-1.5",
30
+ function u({ idPrefix: e, openingNote: t, closingNote: n, openingNoteError: r, closingNoteError: i, disabled: a, onOpeningNoteChange: u, onClosingNoteChange: d, labels: f }) {
31
+ return /* @__PURE__ */ c("div", {
32
+ className: "ttw:flex ttw:flex-col ttw:gap-2.5 ttw:rounded-xl ttw:border ttw:border-border ttw:p-6",
13
33
  children: [
14
- /* @__PURE__ */ t(r, {
15
- label: i.subtotalLabel,
16
- value: e.subtotal,
17
- className: "ttw:text-sm ttw:font-normal"
18
- }),
19
- /* @__PURE__ */ t(r, {
20
- label: i.discountTotalLabel,
21
- value: e.discount,
22
- className: "ttw:text-sm ttw:font-normal"
23
- }),
24
- /* @__PURE__ */ t(r, {
25
- label: i.nonTaxableSubtotalLabel,
26
- value: e.nonTaxableSubtotal,
27
- className: "ttw:text-sm ttw:font-normal ttw:text-muted-foreground"
28
- }),
29
- /* @__PURE__ */ t(r, {
30
- label: i.taxableSubtotalLabel,
31
- value: e.taxableSubtotal,
32
- className: "ttw:text-sm ttw:font-normal ttw:text-muted-foreground"
34
+ /* @__PURE__ */ c("div", {
35
+ className: "ttw:flex ttw:flex-col ttw:gap-2.5 ttw:pb-4",
36
+ children: [/* @__PURE__ */ s(o, {
37
+ variant: "h4",
38
+ children: f.notesHeading
39
+ }), /* @__PURE__ */ s(o, {
40
+ variant: "body2",
41
+ color: "muted",
42
+ className: "ttw:font-medium",
43
+ children: f.notesDescription
44
+ })]
33
45
  }),
34
- /* @__PURE__ */ t(r, {
35
- label: i.taxTotalLabel,
36
- value: e.tax,
37
- className: "ttw:text-sm ttw:font-normal"
46
+ /* @__PURE__ */ s(l, {
47
+ id: `${e}-opening-note`,
48
+ value: t,
49
+ error: r,
50
+ disabled: a,
51
+ label: f.openingNoteLabel,
52
+ optionalSuffix: f.optionalSuffix,
53
+ placeholder: f.openingNotePlaceholder,
54
+ description: f.openingNoteDescription,
55
+ onChange: u
38
56
  }),
39
- /* @__PURE__ */ t(r, {
40
- label: i.totalLabel,
41
- value: e.total,
42
- className: "ttw:text-lg ttw:font-medium"
57
+ /* @__PURE__ */ s(l, {
58
+ id: `${e}-closing-note`,
59
+ value: n,
60
+ error: i,
61
+ disabled: a,
62
+ label: f.closingNoteLabel,
63
+ optionalSuffix: f.optionalSuffix,
64
+ placeholder: f.closingNotePlaceholder,
65
+ description: f.closingNoteDescription,
66
+ onChange: d
43
67
  })
44
68
  ]
45
69
  });
46
70
  }
47
71
  //#endregion
48
- export { i as ReceivableFormTotals };
72
+ export { u as ReceivableNotesSection };
@@ -1,72 +1,496 @@
1
- import { Field as e, FieldContent as t, FieldDescription as n, FieldError as r, FieldLabel as i, Textarea as a, Typography as o } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
1
+ import { Alert as e, AlertDescription as t, Button as n, Checkbox as r, Field as i, FieldContent as a, FieldError as o, FieldLabel as s, Input as c, InputGroup as l, InputGroupAddon as u, InputGroupInput as d, Label as f, RadioGroup as p, RadioGroupItem as m, Select as h, SelectContent as g, SelectItem as _, SelectTrigger as v, SelectValue as y, Separator as b, Sheet as x, SheetContent as S, SheetDescription as C, SheetFooter as w, SheetHeader as T, SheetTitle as ee, Spinner as te, Typography as E, cn as D } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { RECEIVABLE_FORM_SHEET_LABELS_EN as ne } from "./index4.js";
3
+ import { ReceivableFormTotals as re } from "./index22.js";
4
+ import { ReceivableNotesSection as O } from "./index23.js";
5
+ import { useId as ie } from "react";
6
+ import { jsx as k, jsxs as A } from "react/jsx-runtime";
7
+ import { MinusIcon as j, PlusIcon as M, Trash2Icon as N } from "lucide-react";
3
8
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js
4
- function l({ id: l, value: u, error: d, disabled: f, label: p, optionalSuffix: m, placeholder: h, description: g, onChange: _ }) {
5
- return /* @__PURE__ */ s(e, { children: /* @__PURE__ */ c(t, { children: [
6
- /* @__PURE__ */ c(i, {
7
- htmlFor: l,
8
- className: "ttw:text-nowrap",
9
- children: [p, /* @__PURE__ */ s(o, {
10
- variant: "body2",
11
- component: "span",
12
- color: "muted",
13
- className: "ttw:leading-snug",
14
- children: m
15
- })]
16
- }),
17
- /* @__PURE__ */ s(a, {
18
- id: l,
19
- value: u,
20
- disabled: f,
21
- placeholder: h,
22
- className: "ttw:h-26 ttw:resize-none",
23
- "aria-invalid": !!d,
24
- onChange: (e) => _(e.target.value)
25
- }),
26
- /* @__PURE__ */ s(n, { children: g }),
27
- /* @__PURE__ */ s(r, { errors: d ? [{ message: d }] : [] })
28
- ] }) });
9
+ var P = "__none__", F = "__manage__";
10
+ function I({ message: e }) {
11
+ return e ? /* @__PURE__ */ k("p", {
12
+ className: "ttw:text-sm ttw:text-destructive",
13
+ children: e
14
+ }) : null;
29
15
  }
30
- function u({ idPrefix: e, openingNote: t, closingNote: n, openingNoteError: r, closingNoteError: i, disabled: a, onOpeningNoteChange: u, onClosingNoteChange: d, labels: f }) {
31
- return /* @__PURE__ */ c("div", {
32
- className: "ttw:flex ttw:flex-col ttw:gap-2.5 ttw:rounded-xl ttw:border ttw:border-border ttw:p-6",
16
+ function L({ formId: e, lineItem: t, errors: i, controls: a, focusOnMount: o, canRemove: s, unitOptions: c, currencySymbol: f, labels: p, renderProductSelector: m, onChange: b, onCommit: x, onQuantityStep: S, onManageUnits: C, onRemove: w }) {
17
+ let T = `${e}-line-${t.id}`;
18
+ return /* @__PURE__ */ A("li", {
19
+ className: "ttw:flex ttw:h-9 ttw:items-center ttw:gap-2.5",
33
20
  children: [
34
- /* @__PURE__ */ c("div", {
35
- className: "ttw:flex ttw:flex-col ttw:gap-2.5 ttw:pb-4",
36
- children: [/* @__PURE__ */ s(o, {
37
- variant: "h4",
38
- children: f.notesHeading
39
- }), /* @__PURE__ */ s(o, {
40
- variant: "body2",
41
- color: "muted",
42
- className: "ttw:font-medium",
43
- children: f.notesDescription
21
+ /* @__PURE__ */ k("div", {
22
+ className: "ttw:min-w-30 ttw:flex-1",
23
+ children: m(t, {
24
+ inputId: `${T}-name`,
25
+ invalid: !!i?.name,
26
+ focusOnMount: o
27
+ })
28
+ }),
29
+ /* @__PURE__ */ A("div", {
30
+ className: D("ttw:flex ttw:h-9 ttw:w-26 ttw:min-w-26 ttw:items-center ttw:rounded-md ttw:border ttw:border-input ttw:shadow-xs", i?.quantity && "ttw:border-destructive"),
31
+ children: [
32
+ /* @__PURE__ */ k("button", {
33
+ type: "button",
34
+ "aria-label": p.decreaseQuantityButton,
35
+ disabled: a ? !a.canDecreaseQuantity : !1,
36
+ className: "ttw:flex ttw:size-6 ttw:shrink-0 ttw:items-center ttw:justify-center ttw:rounded-sm ttw:text-muted-foreground ttw:hover:bg-accent ttw:disabled:pointer-events-none ttw:disabled:opacity-50",
37
+ onClick: () => S(-1),
38
+ children: /* @__PURE__ */ k(j, { className: "ttw:size-3.5" })
39
+ }),
40
+ /* @__PURE__ */ k("input", {
41
+ id: `${T}-quantity`,
42
+ "aria-label": p.quantityLabel,
43
+ "aria-invalid": !!i?.quantity || void 0,
44
+ type: "text",
45
+ inputMode: "decimal",
46
+ className: "ttw:h-full ttw:w-full ttw:min-w-0 ttw:bg-transparent ttw:px-0 ttw:text-center ttw:text-sm ttw:outline-none",
47
+ value: t.quantity,
48
+ onChange: (e) => b({ quantity: e.target.value }),
49
+ onBlur: () => x("quantity")
50
+ }),
51
+ /* @__PURE__ */ k("button", {
52
+ type: "button",
53
+ "aria-label": p.increaseQuantityButton,
54
+ disabled: a ? !a.canIncreaseQuantity : !1,
55
+ className: "ttw:flex ttw:size-6 ttw:shrink-0 ttw:items-center ttw:justify-center ttw:rounded-sm ttw:text-muted-foreground ttw:hover:bg-accent ttw:disabled:pointer-events-none ttw:disabled:opacity-50",
56
+ onClick: () => S(1),
57
+ children: /* @__PURE__ */ k(M, { className: "ttw:size-3.5" })
58
+ })
59
+ ]
60
+ }),
61
+ /* @__PURE__ */ A(h, {
62
+ value: t.unit || P,
63
+ onValueChange: (e) => {
64
+ if (e === F) {
65
+ C?.();
66
+ return;
67
+ }
68
+ b({ unit: e === P ? "" : e });
69
+ },
70
+ children: [/* @__PURE__ */ k(v, {
71
+ id: `${T}-unit`,
72
+ "aria-label": p.unitLabel,
73
+ "aria-invalid": !!i?.measureUnit || void 0,
74
+ className: "ttw:w-22",
75
+ children: /* @__PURE__ */ k(y, {
76
+ className: "ttw:truncate",
77
+ placeholder: p.unitPlaceholder
78
+ })
79
+ }), /* @__PURE__ */ A(g, { children: [
80
+ C && /* @__PURE__ */ A(_, {
81
+ value: F,
82
+ className: "ttw:font-semibold ttw:text-primary ttw:hover:text-primary ttw:focus:text-primary",
83
+ children: [/* @__PURE__ */ k(M, { className: "ttw:text-primary" }), p.manageUnitsOption]
84
+ }),
85
+ /* @__PURE__ */ k(_, {
86
+ value: P,
87
+ children: p.unitNone
88
+ }),
89
+ c.map((e) => /* @__PURE__ */ k(_, {
90
+ value: e.value,
91
+ children: e.label
92
+ }, e.value))
93
+ ] })]
94
+ }),
95
+ /* @__PURE__ */ A(l, {
96
+ className: "ttw:w-full ttw:max-w-41 ttw:min-w-29",
97
+ children: [/* @__PURE__ */ k(u, {
98
+ align: "inline-start",
99
+ children: f
100
+ }), /* @__PURE__ */ k(d, {
101
+ id: `${T}-price`,
102
+ "aria-label": p.priceLabel,
103
+ "aria-invalid": !!i?.price || void 0,
104
+ "data-has-start-addon": !0,
105
+ type: "text",
106
+ inputMode: "decimal",
107
+ className: "ttw:text-right",
108
+ value: t.price,
109
+ onChange: (e) => b({ price: e.target.value }),
110
+ onBlur: () => x("price")
44
111
  })]
45
112
  }),
46
- /* @__PURE__ */ s(l, {
47
- id: `${e}-opening-note`,
48
- value: t,
49
- error: r,
50
- disabled: a,
51
- label: f.openingNoteLabel,
52
- optionalSuffix: f.optionalSuffix,
53
- placeholder: f.openingNotePlaceholder,
54
- description: f.openingNoteDescription,
55
- onChange: u
113
+ /* @__PURE__ */ k("div", {
114
+ className: "ttw:flex ttw:w-12 ttw:min-w-12 ttw:items-center ttw:justify-center",
115
+ children: /* @__PURE__ */ k(r, {
116
+ id: `${T}-taxable`,
117
+ "aria-label": p.taxableLabel,
118
+ checked: t.taxable,
119
+ onCheckedChange: (e) => b({ taxable: e === !0 })
120
+ })
56
121
  }),
57
- /* @__PURE__ */ s(l, {
58
- id: `${e}-closing-note`,
59
- value: n,
60
- error: i,
61
- disabled: a,
62
- label: f.closingNoteLabel,
63
- optionalSuffix: f.optionalSuffix,
64
- placeholder: f.closingNotePlaceholder,
65
- description: f.closingNoteDescription,
66
- onChange: d
122
+ s && /* @__PURE__ */ k(n, {
123
+ type: "button",
124
+ variant: "ghost",
125
+ size: "sm",
126
+ "aria-label": p.removeLineItemButton,
127
+ className: "ttw:w-10 ttw:rounded-none ttw:border-l ttw:border-border ttw:pl-4 ttw:text-muted-foreground ttw:hover:bg-transparent ttw:hover:text-destructive ttw:has-[>svg]:pr-0",
128
+ onClick: w,
129
+ children: /* @__PURE__ */ k(N, {})
67
130
  })
68
131
  ]
69
132
  });
70
133
  }
134
+ function ae({ inputId: e, discountType: t, value: n, error: r, currencySymbol: c, disabled: f, labels: p, onChange: m, onTypeChange: h, onFocus: g, onBlur: _ }) {
135
+ let v = `${e}-error`, y = [{
136
+ type: "amount",
137
+ label: c,
138
+ ariaLabel: p.discountAmountOptionAriaLabel
139
+ }, {
140
+ type: "percentage",
141
+ label: p.discountPercentageOption,
142
+ ariaLabel: p.discountPercentageOptionAriaLabel
143
+ }];
144
+ return /* @__PURE__ */ A(i, {
145
+ className: "ttw:flex-col",
146
+ children: [/* @__PURE__ */ A(a, {
147
+ className: "ttw:flex-row ttw:items-center ttw:justify-end",
148
+ children: [/* @__PURE__ */ k(s, {
149
+ htmlFor: e,
150
+ className: D(r && "ttw:text-destructive"),
151
+ children: p.discountLabel
152
+ }), /* @__PURE__ */ A(l, {
153
+ className: "ttw:w-40 ttw:overflow-hidden",
154
+ children: [/* @__PURE__ */ k(u, {
155
+ align: "inline-start",
156
+ className: "ttw:gap-0 ttw:self-stretch ttw:p-0 ttw:has-[>button]:ml-0",
157
+ children: y.map((e) => /* @__PURE__ */ k("button", {
158
+ type: "button",
159
+ "aria-label": e.ariaLabel,
160
+ "aria-pressed": t === e.type,
161
+ disabled: f,
162
+ className: D("ttw:pointer-events-auto ttw:h-full ttw:w-9 ttw:cursor-pointer ttw:border-r ttw:border-input ttw:text-sm ttw:transition-colors ttw:disabled:pointer-events-none ttw:disabled:opacity-50", t === e.type ? "ttw:bg-primary ttw:text-primary-foreground" : "ttw:text-muted-foreground ttw:hover:bg-muted ttw:hover:text-foreground"),
163
+ onClick: () => h(e.type),
164
+ children: e.label
165
+ }, e.type))
166
+ }), /* @__PURE__ */ k(d, {
167
+ id: e,
168
+ type: "text",
169
+ inputMode: "decimal",
170
+ className: "ttw:text-right",
171
+ "aria-invalid": !!r || void 0,
172
+ "aria-describedby": r ? v : void 0,
173
+ disabled: f,
174
+ value: n,
175
+ onChange: (e) => m(e.target.value),
176
+ onFocus: g,
177
+ onBlur: _
178
+ })]
179
+ })]
180
+ }), r && /* @__PURE__ */ k(o, {
181
+ id: v,
182
+ className: "ttw:text-right",
183
+ children: r
184
+ })]
185
+ });
186
+ }
187
+ function R({ open: r, onOpenChange: j, mode: N = "create", values: P, errors: F, currencyOptions: R, unitOptions: oe, currencySymbol: z, lineItemControls: B, autoFocusLineItemId: V, lineItemsLoading: H, inProgress: U, customerSelector: W, renderProductSelector: G, onChange: K, onLineItemChange: q, onLineItemCommit: se, onLineItemQuantityStep: ce, onTaxRateCommit: J, onDiscountFocus: le, onDiscountCommit: ue, totals: de, onManageUnits: fe, onAddLineItem: pe, onRemoveLineItem: me, showDueDateField: Y, billingSection: he, remindersSection: ge, bankAccountSection: _e, attachmentsSection: ve, cancelDisabled: ye, draftButtonLabel: X, draftDisabled: be, primaryButtonLabel: xe, primaryDisabled: Se, scrollContainerRef: Ce, onSubmit: we, onDraftClick: Te, onPrimaryClick: Ee, onCancel: De, labels: Oe }) {
188
+ let Z = {
189
+ ...ne,
190
+ ...Oe
191
+ }, Q = ie(), $ = N === "edit", ke = D("ttw:grid ttw:gap-4", $ && Y ? "ttw:grid-cols-3" : "ttw:grid-cols-2");
192
+ return /* @__PURE__ */ k(x, {
193
+ open: r,
194
+ onOpenChange: j,
195
+ children: /* @__PURE__ */ A(S, {
196
+ ref: Ce,
197
+ className: "ttw:w-180 ttw:overflow-y-auto ttw:sm:max-w-180",
198
+ children: [
199
+ /* @__PURE__ */ A(T, { children: [/* @__PURE__ */ k(ee, { children: N === "edit" ? Z.editTitle : Z.createTitle }), /* @__PURE__ */ k(C, {
200
+ className: "ttw:sr-only",
201
+ children: Z.hiddenDescription
202
+ })] }),
203
+ /* @__PURE__ */ A("form", {
204
+ id: Q,
205
+ onSubmit: (e) => {
206
+ e.preventDefault(), e.stopPropagation(), we();
207
+ },
208
+ children: [/* @__PURE__ */ k("button", {
209
+ type: "submit",
210
+ className: "ttw:sr-only",
211
+ tabIndex: -1,
212
+ "aria-hidden": "true"
213
+ }), /* @__PURE__ */ A("div", {
214
+ className: "ttw:flex ttw:flex-col ttw:gap-5 ttw:px-6 ttw:pb-6",
215
+ children: [
216
+ /* @__PURE__ */ A("div", {
217
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
218
+ children: [
219
+ /* @__PURE__ */ k(f, { children: Z.documentTypeLabel }),
220
+ /* @__PURE__ */ A(p, {
221
+ className: "ttw:flex ttw:flex-row ttw:gap-6",
222
+ disabled: N === "edit",
223
+ value: P.type,
224
+ onValueChange: (e) => K({ type: e }),
225
+ children: [/* @__PURE__ */ A("div", {
226
+ className: "ttw:flex ttw:items-center ttw:gap-2",
227
+ children: [/* @__PURE__ */ k(m, {
228
+ value: "invoice",
229
+ id: `${Q}-invoice`
230
+ }), /* @__PURE__ */ k(f, {
231
+ htmlFor: `${Q}-invoice`,
232
+ children: Z.typeInvoice
233
+ })]
234
+ }), /* @__PURE__ */ A("div", {
235
+ className: "ttw:flex ttw:items-center ttw:gap-2",
236
+ children: [/* @__PURE__ */ k(m, {
237
+ value: "quote",
238
+ id: `${Q}-quote`
239
+ }), /* @__PURE__ */ k(f, {
240
+ htmlFor: `${Q}-quote`,
241
+ children: Z.typeQuote
242
+ })]
243
+ })]
244
+ }),
245
+ /* @__PURE__ */ k(I, { message: F?.type })
246
+ ]
247
+ }),
248
+ /* @__PURE__ */ A("div", {
249
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
250
+ children: [
251
+ /* @__PURE__ */ k(f, { children: Z.customerLabel }),
252
+ W,
253
+ /* @__PURE__ */ k("p", {
254
+ className: "ttw:text-xs ttw:text-muted-foreground",
255
+ children: Z.customerHint
256
+ }),
257
+ /* @__PURE__ */ k(I, { message: F?.customerId })
258
+ ]
259
+ }),
260
+ /* @__PURE__ */ A("div", {
261
+ className: ke,
262
+ children: [
263
+ /* @__PURE__ */ A("div", {
264
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
265
+ children: [
266
+ /* @__PURE__ */ k(f, {
267
+ htmlFor: `${Q}-currency`,
268
+ children: Z.currencyLabel
269
+ }),
270
+ /* @__PURE__ */ A(h, {
271
+ value: P.currency,
272
+ onValueChange: (e) => K({ currency: e }),
273
+ children: [/* @__PURE__ */ k(v, {
274
+ id: `${Q}-currency`,
275
+ children: /* @__PURE__ */ k(y, {})
276
+ }), /* @__PURE__ */ k(g, { children: R.map((e) => /* @__PURE__ */ k(_, {
277
+ value: e.value,
278
+ children: e.label
279
+ }, e.value)) })]
280
+ }),
281
+ /* @__PURE__ */ k(I, { message: F?.currency })
282
+ ]
283
+ }),
284
+ $ && /* @__PURE__ */ A("div", {
285
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
286
+ children: [
287
+ /* @__PURE__ */ k(f, {
288
+ htmlFor: `${Q}-issue-date`,
289
+ children: Z.issueDateLabel
290
+ }),
291
+ /* @__PURE__ */ k(c, {
292
+ id: `${Q}-issue-date`,
293
+ type: "date",
294
+ value: P.issueDate,
295
+ onChange: (e) => K({ issueDate: e.target.value })
296
+ }),
297
+ /* @__PURE__ */ k(I, { message: F?.issueDate })
298
+ ]
299
+ }),
300
+ Y && /* @__PURE__ */ A("div", {
301
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5",
302
+ children: [
303
+ /* @__PURE__ */ k(f, {
304
+ htmlFor: `${Q}-due-date`,
305
+ children: Z.dueDateLabel
306
+ }),
307
+ /* @__PURE__ */ k(c, {
308
+ id: `${Q}-due-date`,
309
+ type: "date",
310
+ value: P.dueDate,
311
+ onChange: (e) => K({ dueDate: e.target.value })
312
+ }),
313
+ /* @__PURE__ */ k(I, { message: F?.dueDate })
314
+ ]
315
+ })
316
+ ]
317
+ }),
318
+ he,
319
+ ge,
320
+ /* @__PURE__ */ A("div", {
321
+ className: "ttw:flex ttw:flex-col ttw:gap-2.5 ttw:rounded-xl ttw:border ttw:border-border ttw:p-6",
322
+ children: [
323
+ /* @__PURE__ */ A("div", {
324
+ className: "ttw:flex ttw:flex-col ttw:gap-2.5 ttw:pb-4",
325
+ children: [/* @__PURE__ */ k(E, {
326
+ variant: "h4",
327
+ children: Z.lineItemsHeading
328
+ }), /* @__PURE__ */ k(E, {
329
+ variant: "body2",
330
+ color: "muted",
331
+ className: "ttw:font-medium",
332
+ children: Z.lineItemsDescription
333
+ })]
334
+ }),
335
+ F?.lineItemsSummary?.length ? /* @__PURE__ */ k(e, {
336
+ variant: "destructive",
337
+ className: "ttw:mb-2",
338
+ children: /* @__PURE__ */ k(t, { children: /* @__PURE__ */ k("ul", { children: F.lineItemsSummary.map((e) => /* @__PURE__ */ k("li", { children: e }, e)) }) })
339
+ }) : null,
340
+ /* @__PURE__ */ A("ul", {
341
+ className: "ttw:flex ttw:flex-col ttw:gap-2.5",
342
+ children: [/* @__PURE__ */ A("li", {
343
+ "aria-hidden": !0,
344
+ className: "ttw:flex ttw:h-5 ttw:items-center ttw:gap-2.5 ttw:text-sm ttw:leading-5 ttw:font-medium",
345
+ children: [
346
+ /* @__PURE__ */ k("span", {
347
+ className: "ttw:inline-flex ttw:min-w-30 ttw:flex-1 ttw:whitespace-nowrap",
348
+ children: Z.productLabel
349
+ }),
350
+ /* @__PURE__ */ k("span", {
351
+ className: "ttw:w-24 ttw:min-w-24",
352
+ children: Z.quantityLabel
353
+ }),
354
+ /* @__PURE__ */ k("span", {
355
+ className: "ttw:w-20.5 ttw:min-w-20.5",
356
+ children: Z.unitLabel
357
+ }),
358
+ /* @__PURE__ */ k("span", {
359
+ className: "ttw:w-full ttw:max-w-41 ttw:min-w-29",
360
+ children: Z.priceLabel
361
+ }),
362
+ /* @__PURE__ */ k("span", {
363
+ className: "ttw:w-12 ttw:min-w-12",
364
+ children: Z.taxableLabel
365
+ }),
366
+ P.lineItems.length > 1 && /* @__PURE__ */ k("span", { className: "ttw:w-10 ttw:min-w-10" })
367
+ ]
368
+ }), H ? /* @__PURE__ */ k("li", {
369
+ className: "ttw:flex ttw:h-9 ttw:items-center ttw:justify-center",
370
+ children: /* @__PURE__ */ k(te, { className: "ttw:size-5" })
371
+ }) : P.lineItems.map((e) => /* @__PURE__ */ k(L, {
372
+ formId: Q,
373
+ lineItem: e,
374
+ errors: F?.lineItems?.[e.id],
375
+ controls: B?.[e.id],
376
+ focusOnMount: e.id === V,
377
+ canRemove: P.lineItems.length > 1,
378
+ unitOptions: oe,
379
+ currencySymbol: z,
380
+ labels: Z,
381
+ renderProductSelector: G,
382
+ onChange: (t) => q(e.id, t),
383
+ onCommit: (t) => se(e.id, t),
384
+ onQuantityStep: (t) => ce(e.id, t),
385
+ onManageUnits: fe,
386
+ onRemove: () => me(e.id)
387
+ }, e.id))]
388
+ }),
389
+ /* @__PURE__ */ A(n, {
390
+ type: "button",
391
+ variant: "ghost",
392
+ className: "ttw:w-fit ttw:text-primary ttw:hover:text-primary",
393
+ onClick: pe,
394
+ children: [/* @__PURE__ */ k(M, { className: "ttw:size-5 ttw:text-primary" }), Z.addLineItemButton]
395
+ }),
396
+ /* @__PURE__ */ k(ae, {
397
+ inputId: `${Q}-discount`,
398
+ discountType: P.discountType,
399
+ value: P.discount,
400
+ error: F?.discount,
401
+ currencySymbol: z,
402
+ disabled: U,
403
+ labels: Z,
404
+ onChange: (e) => K({ discount: e }),
405
+ onTypeChange: (e) => K({ discountType: e }),
406
+ onFocus: le,
407
+ onBlur: ue
408
+ }),
409
+ /* @__PURE__ */ A(i, {
410
+ className: "ttw:flex-col",
411
+ children: [/* @__PURE__ */ A(a, {
412
+ className: "ttw:flex-row ttw:justify-end",
413
+ children: [/* @__PURE__ */ k(s, {
414
+ htmlFor: `${Q}-tax-rate`,
415
+ className: D(F?.taxRate && "ttw:text-destructive"),
416
+ children: Z.taxRateLabel
417
+ }), /* @__PURE__ */ A(l, {
418
+ className: "ttw:w-40 ttw:has-[>[data-align=inline-end]]:[&>input]:pr-0",
419
+ children: [/* @__PURE__ */ k(d, {
420
+ id: `${Q}-tax-rate`,
421
+ className: "ttw:text-right",
422
+ placeholder: Z.taxRatePlaceholder,
423
+ type: "text",
424
+ inputMode: "decimal",
425
+ "aria-invalid": !!F?.taxRate || void 0,
426
+ "aria-describedby": F?.taxRate ? `${Q}-tax-rate-error` : void 0,
427
+ value: P.taxRate,
428
+ onChange: (e) => K({ taxRate: e.target.value }),
429
+ onBlur: J
430
+ }), /* @__PURE__ */ k(u, {
431
+ align: "inline-end",
432
+ children: Z.taxRateSuffix
433
+ })]
434
+ })]
435
+ }), F?.taxRate && /* @__PURE__ */ k(o, {
436
+ id: `${Q}-tax-rate-error`,
437
+ className: "ttw:text-right",
438
+ children: F.taxRate
439
+ })]
440
+ }),
441
+ /* @__PURE__ */ k(b, {}),
442
+ /* @__PURE__ */ k(re, {
443
+ totals: de,
444
+ labels: Z
445
+ })
446
+ ]
447
+ }),
448
+ _e,
449
+ /* @__PURE__ */ k(O, {
450
+ idPrefix: Q,
451
+ openingNote: P.openingNote,
452
+ closingNote: P.closingNote,
453
+ openingNoteError: F?.openingNote,
454
+ closingNoteError: F?.closingNote,
455
+ disabled: U,
456
+ onOpeningNoteChange: (e) => K({ openingNote: e }),
457
+ onClosingNoteChange: (e) => K({ closingNote: e }),
458
+ labels: Z
459
+ }),
460
+ ve
461
+ ]
462
+ })]
463
+ }),
464
+ /* @__PURE__ */ k(w, { children: /* @__PURE__ */ A("div", {
465
+ className: "ttw:flex ttw:justify-end ttw:gap-2",
466
+ children: [
467
+ /* @__PURE__ */ k(n, {
468
+ type: "button",
469
+ variant: "ghost",
470
+ disabled: ye,
471
+ onClick: De,
472
+ children: Z.cancelButton
473
+ }),
474
+ X && /* @__PURE__ */ k(n, {
475
+ type: "submit",
476
+ form: Q,
477
+ variant: "secondary",
478
+ disabled: be,
479
+ onClick: Te,
480
+ children: X
481
+ }),
482
+ /* @__PURE__ */ k(n, {
483
+ type: "submit",
484
+ form: Q,
485
+ disabled: Se,
486
+ onClick: Ee,
487
+ children: xe
488
+ })
489
+ ]
490
+ }) })
491
+ ]
492
+ })
493
+ });
494
+ }
71
495
  //#endregion
72
- export { u as ReceivableNotesSection };
496
+ export { R as ReceivableFormSheet, R as default };