@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,128 +1,51 @@
1
- import { cn as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { PRODUCT_SELECTOR_LABELS_EN as t } from "./index2.js";
3
- import { useCallback as n, useId as r, useRef as i, useState as a } from "react";
4
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
- import { CheckIcon as c, ChevronDownIcon as l, Loader2Icon as u } from "lucide-react";
1
+ import { AlertDialog as e, AlertDialogContent as t, AlertDialogDescription as n, AlertDialogFooter as r, AlertDialogHeader as i, AlertDialogTitle as a, Button as o, Spinner as s, Table as c, TableBody as l, TableCell as u, TableRow as d } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { MEASURE_UNIT_DELETE_DIALOG_LABELS_EN as f } from "./index2.js";
3
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
6
4
  //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js
7
- function d({ inputValue: d, onInputValueChange: f, options: p, value: m, onOptionSelect: h, isLoading: g, disabled: _, invalid: v, inputId: y, focusOnMount: b, maxLength: x, labels: S }) {
8
- let C = {
9
- ...t,
10
- ...S
11
- }, w = r(), [T, E] = a(!1), [D, O] = a(), k = p.findIndex((e) => e.value === D), A = () => {
12
- E(!1), O(void 0);
13
- }, j = (e) => {
14
- h(e), A();
15
- }, M = (e) => `${w}-option-${e}`, N = (e) => {
16
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
17
- if (e.preventDefault(), E(!0), !p.length) return;
18
- let t = e.key === "ArrowDown" ? Math.min(k + 1, p.length - 1) : Math.max(k - 1, 0);
19
- O(p[t].value), document.getElementById(M(t))?.scrollIntoView?.({ block: "nearest" });
20
- return;
21
- }
22
- if (e.key === "Enter") {
23
- e.preventDefault();
24
- let t = p[k];
25
- T && t ? j(t.value) : A();
26
- return;
27
- }
28
- if (e.key === "Tab" && T) {
29
- let e = d.trim().toLowerCase();
30
- if (!e) return;
31
- let t = p.find((t) => t.label.toLowerCase() === e) ?? (p.length === 1 ? p[0] : void 0);
32
- t ? j(t.value) : A();
33
- return;
34
- }
35
- e.key === "Escape" && T && (e.stopPropagation(), A());
36
- }, P = i(null), F = n((e) => {
37
- P.current = e, e && b && e.focus();
38
- }, [b]), I = () => {
39
- if (T) {
40
- A();
41
- return;
42
- }
43
- P.current?.focus(), E(!0);
44
- }, L = T && k >= 0 ? M(k) : void 0;
45
- return /* @__PURE__ */ s("div", {
46
- className: "ttw:relative ttw:w-full",
47
- children: [/* @__PURE__ */ s("div", {
48
- className: e("ttw:flex ttw:h-9 ttw:w-full ttw:min-w-0 ttw:items-center ttw:rounded-md ttw:border ttw:border-input ttw:shadow-xs ttw:transition-[color,box-shadow] ttw:has-[input:focus-visible]:border-ring ttw:has-[input:focus-visible]:ring-[3px] ttw:has-[input:focus-visible]:ring-ring/50 ttw:has-[[aria-invalid=true]]:border-destructive", _ && "ttw:opacity-50"),
49
- children: [
50
- g ? /* @__PURE__ */ o(u, { className: "ttw:pointer-events-none ttw:ml-3 ttw:size-4 ttw:shrink-0 ttw:animate-spin ttw:text-muted-foreground" }) : null,
51
- /* @__PURE__ */ o("input", {
52
- id: y,
53
- role: "combobox",
54
- "aria-label": C.fieldLabel,
55
- "aria-autocomplete": "list",
56
- "aria-expanded": T,
57
- "aria-controls": w,
58
- "aria-activedescendant": L,
59
- "aria-invalid": v || void 0,
60
- autoComplete: "off",
61
- ref: F,
62
- maxLength: x,
63
- disabled: _,
64
- placeholder: C.placeholder,
65
- className: e("ttw:h-full ttw:min-w-0 ttw:flex-1 ttw:text-ellipsis ttw:bg-transparent ttw:pr-2 ttw:text-base ttw:outline-none ttw:placeholder:text-muted-foreground ttw:disabled:cursor-not-allowed ttw:md:text-sm", g ? "ttw:pl-2" : "ttw:pl-3"),
66
- value: d,
67
- title: d || void 0,
68
- onFocus: () => E(!0),
69
- onClick: () => E(!0),
70
- onBlur: A,
71
- onChange: (e) => {
72
- f(e.target.value), E(!0), O(void 0);
73
- },
74
- onKeyDown: N
75
- }),
76
- /* @__PURE__ */ o("button", {
77
- type: "button",
78
- tabIndex: -1,
79
- "aria-label": C.toggleListButton,
80
- "aria-controls": w,
81
- "aria-expanded": T,
82
- disabled: _,
83
- className: "ttw:mr-[0.3rem] ttw:flex ttw:size-6 ttw:shrink-0 ttw:cursor-pointer ttw:items-center ttw:justify-center ttw:rounded-[calc(var(--radius)-5px)] ttw:text-muted-foreground ttw:transition-all ttw:hover:bg-accent ttw:hover:text-accent-foreground ttw:disabled:pointer-events-none",
84
- onMouseDown: (e) => e.preventDefault(),
85
- onClick: I,
86
- children: /* @__PURE__ */ o(l, { className: "ttw:pointer-events-none ttw:size-4" })
87
- })
88
- ]
89
- }), T && !_ ? /* @__PURE__ */ o("div", {
90
- role: "presentation",
91
- className: e("ttw:absolute ttw:left-0 ttw:top-full ttw:z-50 ttw:mt-1.5 ttw:w-full ttw:min-w-138 ttw:overflow-hidden ttw:rounded-md ttw:bg-popover ttw:text-popover-foreground ttw:shadow-md ttw:ring-1 ttw:ring-foreground/10", !p.length && "ttw:pointer-events-none"),
92
- onMouseDown: p.length ? (e) => e.preventDefault() : void 0,
93
- children: /* @__PURE__ */ s("ul", {
94
- id: w,
95
- role: "listbox",
96
- "aria-label": C.fieldLabel,
97
- className: "ttw:max-h-87 ttw:scroll-py-1 ttw:overflow-y-auto ttw:p-1",
98
- children: [p.map((t, n) => /* @__PURE__ */ s("li", {
99
- id: M(n),
100
- role: "option",
101
- "aria-selected": t.value === m,
102
- className: e("ttw:relative ttw:flex ttw:w-full ttw:cursor-default ttw:items-center ttw:gap-2 ttw:rounded-sm ttw:py-1.5 ttw:pr-8 ttw:pl-2 ttw:text-sm ttw:select-none", n === k && "ttw:bg-accent ttw:text-accent-foreground"),
103
- onMouseEnter: () => O(t.value),
104
- onMouseDown: () => j(t.value),
105
- children: [
106
- /* @__PURE__ */ o("span", {
107
- className: "ttw:min-w-0 ttw:flex-1 ttw:truncate",
108
- children: t.label
109
- }),
110
- t.meta ? /* @__PURE__ */ o("span", {
111
- className: "ttw:shrink-0 ttw:text-right ttw:text-xs ttw:text-muted-foreground",
112
- children: t.meta
113
- }) : null,
114
- t.value === m ? /* @__PURE__ */ o("span", {
115
- className: "ttw:pointer-events-none ttw:absolute ttw:right-2 ttw:flex ttw:size-4 ttw:items-center ttw:justify-center",
116
- children: /* @__PURE__ */ o(c, { className: "ttw:size-4" })
117
- }) : null
118
- ]
119
- }, t.value)), p.length ? null : /* @__PURE__ */ o("li", {
120
- className: "ttw:py-2 ttw:text-center ttw:text-sm ttw:text-muted-foreground",
121
- children: C.emptyText
122
- })]
123
- })
124
- }) : null]
5
+ function h({ open: h, onOpenChange: g, unitName: _, affectedProducts: v, isLoadingProducts: y, isDeleting: b, onConfirm: x, onCancel: S, labels: C }) {
6
+ let w = {
7
+ ...f,
8
+ ...C
9
+ }, T = v.length > 0;
10
+ return /* @__PURE__ */ p(e, {
11
+ open: h,
12
+ onOpenChange: g,
13
+ children: /* @__PURE__ */ m(t, { children: [
14
+ /* @__PURE__ */ m(i, { children: [/* @__PURE__ */ p(a, { children: (T ? w.titleWithItems : w.titleNoItems).replace("{name}", _) }), /* @__PURE__ */ p(n, { children: T ? w.messageWithItems : w.messageNoItems })] }),
15
+ /* @__PURE__ */ p("p", {
16
+ className: "ttw:text-sm ttw:text-muted-foreground",
17
+ children: T ? w.messageWithItemsHint : w.messageNoItemsHint
18
+ }),
19
+ y ? /* @__PURE__ */ p("div", {
20
+ className: "ttw:flex ttw:justify-center ttw:py-4",
21
+ children: /* @__PURE__ */ p(s, {})
22
+ }) : T ? /* @__PURE__ */ p("div", {
23
+ className: "ttw:max-h-60 ttw:overflow-auto ttw:rounded-md ttw:border",
24
+ children: /* @__PURE__ */ p(c, { children: /* @__PURE__ */ p(l, { children: v.map((e) => /* @__PURE__ */ m(d, {
25
+ className: "ttw:border-border ttw:hover:bg-transparent",
26
+ children: [/* @__PURE__ */ p(u, {
27
+ className: "ttw:pl-0 ttw:whitespace-normal ttw:text-text ttw:font-medium",
28
+ children: e.name
29
+ }), /* @__PURE__ */ p(u, {
30
+ className: "ttw:pr-0 ttw:text-right ttw:text-text ttw:font-medium",
31
+ children: e.priceLabel
32
+ })]
33
+ }, e.id)) }) })
34
+ }) : null,
35
+ /* @__PURE__ */ m(r, { children: [/* @__PURE__ */ p(o, {
36
+ variant: "ghost",
37
+ onClick: S,
38
+ disabled: b,
39
+ children: w.cancelButton
40
+ }), /* @__PURE__ */ p(o, {
41
+ variant: "destructive",
42
+ onClick: x,
43
+ disabled: b || y,
44
+ loading: b,
45
+ children: w.confirmButton
46
+ })] })
47
+ ] })
125
48
  });
126
49
  }
127
50
  //#endregion
128
- export { d as ProductSelector, d as default };
51
+ export { h as MeasureUnitDeleteDialog, h as default };
@@ -0,0 +1,128 @@
1
+ import { cn as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { PRODUCT_SELECTOR_LABELS_EN as t } from "./index2.js";
3
+ import { useCallback as n, useId as r, useRef as i, useState as a } from "react";
4
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
+ import { CheckIcon as c, ChevronDownIcon as l, Loader2Icon as u } from "lucide-react";
6
+ //#region ../../libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index7.js
7
+ function d({ inputValue: d, onInputValueChange: f, options: p, value: m, onOptionSelect: h, isLoading: g, disabled: _, invalid: v, inputId: y, focusOnMount: b, maxLength: x, labels: S }) {
8
+ let C = {
9
+ ...t,
10
+ ...S
11
+ }, w = r(), [T, E] = a(!1), [D, O] = a(), k = p.findIndex((e) => e.value === D), A = () => {
12
+ E(!1), O(void 0);
13
+ }, j = (e) => {
14
+ h(e), A();
15
+ }, M = (e) => `${w}-option-${e}`, N = (e) => {
16
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
17
+ if (e.preventDefault(), E(!0), !p.length) return;
18
+ let t = e.key === "ArrowDown" ? Math.min(k + 1, p.length - 1) : Math.max(k - 1, 0);
19
+ O(p[t].value), document.getElementById(M(t))?.scrollIntoView?.({ block: "nearest" });
20
+ return;
21
+ }
22
+ if (e.key === "Enter") {
23
+ e.preventDefault();
24
+ let t = p[k];
25
+ T && t ? j(t.value) : A();
26
+ return;
27
+ }
28
+ if (e.key === "Tab" && T) {
29
+ let e = d.trim().toLowerCase();
30
+ if (!e) return;
31
+ let t = p.find((t) => t.label.toLowerCase() === e) ?? (p.length === 1 ? p[0] : void 0);
32
+ t ? j(t.value) : A();
33
+ return;
34
+ }
35
+ e.key === "Escape" && T && (e.stopPropagation(), A());
36
+ }, P = i(null), F = n((e) => {
37
+ P.current = e, e && b && e.focus();
38
+ }, [b]), I = () => {
39
+ if (T) {
40
+ A();
41
+ return;
42
+ }
43
+ P.current?.focus(), E(!0);
44
+ }, L = T && k >= 0 ? M(k) : void 0;
45
+ return /* @__PURE__ */ s("div", {
46
+ className: "ttw:relative ttw:w-full",
47
+ children: [/* @__PURE__ */ s("div", {
48
+ className: e("ttw:flex ttw:h-9 ttw:w-full ttw:min-w-0 ttw:items-center ttw:rounded-md ttw:border ttw:border-input ttw:shadow-xs ttw:transition-[color,box-shadow] ttw:has-[input:focus-visible]:border-ring ttw:has-[input:focus-visible]:ring-[3px] ttw:has-[input:focus-visible]:ring-ring/50 ttw:has-[[aria-invalid=true]]:border-destructive", _ && "ttw:opacity-50"),
49
+ children: [
50
+ g ? /* @__PURE__ */ o(u, { className: "ttw:pointer-events-none ttw:ml-3 ttw:size-4 ttw:shrink-0 ttw:animate-spin ttw:text-muted-foreground" }) : null,
51
+ /* @__PURE__ */ o("input", {
52
+ id: y,
53
+ role: "combobox",
54
+ "aria-label": C.fieldLabel,
55
+ "aria-autocomplete": "list",
56
+ "aria-expanded": T,
57
+ "aria-controls": w,
58
+ "aria-activedescendant": L,
59
+ "aria-invalid": v || void 0,
60
+ autoComplete: "off",
61
+ ref: F,
62
+ maxLength: x,
63
+ disabled: _,
64
+ placeholder: C.placeholder,
65
+ className: e("ttw:h-full ttw:min-w-0 ttw:flex-1 ttw:text-ellipsis ttw:bg-transparent ttw:pr-2 ttw:text-base ttw:outline-none ttw:placeholder:text-muted-foreground ttw:disabled:cursor-not-allowed ttw:md:text-sm", g ? "ttw:pl-2" : "ttw:pl-3"),
66
+ value: d,
67
+ title: d || void 0,
68
+ onFocus: () => E(!0),
69
+ onClick: () => E(!0),
70
+ onBlur: A,
71
+ onChange: (e) => {
72
+ f(e.target.value), E(!0), O(void 0);
73
+ },
74
+ onKeyDown: N
75
+ }),
76
+ /* @__PURE__ */ o("button", {
77
+ type: "button",
78
+ tabIndex: -1,
79
+ "aria-label": C.toggleListButton,
80
+ "aria-controls": w,
81
+ "aria-expanded": T,
82
+ disabled: _,
83
+ className: "ttw:mr-[0.3rem] ttw:flex ttw:size-6 ttw:shrink-0 ttw:cursor-pointer ttw:items-center ttw:justify-center ttw:rounded-[calc(var(--radius)-5px)] ttw:text-muted-foreground ttw:transition-all ttw:hover:bg-accent ttw:hover:text-accent-foreground ttw:disabled:pointer-events-none",
84
+ onMouseDown: (e) => e.preventDefault(),
85
+ onClick: I,
86
+ children: /* @__PURE__ */ o(l, { className: "ttw:pointer-events-none ttw:size-4" })
87
+ })
88
+ ]
89
+ }), T && !_ ? /* @__PURE__ */ o("div", {
90
+ role: "presentation",
91
+ className: e("ttw:absolute ttw:left-0 ttw:top-full ttw:z-50 ttw:mt-1.5 ttw:w-full ttw:min-w-138 ttw:overflow-hidden ttw:rounded-md ttw:bg-popover ttw:text-popover-foreground ttw:shadow-md ttw:ring-1 ttw:ring-foreground/10", !p.length && "ttw:pointer-events-none"),
92
+ onMouseDown: p.length ? (e) => e.preventDefault() : void 0,
93
+ children: /* @__PURE__ */ s("ul", {
94
+ id: w,
95
+ role: "listbox",
96
+ "aria-label": C.fieldLabel,
97
+ className: "ttw:max-h-87 ttw:scroll-py-1 ttw:overflow-y-auto ttw:p-1",
98
+ children: [p.map((t, n) => /* @__PURE__ */ s("li", {
99
+ id: M(n),
100
+ role: "option",
101
+ "aria-selected": t.value === m,
102
+ className: e("ttw:relative ttw:flex ttw:w-full ttw:cursor-default ttw:items-center ttw:gap-2 ttw:rounded-sm ttw:py-1.5 ttw:pr-8 ttw:pl-2 ttw:text-sm ttw:select-none", n === k && "ttw:bg-accent ttw:text-accent-foreground"),
103
+ onMouseEnter: () => O(t.value),
104
+ onMouseDown: () => j(t.value),
105
+ children: [
106
+ /* @__PURE__ */ o("span", {
107
+ className: "ttw:min-w-0 ttw:flex-1 ttw:truncate",
108
+ children: t.label
109
+ }),
110
+ t.meta ? /* @__PURE__ */ o("span", {
111
+ className: "ttw:shrink-0 ttw:text-right ttw:text-xs ttw:text-muted-foreground",
112
+ children: t.meta
113
+ }) : null,
114
+ t.value === m ? /* @__PURE__ */ o("span", {
115
+ className: "ttw:pointer-events-none ttw:absolute ttw:right-2 ttw:flex ttw:size-4 ttw:items-center ttw:justify-center",
116
+ children: /* @__PURE__ */ o(c, { className: "ttw:size-4" })
117
+ }) : null
118
+ ]
119
+ }, t.value)), p.length ? null : /* @__PURE__ */ o("li", {
120
+ className: "ttw:py-2 ttw:text-center ttw:text-sm ttw:text-muted-foreground",
121
+ children: C.emptyText
122
+ })]
123
+ })
124
+ }) : null]
125
+ });
126
+ }
127
+ //#endregion
128
+ export { d as ProductSelector, d as default };
@@ -11,16 +11,17 @@ import { WIDGET_NAME as n } from "../analytics/events.js";
11
11
  import { TransfersWidgetInner as r } from "./TransfersWidgetInner.js";
12
12
  import { jsx as i, jsxs as a } from "react/jsx-runtime";
13
13
  //#region ../../libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetFeature.js
14
- function o({ labels: o, featureLabels: s, isTransferMoneyOpen: c, defaultIsTransferMoneyOpen: l, onTransferMoneyOpenChange: u, ...d }) {
14
+ function o({ labels: o, featureLabels: s, isTransferMoneyOpen: c, defaultIsTransferMoneyOpen: l, onTransferMoneyOpenChange: u, onLinkAccountClick: d, ...f }) {
15
15
  return /* @__PURE__ */ a(t, {
16
- ...d,
16
+ ...f,
17
17
  widgetName: n,
18
18
  children: [/* @__PURE__ */ i(e, {}), /* @__PURE__ */ i(r, {
19
19
  labels: o,
20
20
  featureLabels: s,
21
21
  isTransferMoneyOpen: c,
22
22
  defaultIsTransferMoneyOpen: l,
23
- onTransferMoneyOpenChange: u
23
+ onTransferMoneyOpenChange: u,
24
+ onLinkAccountClick: d
24
25
  })]
25
26
  });
26
27
  }
@@ -3,149 +3,140 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { TESOURO_NEW_EMBEDDED_BANK_ACCOUNT_CREATED_SUCCESS_EVENT as e, TESOURO_NEW_EXTERNAL_BANK_ACCOUNT_LINKED_SUCCESS_EVENT as t } from "../../../../../shared/util/dist/lib/widgetDomEvents.js";
6
- import { isOrganizationOnItsWay as n } from "../../../../../shared/data-access/dist/lib/organizationStatus.js";
7
- import { useEmbedApi as r } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
- import { Scope as i } from "../../../../../shared/data-access/dist/lib/scopes.js";
6
+ import { isOrganizationOnItsWay as ee } from "../../../../../shared/data-access/dist/lib/organizationStatus.js";
7
+ import { useEmbedApi as n } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
+ import { Scope as r } from "../../../../../shared/data-access/dist/lib/scopes.js";
9
9
  import "../../../../../shared/data-access/dist/index.js";
10
- import { useAnalyticsTrack as a } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
11
- import { useWidgetConfig as ee } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import { useAnalyticsTrack as te } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
11
+ import { useWidgetConfig as ne } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
12
  import "../../../../../shared/feature/dist/index.js";
13
- import { DEFAULT_FEATURE_LABELS as o } from "./featureLabels.js";
14
- import { TRANSFERS_ANALYTICS_EVENTS as s } from "../analytics/events.js";
15
- import { isPaginatedAccountsQueryInFlight as c } from "../../../../data-access/dist/index2.js";
16
- import { useTransferBankAccountsQuery as l } from "../../../../data-access/dist/index4.js";
17
- import { useTransferExternalAccountsQuery as u } from "../../../../data-access/dist/index5.js";
18
- import { useOrganizationTransfersQuery as te } from "../../../../data-access/dist/index6.js";
13
+ import { DEFAULT_FEATURE_LABELS as i } from "./featureLabels.js";
14
+ import { TRANSFERS_ANALYTICS_EVENTS as re } from "../analytics/events.js";
15
+ import { isPaginatedAccountsQueryInFlight as a } from "../../../../data-access/dist/index2.js";
16
+ import { useTransferBankAccountsQuery as ie } from "../../../../data-access/dist/index4.js";
17
+ import { useTransferExternalAccountsQuery as ae } from "../../../../data-access/dist/index5.js";
18
+ import { useOrganizationTransfersQuery as oe } from "../../../../data-access/dist/index6.js";
19
19
  import "../../../../data-access/dist/index.js";
20
- import { mapTransferToRowView as ne, useTransferMoneyModalController as re } from "./useTransferMoneyModalController.js";
21
- import { transfersWidgetTestIds as d } from "./testIds.js";
22
- import { TRANSFERS_PAGE_SIZE_OPTIONS as ie, useTransfersPageState as ae } from "./useTransfersPageState.js";
23
- import { TRANSFERS_WIDGET_LABELS_EN as oe } from "../../../../ui/dist/lib/TransfersWidget/labels.js";
24
- import { TransfersWidget as se } from "../../../../ui/dist/lib/TransfersWidget/TransfersWidget.js";
20
+ import { useTransferMoneyModalController as se } from "./useTransferMoneyModalController.js";
21
+ import { buildAccountDirectory as ce, mapTransferToDetailView as o, mapTransferToRowView as s } from "./transferViews.js";
22
+ import { transfersWidgetTestIds as c } from "./testIds.js";
23
+ import { TRANSFERS_PAGE_SIZE_OPTIONS as le, useTransfersPageState as ue } from "./useTransfersPageState.js";
24
+ import { TRANSFERS_WIDGET_LABELS_EN as de } from "../../../../ui/dist/lib/TransfersWidget/labels.js";
25
+ import { TransfersWidget as fe } from "../../../../ui/dist/lib/TransfersWidget/TransfersWidget.js";
25
26
  import "../../../../ui/dist/index.js";
26
- import { useCallback as ce, useEffect as f, useMemo as p, useState as m } from "react";
27
- import { jsx as h } from "react/jsx-runtime";
27
+ import { useCallback as pe, useEffect as l, useMemo as u, useState as d } from "react";
28
+ import { jsx as f } from "react/jsx-runtime";
28
29
  //#region ../../libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/TransfersWidgetInner.js
29
- var g = [i.TransferWriteOrg, i.BankAccountReadOrg], _ = [t, e];
30
- function v(e) {
31
- return e.slice(-4);
32
- }
33
- function y({ labels: e, featureLabels: t, isTransferMoneyOpen: y, defaultIsTransferMoneyOpen: le, onTransferMoneyOpenChange: ue }) {
34
- let b = {
35
- ...o,
30
+ var p = [r.TransferWriteOrg, r.BankAccountReadOrg], m = [t, e];
31
+ function h({ labels: e, featureLabels: t, isTransferMoneyOpen: h, defaultIsTransferMoneyOpen: me, onTransferMoneyOpenChange: he, onLinkAccountClick: g }) {
32
+ let _ = {
33
+ ...i,
36
34
  ...t
37
- }, x = {
38
- ...oe,
35
+ }, v = {
36
+ ...de,
39
37
  ...e,
40
38
  ...t?.routeSeparator === void 0 ? {} : { listAccountsSeparator: t.routeSeparator }
41
- }, S = a(), { initResponse: C } = ee(), { organizationId: de, organizationStatus: fe } = r(), pe = n(fe);
42
- f(() => {
43
- S(s.Mounted);
44
- }, [S]);
45
- let w = C?.scopes ?? [], T = w.includes(i.ExternalBankAccountReadOrg), me = w.includes(i.PaymentRailAch), E = T && me, D = g.every((e) => w.includes(e)), O = ae({
46
- organizationId: de,
47
- userId: C?.userId
48
- }), { data: k, isLoading: A, isError: j, isPlaceholderData: M, refetch: N } = te({
49
- limit: O.pageSize,
50
- pagination_token: O.paginationToken
51
- }), P = l(), { data: F, isError: I, refetch: L } = P, R = u({ enabled: T }), { data: z, isError: he, refetch: B } = R, V = F?.data ?? [], H = p(() => E ? (z?.data ?? []).filter((e) => e.verificationStatus === "VERIFIED" && e.accountStatus === "ACTIVE") : [], [E, z?.data]), U = p(() => {
52
- let e = /* @__PURE__ */ new Map();
53
- for (let t of V) {
54
- let n = v(t.accountNumber), r = t.nickname?.trim() || x.accountFallbackName;
55
- e.set(t.id, `${r} ···${n}`);
56
- }
57
- for (let t of H) {
58
- let n = v(t.accountNumber), r = t.nickname?.trim() || t.nameOnAccount;
59
- e.set(t.id, `${r} ···${n}`);
60
- }
61
- return e;
62
- }, [
63
- V,
64
- x.accountFallbackName,
65
- H
66
- ]), W = k?.data, G = p(() => (W ?? []).map((e) => ne(e, U, x, b)), [
67
- U,
68
- b,
69
- x,
70
- W
71
- ]), K = k?.nextPaginationToken ?? void 0, q = k?.prevPaginationToken ?? void 0, [J, ge] = m(O);
72
- !M && (J.pageIndex !== O.pageIndex || J.pageSize !== O.pageSize) && ge(O);
73
- let Y = J.pageIndex * J.pageSize, _e = {
74
- pageSize: O.pageSize,
75
- pageSizeOptions: ie,
76
- rangeLabel: `${b.viewingRangeLabel} ${G.length === 0 ? "0-0" : `${Y + 1}-${Y + G.length}`}`,
39
+ }, y = te(), { initResponse: b } = ne(), { organizationId: ge, organizationStatus: _e } = n(), ve = ee(_e);
40
+ l(() => {
41
+ y(re.Mounted);
42
+ }, [y]);
43
+ let x = b?.scopes ?? [], S = x.includes(r.ExternalBankAccountReadOrg), ye = x.includes(r.PaymentRailAch), C = S && ye, w = p.every((e) => x.includes(e)), T = ue({
44
+ organizationId: ge,
45
+ userId: b?.userId
46
+ }), { data: E, isLoading: D, isError: O, isPlaceholderData: k, refetch: A } = oe({
47
+ limit: T.pageSize,
48
+ pagination_token: T.paginationToken
49
+ }), j = ie(), { data: M, isError: N, refetch: P } = j, F = ae({ enabled: S }), { data: I, isError: be, refetch: L } = F, R = M?.data ?? [], z = u(() => C ? (I?.data ?? []).filter((e) => e.verificationStatus === "VERIFIED" && e.accountStatus === "ACTIVE") : [], [C, I?.data]), xe = I?.data, B = ce(R, xe ?? [], v), V = E?.data, H = (V ?? []).map((e) => s(e, B, v, _)), [Se, U] = d(), W = `${T.pageSize}:${T.paginationToken ?? ""}`, [Ce, we] = d(W);
50
+ W !== Ce && (we(W), U(void 0));
51
+ let G = V?.find((e) => e.id === Se), Te = G ? o(G, B, v, _) : void 0, K = E?.nextPaginationToken ?? void 0, q = E?.prevPaginationToken ?? void 0, [J, Ee] = d(T);
52
+ !k && (J.pageIndex !== T.pageIndex || J.pageSize !== T.pageSize) && Ee(T);
53
+ let Y = J.pageIndex * J.pageSize, De = {
54
+ pageSize: T.pageSize,
55
+ pageSizeOptions: le,
56
+ rangeLabel: `${_.viewingRangeLabel} ${H.length === 0 ? "0-0" : `${Y + 1}-${Y + H.length}`}`,
77
57
  isPreviousDisabled: !q,
78
58
  isNextDisabled: !K,
79
- isDisabled: M,
80
- onPageSizeChange: O.changePageSize,
59
+ isDisabled: k,
60
+ onPageSizeChange: T.changePageSize,
81
61
  onPreviousPageClick: () => {
82
- q && O.goToPreviousPage(q);
62
+ q && T.goToPreviousPage(q);
83
63
  },
84
64
  onNextPageClick: () => {
85
- K && O.goToNextPage(K);
65
+ K && T.goToNextPage(K);
86
66
  }
87
- }, X = ce(() => {
88
- N(), L(), T && B();
67
+ }, X = pe(() => {
68
+ A(), P(), S && L();
89
69
  }, [
90
- T,
70
+ S,
71
+ P,
91
72
  L,
92
- B,
93
- N
73
+ A
94
74
  ]);
95
- f(() => {
75
+ l(() => {
96
76
  let e = () => {
97
77
  X();
98
78
  };
99
- for (let t of _) window.addEventListener(t, e);
79
+ for (let t of m) window.addEventListener(t, e);
100
80
  return () => {
101
- for (let t of _) window.removeEventListener(t, e);
81
+ for (let t of m) window.removeEventListener(t, e);
102
82
  };
103
83
  }, [X]);
104
- let { modalProps: ve, openModal: Z } = re({
105
- labels: x,
106
- featureLabels: b,
107
- embeddedBankAccounts: V,
108
- verifiedExternalBankAccounts: H,
109
- track: S,
110
- isTransferMoneyOpen: y,
111
- defaultIsTransferMoneyOpen: le,
112
- onTransferMoneyOpenChange: ue
113
- }), ye = c(P), be = T && c(R), xe = pe && !F || A || ye || be, Q = j || I || T && he, Se = V.length + H.length, $ = !(V.length > 0) || Se <= 1;
114
- return /* @__PURE__ */ h(se, {
115
- transferRows: G,
116
- pagination: _e,
117
- isLoading: xe,
84
+ let { modalProps: Z, openModal: Oe } = se({
85
+ labels: v,
86
+ featureLabels: _,
87
+ embeddedBankAccounts: R,
88
+ verifiedExternalBankAccounts: z,
89
+ track: y,
90
+ isTransferMoneyOpen: h,
91
+ defaultIsTransferMoneyOpen: me,
92
+ onTransferMoneyOpenChange: he
93
+ }), ke = a(j), Ae = S && a(F), je = ve && !M || D || ke || Ae, Q = O || N || S && be, Me = R.length + z.length, $ = !(R.length > 0) || Me <= 1;
94
+ return /* @__PURE__ */ f(fe, {
95
+ transferRows: H,
96
+ pagination: De,
97
+ selectedRowKey: G?.id,
98
+ onRowClick: U,
99
+ transferDetail: Te,
100
+ onTransferDetailClose: () => U(void 0),
101
+ onLinkAccountClick: g ? () => {
102
+ U(void 0), g();
103
+ } : void 0,
104
+ isLoading: je,
118
105
  isError: Q,
119
106
  onRetry: Q ? () => void X() : void 0,
120
- showTransferMoneyCta: D,
107
+ showTransferMoneyCta: w,
121
108
  isTransferMoneyCtaDisabled: $,
122
- onTransferMoneyClick: D && !$ ? () => Z() : void 0,
109
+ onTransferMoneyClick: w && !$ ? () => Oe() : void 0,
123
110
  transferMoneyModal: {
124
- ...ve,
111
+ ...Z,
125
112
  testIds: {
126
- root: d.modal,
127
- closeButton: d.modalCloseButton,
128
- fromAccountTrigger: d.modalFromAccountTrigger,
129
- toAccountTrigger: d.modalToAccountTrigger,
130
- accountsConfirm: d.modalAccountsConfirmButton,
131
- amountInput: d.modalAmountInput,
113
+ root: c.modal,
114
+ closeButton: c.modalCloseButton,
115
+ fromAccountTrigger: c.modalFromAccountTrigger,
116
+ toAccountTrigger: c.modalToAccountTrigger,
117
+ accountsConfirm: c.modalAccountsConfirmButton,
118
+ amountInput: c.modalAmountInput,
132
119
  reviewStep: {
133
- confirm: d.modalConfirmTransferButton,
134
- goBack: d.modalGoBackButton
120
+ confirm: c.modalConfirmTransferButton,
121
+ goBack: c.modalGoBackButton
135
122
  },
136
- resultStep: { backToTransfers: d.modalBackToTransfersButton }
123
+ resultStep: { backToTransfers: c.modalBackToTransfersButton }
137
124
  }
138
125
  },
139
126
  labels: e,
140
127
  testIds: {
141
- transferMoneyButton: d.transferMoneyButton,
142
- skeleton: d.skeleton,
143
- error: d.error,
144
- retry: d.retry,
145
- empty: d.empty,
146
- transferRow: d.transferRow
128
+ transferMoneyButton: c.transferMoneyButton,
129
+ skeleton: c.skeleton,
130
+ error: c.error,
131
+ retry: c.retry,
132
+ empty: c.empty,
133
+ transferRow: c.transferRow,
134
+ transferDetail: {
135
+ root: c.transferDetail,
136
+ returnedBanner: c.transferDetailReturnedBanner
137
+ }
147
138
  }
148
139
  });
149
140
  }
150
141
  //#endregion
151
- export { y as TransfersWidgetInner };
142
+ export { h as TransfersWidgetInner };
@@ -5,6 +5,8 @@ var e = {
5
5
  retry: "transfers-widget-retry",
6
6
  empty: "transfers-widget-empty",
7
7
  transferRow: "embedded-banking-transfer-row",
8
+ transferDetail: "transfers-widget-transfer-detail",
9
+ transferDetailReturnedBanner: "transfers-widget-transfer-detail-returned-banner",
8
10
  transferMoneyButton: "embedded-banking-transfer-money-button",
9
11
  modal: "embedded-banking-transfer-money-modal",
10
12
  modalCloseButton: "embedded-banking-transfer-money-modal-close-button",