@tesouro/embedded-components-react 0.7.70 → 0.7.73

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 (46) hide show
  1. package/README.md +15 -12
  2. package/dist/index.css +24 -6
  3. package/dist/index.d.ts +76 -8
  4. package/dist/lib/LinkedAccountsWidget.d.ts +9 -0
  5. package/dist/lib/ProductsWidget.d.ts +12 -6
  6. package/dist/lib/ReceivablesWidget.d.ts +1 -5
  7. package/dist/lib/TransfersWidget.d.ts +55 -2
  8. package/dist/lib/WidgetSuite.d.ts +63 -1
  9. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/lib/LinkedAccountsWidget.js +6 -4
  10. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/lib/useLinkedAccountsWidget.js +199 -182
  11. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +23 -24
  12. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/constants.js +6 -2
  13. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsTable.js +112 -51
  14. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductsWidget.js +80 -56
  15. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index.js +6 -5
  16. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index2.js +15 -6
  17. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js +170 -135
  18. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js +49 -150
  19. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index6.js +152 -24
  20. package/dist/libs/tesouro-embedded-components-react/products-widget/ui/dist/index7.js +28 -0
  21. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +13 -12
  23. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +2 -2
  24. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/ProductSelector.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js +41 -27
  26. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +70 -52
  27. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index.js +7 -6
  28. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +19 -8
  29. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +171 -218
  30. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +52 -180
  31. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index5.js +188 -46
  32. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +47 -124
  33. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js +128 -0
  34. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetFeature.js +4 -3
  35. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetInner.js +99 -108
  36. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/testIds.js +2 -0
  37. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/transferViews.js +135 -0
  38. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/useTransferMoneyModalController.js +140 -153
  39. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransferAccountTile.js +15 -0
  40. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransferDetailSheet.js +111 -0
  41. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransferStatusBadge.js +18 -0
  42. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransfersWidget.js +181 -126
  43. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/labels.js +33 -0
  44. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/TransfersSection.js +16 -8
  45. package/dist/packages/shared-ui-shadcn/dist/index.js +328 -327
  46. package/package.json +1 -1
@@ -1,157 +1,199 @@
1
- import { Button as e, DataTable as t, InputGroup as n, InputGroupAddon as r, InputGroupInput as i, Select as a, SelectContent as o, SelectItem as s, SelectTrigger as c, SelectValue as l } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { EmptyState as u } from "../../../shared/ui/dist/lib/EmptyState/EmptyState.js";
3
- import { ErrorState as d } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
1
+ import { Button as e, DataTable as t, FilterBar as n, FilterMenuButton as r, FilterTag as i, MultiSelectFilter as a, Popover as o, PopoverContent as s, PopoverTrigger as c, RadioGroup as l, RadioGroupItem as u, SearchInput as d } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { EmptyState as f } from "../../../shared/ui/dist/lib/EmptyState/EmptyState.js";
3
+ import { ErrorState as p } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
4
4
  import "../../../shared/ui/dist/index.js";
5
- import { PRODUCTS_SCREEN_LABELS_EN as f } from "./index2.js";
6
- import { ProductTypeBadge as p } from "./index3.js";
7
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
8
- import { ArrowDownIcon as _, ArrowUpDownIcon as v, ArrowUpIcon as y, Plus as b, Search as x } from "lucide-react";
5
+ import { PRODUCTS_SCREEN_LABELS_EN as m } from "./index2.js";
6
+ import { ProductTypeBadge as h } from "./index3.js";
7
+ import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
8
+ import { ArrowDownIcon as y, ArrowUpDownIcon as b, ArrowUpIcon as x, ListFilter as S } from "lucide-react";
9
9
  //#region ../../libs/tesouro-embedded-components-react/products-widget/ui/dist/index4.js
10
- var S = [
10
+ var C = [
11
11
  10,
12
12
  25,
13
13
  50,
14
14
  100
15
- ], C = "all";
16
- function w({ labels: e, searchValue: t, onSearchChange: u, typeFilter: d, onTypeFilterChange: f, unitFilter: p, onUnitFilterChange: m, unitOptions: _, headerActions: v }) {
17
- return /* @__PURE__ */ g("div", {
18
- className: "ttw:flex ttw:flex-wrap ttw:items-center ttw:gap-2 ttw:px-4",
19
- children: [
20
- /* @__PURE__ */ g(n, {
21
- className: "ttw:w-80",
22
- children: [/* @__PURE__ */ h(r, {
23
- align: "inline-start",
24
- children: /* @__PURE__ */ h(x, { className: "ttw:size-4" })
25
- }), /* @__PURE__ */ h(i, {
26
- "data-has-start-addon": !0,
27
- placeholder: e.searchPlaceholder,
28
- value: t,
29
- onChange: (e) => u(e.target.value)
30
- })]
31
- }),
32
- /* @__PURE__ */ g(a, {
33
- value: d,
34
- onValueChange: f,
35
- children: [/* @__PURE__ */ h(c, {
36
- className: "ttw:w-44",
37
- children: /* @__PURE__ */ h(l, {})
38
- }), /* @__PURE__ */ g(o, { children: [
39
- /* @__PURE__ */ h(s, {
40
- value: C,
41
- children: e.typeFilterAll
15
+ ], w = "ttw:flex ttw:w-full ttw:cursor-pointer ttw:items-center ttw:gap-2 ttw:rounded-md ttw:px-2 ttw:py-1.5 ttw:text-xs ttw:font-medium ttw:transition-colors ttw:hover:bg-accent";
16
+ function T({ labels: e, filters: t }) {
17
+ return /* @__PURE__ */ _(n, {
18
+ className: "ttw:flex-wrap ttw:px-4",
19
+ searchSlot: /* @__PURE__ */ _(d, {
20
+ value: t.searchValue,
21
+ onChange: (e) => t.onSearchChange(e.target.value),
22
+ placeholder: e.searchPlaceholder,
23
+ "aria-label": e.searchLabel,
24
+ className: "ttw:min-w-64"
25
+ }),
26
+ menuSlot: /* @__PURE__ */ v(o, {
27
+ open: t.isPopoverOpen,
28
+ onOpenChange: (e) => {
29
+ e || t.onPopoverClose();
30
+ },
31
+ children: [/* @__PURE__ */ _(c, {
32
+ asChild: !0,
33
+ children: /* @__PURE__ */ _(r, {
34
+ activeCount: t.activeFilterCount,
35
+ onClick: (e) => {
36
+ t.isPanelOpen && e.preventDefault(), t.onMenuToggle();
37
+ },
38
+ labels: { filters: e.filtersButton }
39
+ })
40
+ }), /* @__PURE__ */ v(s, {
41
+ align: "start",
42
+ className: "ttw:w-56 ttw:p-0",
43
+ children: [
44
+ t.isMenuOpen && /* @__PURE__ */ v("div", {
45
+ className: "ttw:p-1",
46
+ children: [/* @__PURE__ */ v("button", {
47
+ type: "button",
48
+ className: w,
49
+ onClick: t.onTypeFieldSelect,
50
+ children: [/* @__PURE__ */ _(S, {
51
+ className: "ttw:size-4 ttw:shrink-0 ttw:text-muted-foreground",
52
+ "aria-hidden": !0
53
+ }), e.filterFieldType]
54
+ }), /* @__PURE__ */ v("button", {
55
+ type: "button",
56
+ className: w,
57
+ onClick: t.onUnitFieldSelect,
58
+ children: [/* @__PURE__ */ _(S, {
59
+ className: "ttw:size-4 ttw:shrink-0 ttw:text-muted-foreground",
60
+ "aria-hidden": !0
61
+ }), e.filterFieldUnit]
62
+ })]
42
63
  }),
43
- /* @__PURE__ */ h(s, {
44
- value: "product",
45
- children: e.typeFilterProduct
64
+ t.isTypePanelOpen && /* @__PURE__ */ _(a, {
65
+ options: [...t.typeOptions],
66
+ selectedValues: [...t.selectedTypes],
67
+ onSelectionChange: t.onTypeChange
46
68
  }),
47
- /* @__PURE__ */ h(s, {
48
- value: "service",
49
- children: e.typeFilterService
69
+ t.isUnitPanelOpen && /* @__PURE__ */ _("div", {
70
+ className: "ttw:max-h-64 ttw:overflow-auto ttw:p-3",
71
+ children: /* @__PURE__ */ _(l, {
72
+ value: t.selectedUnit,
73
+ onValueChange: t.onUnitChange,
74
+ "aria-label": e.filterFieldUnit,
75
+ className: "ttw:flex ttw:flex-col ttw:gap-1",
76
+ children: t.unitOptions.map((e) => /* @__PURE__ */ v("label", {
77
+ className: "ttw:flex ttw:cursor-pointer ttw:items-center ttw:gap-2",
78
+ children: [/* @__PURE__ */ _(u, { value: e.value }), /* @__PURE__ */ _("span", {
79
+ className: "ttw:text-xs ttw:font-medium",
80
+ children: e.label
81
+ })]
82
+ }, e.value))
83
+ })
50
84
  })
51
- ] })]
52
- }),
53
- /* @__PURE__ */ g("div", {
54
- className: "ttw:ml-auto ttw:flex ttw:items-center ttw:gap-2",
55
- children: [/* @__PURE__ */ g(a, {
56
- value: p,
57
- onValueChange: m,
58
- children: [/* @__PURE__ */ h(c, {
59
- className: "ttw:w-44",
60
- children: /* @__PURE__ */ h(l, {})
61
- }), /* @__PURE__ */ g(o, { children: [/* @__PURE__ */ h(s, {
62
- value: C,
63
- children: e.unitFilterAll
64
- }), _.map((e) => /* @__PURE__ */ h(s, {
65
- value: e.value,
66
- children: e.label
67
- }, e.value))] })]
68
- }), v]
69
- })
70
- ]
85
+ ]
86
+ })]
87
+ }),
88
+ activeChipsSlot: /* @__PURE__ */ v(g, { children: [t.chips.map((n) => /* @__PURE__ */ _(i, {
89
+ label: n.label,
90
+ variant: "default",
91
+ labels: { remove: e.filterChipRemove },
92
+ onDismiss: () => t.onRemoveChip(n.key)
93
+ }, n.key)), t.chips.length > 0 && /* @__PURE__ */ _("button", {
94
+ type: "button",
95
+ className: "ttw:cursor-pointer ttw:whitespace-nowrap ttw:text-xs ttw:text-muted-foreground ttw:transition-colors ttw:hover:text-foreground",
96
+ onClick: t.onClearAll,
97
+ children: e.clearAllFilters
98
+ })] })
71
99
  });
72
100
  }
73
- function T({ products: n, isLoading: r, isError: i, sorting: a, onSortingChange: o, pageSize: s, onPageSizeChange: c, pageSizeOptions: l = S, hasNextPage: x, hasPrevPage: C, onNextPage: T, onPrevPage: E, searchValue: D, onSearchChange: O, typeFilter: k, onTypeFilterChange: A, unitFilter: j, onUnitFilterChange: M, unitOptions: N, isFiltering: P, onCreateClick: F, onManageUnitsClick: I, onRowClick: L, onRetry: R, canCreate: z = !0, canManageUnits: B = !0, isAccessRestricted: V, labels: H, testIds: U }) {
74
- let W = {
75
- ...f,
76
- ...H,
101
+ function E({ products: n, isLoading: r, isError: i, sorting: a, onSortingChange: o, pageSize: s, onPageSizeChange: c, pageSizeOptions: l = C, hasNextPage: u, hasPrevPage: d, onNextPage: S, onPrevPage: w, filters: E, isFiltering: D, onCreateClick: O, onManageUnitsClick: k, onRowClick: A, onRetry: j, canCreate: M = !0, canManageUnits: N = !0, isAccessRestricted: P, labels: F, testIds: I }) {
102
+ let L = {
103
+ ...m,
104
+ ...F,
77
105
  typeBadge: {
78
- ...f.typeBadge,
79
- ...H?.typeBadge
106
+ ...m.typeBadge,
107
+ ...F?.typeBadge
80
108
  }
81
- }, G = [
109
+ }, R = [
82
110
  {
83
111
  accessorKey: "name",
84
112
  enableSorting: !0,
85
113
  header: ({ column: t }) => {
86
114
  let n = t.getIsSorted();
87
- return /* @__PURE__ */ g("div", {
115
+ return /* @__PURE__ */ v("div", {
88
116
  className: "ttw:flex ttw:items-center ttw:gap-2 ttw:text-inherit",
89
- children: [W.columnName, /* @__PURE__ */ h(e, {
117
+ children: [L.columnName, /* @__PURE__ */ _(e, {
90
118
  variant: "ghost",
91
119
  size: "icon-sm",
92
120
  onClick: () => t.toggleSorting(n === "asc"),
93
- children: h(n === "asc" ? y : n === "desc" ? _ : v, { className: "ttw:size-4" })
121
+ children: _(n === "asc" ? x : n === "desc" ? y : b, { className: "ttw:size-4" })
94
122
  })]
95
123
  });
96
- }
124
+ },
125
+ size: 320,
126
+ cell: ({ row: e }) => /* @__PURE__ */ _("span", {
127
+ className: "ttw:block ttw:w-74 ttw:truncate",
128
+ children: e.original.name
129
+ })
97
130
  },
98
131
  {
99
132
  accessorKey: "type",
100
- header: W.columnType,
101
- cell: ({ row: e }) => e.original.type ? /* @__PURE__ */ h(p, {
102
- type: e.original.type,
103
- labels: W.typeBadge
104
- }) : null
133
+ size: 112,
134
+ header: L.columnType,
135
+ cell: ({ row: e }) => /* @__PURE__ */ _("div", {
136
+ className: "ttw:w-22",
137
+ children: e.original.type && /* @__PURE__ */ _(h, {
138
+ type: e.original.type,
139
+ labels: L.typeBadge
140
+ })
141
+ })
105
142
  },
106
143
  {
107
144
  accessorKey: "description",
108
- header: W.columnDescription,
109
- cell: ({ row: e }) => /* @__PURE__ */ h("div", {
110
- className: "ttw:w-120",
111
- children: /* @__PURE__ */ h("span", {
112
- className: "ttw:w-full ttw:inline-block ttw:truncate",
145
+ header: L.columnDescription,
146
+ size: 1e4,
147
+ cell: ({ row: e }) => /* @__PURE__ */ _("div", {
148
+ className: "ttw:relative ttw:h-5 ttw:min-w-40",
149
+ children: /* @__PURE__ */ _("span", {
150
+ className: "ttw:absolute ttw:inset-0 ttw:truncate",
113
151
  children: e.original.description
114
152
  })
115
153
  })
116
154
  },
117
155
  {
118
156
  accessorKey: "priceLabel",
119
- header: () => /* @__PURE__ */ h("div", {
157
+ size: 180,
158
+ header: () => /* @__PURE__ */ _("div", {
120
159
  className: "ttw:text-right",
121
- children: W.columnPrice
160
+ children: L.columnPrice
122
161
  }),
123
- cell: ({ row: e }) => /* @__PURE__ */ g("div", {
124
- className: "ttw:flex ttw:justify-end ttw:items-center ttw:gap-1",
125
- children: [/* @__PURE__ */ h("span", { children: e.original.priceLabel }), e.original.unitLabel && /* @__PURE__ */ h("span", {
126
- className: "ttw:text-muted-foreground ttw:text-xs",
162
+ cell: ({ row: e }) => /* @__PURE__ */ v("div", {
163
+ className: "ttw:flex ttw:w-39 ttw:justify-end ttw:items-center ttw:gap-1",
164
+ children: [/* @__PURE__ */ _("span", { children: e.original.priceLabel }), e.original.unitLabel && /* @__PURE__ */ _("span", {
165
+ className: "ttw:text-muted-foreground ttw:text-sm",
127
166
  children: e.original.unitLabel
128
167
  })]
129
168
  })
130
169
  }
131
- ], K = /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(e, {
132
- variant: "ghost",
133
- className: "ttw:text-primary ttw:hover:text-primary",
134
- onClick: I,
135
- disabled: !B,
136
- children: W.manageUnitsButton
137
- }), /* @__PURE__ */ g(e, {
138
- onClick: F,
139
- disabled: !z,
140
- children: [/* @__PURE__ */ h(b, { className: "ttw:size-4" }), W.createButton]
141
- })] });
142
- return /* @__PURE__ */ h("div", {
170
+ ];
171
+ return /* @__PURE__ */ _("div", {
143
172
  className: "ttw:flex ttw:flex-col ttw:gap-4",
144
- children: V ? /* @__PURE__ */ h(d, {
145
- testId: U?.accessRestricted,
146
- title: W.accessRestrictedTitle,
147
- description: W.accessRestrictedDescription
148
- }) : i ? /* @__PURE__ */ h(d, {
149
- title: W.errorTitle,
150
- description: W.errorDescription,
151
- retryLabel: R ? W.errorRetry : void 0,
152
- onRetry: R
153
- }) : /* @__PURE__ */ h(t, {
154
- columns: G,
173
+ children: P ? /* @__PURE__ */ _(p, {
174
+ testId: I?.accessRestricted,
175
+ title: L.accessRestrictedTitle,
176
+ description: L.accessRestrictedDescription
177
+ }) : i ? /* @__PURE__ */ _(p, {
178
+ title: L.errorTitle,
179
+ description: L.errorDescription,
180
+ retryLabel: j ? L.errorRetry : void 0,
181
+ onRetry: j
182
+ }) : /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ v("div", {
183
+ className: "ttw:flex ttw:flex-wrap ttw:items-center ttw:justify-end ttw:gap-2",
184
+ children: [/* @__PURE__ */ _(e, {
185
+ variant: "ghost",
186
+ className: "ttw:text-primary ttw:hover:text-primary",
187
+ onClick: k,
188
+ disabled: !N,
189
+ children: L.manageUnitsButton
190
+ }), /* @__PURE__ */ _(e, {
191
+ onClick: O,
192
+ disabled: !M,
193
+ children: L.createButton
194
+ })]
195
+ }), /* @__PURE__ */ _(t, {
196
+ columns: R,
155
197
  data: n,
156
198
  isLoading: r,
157
199
  sorting: a,
@@ -159,32 +201,25 @@ function T({ products: n, isLoading: r, isError: i, sorting: a, onSortingChange:
159
201
  pageSize: s,
160
202
  onPageSizeChange: c,
161
203
  pageSizeOptions: l,
162
- hasNextPage: x,
163
- hasPrevPage: C,
164
- onNextPage: T,
165
- onPrevPage: E,
166
- onRowClick: L,
167
- rowAriaLabel: (e) => W.openRow(e.name),
168
- filterComponent: /* @__PURE__ */ h(w, {
169
- labels: W,
170
- searchValue: D,
171
- onSearchChange: O,
172
- typeFilter: k,
173
- onTypeFilterChange: A,
174
- unitFilter: j,
175
- onUnitFilterChange: M,
176
- unitOptions: N,
177
- headerActions: K
204
+ hasNextPage: u,
205
+ hasPrevPage: d,
206
+ onNextPage: S,
207
+ onPrevPage: w,
208
+ onRowClick: A,
209
+ rowAriaLabel: (e) => L.openRow(e.name),
210
+ filterComponent: /* @__PURE__ */ _(T, {
211
+ labels: L,
212
+ filters: E
178
213
  }),
179
- children: /* @__PURE__ */ h(u, {
180
- testId: U?.empty,
181
- title: P ? W.filterEmptyTitle : W.emptyTitle,
182
- description: P ? W.filterEmptyDescription : W.emptyDescription,
183
- actionLabel: P || !z ? void 0 : W.emptyAction,
184
- onAction: P || !z ? void 0 : F
214
+ children: /* @__PURE__ */ _(f, {
215
+ testId: I?.empty,
216
+ title: D ? L.filterEmptyTitle : L.emptyTitle,
217
+ description: D ? L.filterEmptyDescription : L.emptyDescription,
218
+ actionLabel: D || !M ? void 0 : L.emptyAction,
219
+ onAction: D || !M ? void 0 : O
185
220
  })
186
- })
221
+ })] })
187
222
  });
188
223
  }
189
224
  //#endregion
190
- export { T as ProductsScreen, T as default };
225
+ export { E as ProductsScreen, E as default };
@@ -1,155 +1,54 @@
1
- import { Button as e, DropdownMenu as t, DropdownMenuContent as n, DropdownMenuItem as r, DropdownMenuTrigger as i, Sheet as a, SheetClose as o, SheetContent as s, SheetDescription as c, SheetHeader as l, SheetTitle as u, Skeleton as d, Spinner as f, Typography as p } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { ErrorState as m } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
3
- import "../../../shared/ui/dist/index.js";
4
- import { PRODUCT_DETAILS_SHEET_LABELS_EN as h } from "./index2.js";
5
- import { ProductTypeBadge as g } from "./index3.js";
6
- import { jsx as _, jsxs as v } from "react/jsx-runtime";
7
- import { MoreVertical as y, Trash2 as b, X as x } from "lucide-react";
8
- import { twMerge as S } from "tailwind-merge";
1
+ import { Button as e, Typography as t } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { mergeProductFormSheetLabels as n } from "../../../shared/product-catalog/ui/dist/index2.js";
3
+ import { ProductFormFields as r } from "../../../shared/product-catalog/ui/dist/index3.js";
4
+ import "../../../shared/product-catalog/ui/dist/index.js";
5
+ import { useId as i } from "react";
6
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
9
7
  //#region ../../libs/tesouro-embedded-components-react/products-widget/ui/dist/index5.js
10
- function C({ label: e, value: t, isLast: n, emptyValue: r = "—" }) {
11
- return /* @__PURE__ */ v("li", {
12
- className: S("ttw:flex ttw:gap-4 ttw:py-2.5", !n && "ttw:border-b ttw:border-border"),
13
- children: [/* @__PURE__ */ _(p, {
14
- variant: "body2",
15
- color: "muted",
16
- className: "ttw:w-35 ttw:min-w-35 ttw:font-medium",
17
- children: e
18
- }), typeof t == "string" ? /* @__PURE__ */ _(p, {
19
- variant: "body2",
20
- className: "ttw:font-medium",
21
- children: t || r
22
- }) : t]
23
- });
24
- }
25
- function w({ open: S, onOpenChange: w, product: T, isLoading: E, isError: D, onEdit: O, onDelete: k, canEdit: A = !0, canDelete: j = !0, labels: M }) {
26
- let N = {
27
- ...h,
28
- ...M,
29
- typeBadge: {
30
- ...h.typeBadge,
31
- ...M?.typeBadge
32
- }
33
- }, P = T?.type !== "service", F = P ? N.typeBadge.product : N.typeBadge.service, I = T ? N.subtitle.replace("{type}", F).replace("{createdAt}", T.createdAtLabel) : N.hiddenDescription;
34
- return /* @__PURE__ */ _(a, {
35
- open: S,
36
- onOpenChange: w,
37
- children: /* @__PURE__ */ v(s, {
38
- className: "ttw:w-150 ttw:sm:max-w-150 ttw:gap-0",
39
- showCloseButton: !1,
40
- children: [/* @__PURE__ */ v(l, {
41
- className: "ttw:pt-6 ttw:pl-6 ttw:pr-4 ttw:pb-7 ttw:flex-row ttw:gap-3 ttw:border-b ttw:border-border",
42
- children: [/* @__PURE__ */ v("div", {
43
- className: "ttw:flex ttw:flex-col ttw:gap-1.5 ttw:flex-1 ttw:min-w-0",
44
- children: [/* @__PURE__ */ _(u, {
45
- className: "ttw:text-2xl",
46
- children: E ? /* @__PURE__ */ _(d, { className: "ttw:h-7 ttw:w-40" }) : T?.name ?? N.loadingTitle
47
- }), /* @__PURE__ */ _(c, {
48
- asChild: !0,
49
- children: /* @__PURE__ */ _("div", { children: E ? /* @__PURE__ */ _(d, { className: "ttw:h-4 ttw:w-60" }) : I })
50
- })]
51
- }), /* @__PURE__ */ v("div", {
52
- className: "ttw:flex ttw:gap-2 ttw:shrink-0",
53
- children: [j && /* @__PURE__ */ v(t, { children: [/* @__PURE__ */ _(i, {
54
- asChild: !0,
55
- children: /* @__PURE__ */ _(e, {
56
- type: "button",
57
- variant: "outline",
58
- disabled: !T,
59
- "aria-label": N.moreActionsLabel,
60
- className: "ttw:p-2 ttw:size-9 ttw:border-none ttw:bg-muted",
61
- children: /* @__PURE__ */ _(y, { className: "ttw:size-4" })
62
- })
63
- }), /* @__PURE__ */ _(n, {
64
- align: "end",
65
- children: /* @__PURE__ */ v(r, {
66
- onClick: k,
67
- variant: "destructive",
68
- children: [/* @__PURE__ */ _(b, { className: "ttw:size-4" }), N.deleteProductOption.replace("{type}", F)]
69
- })
70
- })] }), /* @__PURE__ */ _(o, {
71
- "aria-label": N.closeLabel,
72
- className: "ttw:size-9 ttw:bg-muted ttw:p-2 ttw:flex ttw:items-center ttw:justify-center ttw:rounded-md ttw:cursor-pointer",
73
- children: /* @__PURE__ */ _(x, { className: "ttw:size-4" })
74
- })]
75
- })]
76
- }), D ? /* @__PURE__ */ _(m, {
77
- title: N.errorTitle,
78
- description: N.errorDescription
79
- }) : E || !T ? /* @__PURE__ */ _("div", {
80
- className: "ttw:flex ttw:w-full ttw:h-full ttw:items-center ttw:justify-center",
81
- children: /* @__PURE__ */ _(f, {})
82
- }) : /* @__PURE__ */ _("main", {
83
- className: "ttw:p-6 ttw:overflow-auto ttw:flex ttw:flex-col ttw:gap-4",
84
- children: /* @__PURE__ */ v("div", {
85
- className: "ttw:flex ttw:flex-col ttw:gap-4",
86
- children: [/* @__PURE__ */ v("div", {
87
- className: "ttw:flex ttw:items-center ttw:justify-between ttw:gap-3 ttw:pt-6 ttw:pb-7 ttw:border-b ttw:border-border",
88
- children: [/* @__PURE__ */ v("div", {
89
- className: "ttw:flex ttw:flex-col ttw:gap-1.5",
90
- children: [/* @__PURE__ */ _(p, {
91
- variant: "body1",
92
- className: "ttw:font-medium",
93
- children: N.sectionHeading.replace("{type}", F)
94
- }), /* @__PURE__ */ _(p, {
95
- variant: "body2",
96
- color: "muted",
97
- children: P ? N.typeProductDescription : N.typeServiceDescription
98
- })]
99
- }), A && /* @__PURE__ */ _(e, {
100
- type: "button",
101
- variant: "ghost",
102
- className: "ttw:text-primary ttw:hover:text-primary",
103
- onClick: O,
104
- children: N.editButton
105
- })]
106
- }), /* @__PURE__ */ v("ul", {
107
- className: "ttw:list-none ttw:p-0 ttw:m-0",
108
- children: [
109
- /* @__PURE__ */ _(C, {
110
- label: N.rowName.replace("{type}", F),
111
- value: T.name,
112
- emptyValue: N.rowEmptyValue
113
- }),
114
- /* @__PURE__ */ _(C, {
115
- label: N.rowPrice,
116
- value: T.priceLabel,
117
- emptyValue: N.rowEmptyValue
118
- }),
119
- /* @__PURE__ */ _(C, {
120
- label: N.rowDescription,
121
- value: T.description,
122
- emptyValue: N.rowEmptyValue
123
- }),
124
- /* @__PURE__ */ _(C, {
125
- label: N.rowType,
126
- value: T.type ? /* @__PURE__ */ _(g, {
127
- type: T.type,
128
- labels: N.typeBadge
129
- }) : N.rowEmptyValue
130
- }),
131
- /* @__PURE__ */ _(C, {
132
- label: N.rowUnit,
133
- value: T.unitLabel,
134
- emptyValue: N.rowEmptyValue
135
- }),
136
- /* @__PURE__ */ _(C, {
137
- label: N.rowCreatedOn,
138
- value: T.createdAtLabel,
139
- emptyValue: N.rowEmptyValue
140
- }),
141
- /* @__PURE__ */ _(C, {
142
- label: N.rowLastUpdate,
143
- value: T.updatedAtLabel,
144
- emptyValue: N.rowEmptyValue,
145
- isLast: !0
146
- })
147
- ]
148
- })]
8
+ function s({ form: s }) {
9
+ let c = n(s.labels), l = i();
10
+ return /* @__PURE__ */ o("form", {
11
+ className: "ttw:flex ttw:flex-col ttw:gap-4 ttw:rounded-[10px] ttw:border ttw:border-border ttw:bg-muted ttw:p-4",
12
+ onSubmit: (e) => {
13
+ e.preventDefault(), e.stopPropagation(), s.onSubmit();
14
+ },
15
+ children: [
16
+ /* @__PURE__ */ a("div", {
17
+ className: "ttw:flex ttw:flex-col ttw:gap-1.5 ttw:border-b ttw:border-border ttw:pt-6 ttw:pb-7",
18
+ children: /* @__PURE__ */ a(t, {
19
+ variant: "body1",
20
+ className: "ttw:font-medium",
21
+ children: s.heading
149
22
  })
150
- })]
151
- })
23
+ }),
24
+ /* @__PURE__ */ a(r, {
25
+ idPrefix: l,
26
+ values: s.values,
27
+ errors: s.errors,
28
+ unitOptions: s.unitOptions,
29
+ pricePrefix: s.pricePrefix,
30
+ onChange: s.onChange,
31
+ labels: s.labels
32
+ }),
33
+ /* @__PURE__ */ o("div", {
34
+ className: "ttw:flex ttw:justify-end ttw:gap-4 ttw:pt-6",
35
+ children: [/* @__PURE__ */ a(e, {
36
+ type: "button",
37
+ variant: "outline",
38
+ className: "ttw:w-fit ttw:border-border",
39
+ disabled: s.inProgress,
40
+ onClick: s.onCancel,
41
+ children: c.cancelButton
42
+ }), /* @__PURE__ */ a(e, {
43
+ type: "submit",
44
+ className: "ttw:w-fit",
45
+ disabled: s.inProgress || s.submitDisabled,
46
+ loading: s.inProgress,
47
+ children: c.saveButton
48
+ })]
49
+ })
50
+ ]
152
51
  });
153
52
  }
154
53
  //#endregion
155
- export { w as ProductDetailsSheet, w as default };
54
+ export { s as ProductEditForm, s as default };