@tesouro/embedded-components-react 0.11.70 → 0.11.72

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 (97) hide show
  1. package/README.md +1 -0
  2. package/dist/index.css +41 -192
  3. package/dist/index.d.ts +93 -73
  4. package/dist/lib/SettingsWidget.d.ts +5 -1
  5. package/dist/lib/WidgetSuite.d.ts +22 -2
  6. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index3.js +8 -7
  7. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index4.js +4 -1
  8. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index6.js +196 -131
  9. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index.js +4 -4
  10. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index3.js +11 -1
  11. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index4.js +5 -3
  12. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index5.js +38 -32
  13. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index6.js +103 -75
  14. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index7.js +140 -168
  15. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index8.js +97 -87
  16. package/dist/libs/tesouro-embedded-components-react/settings-widget/chart-of-accounts/feature/dist/index7.js +11 -7
  17. package/dist/libs/tesouro-embedded-components-react/settings-widget/chart-of-accounts/feature/dist/index8.js +0 -1
  18. package/dist/libs/tesouro-embedded-components-react/settings-widget/chart-of-accounts/ui/dist/index2.js +3 -1
  19. package/dist/libs/tesouro-embedded-components-react/settings-widget/chart-of-accounts/ui/dist/index3.js +134 -177
  20. package/dist/libs/tesouro-embedded-components-react/settings-widget/chart-of-accounts/ui/dist/index4.js +110 -176
  21. package/dist/libs/tesouro-embedded-components-react/settings-widget/chart-of-accounts/ui/dist/index5.js +28 -38
  22. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/lib/ExpenseSettingsTabs/ExpenseSettingsTabs.js +13 -10
  23. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/lib/SettingsWidget/SettingsWidget.js +28 -24
  24. package/dist/libs/tesouro-embedded-components-react/settings-widget/help/ui/shadcn/dist/index3.js +35 -31
  25. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index10.js +2 -0
  26. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index7.js +1 -5
  27. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index8.js +3 -0
  28. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/ui/dist/index11.js +2 -1
  29. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/ui/dist/index12.js +22 -36
  30. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/ui/dist/index16.js +1 -1
  31. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/ui/dist/index17.js +54 -60
  32. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/ui/dist/index20.js +75 -60
  33. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/ui/dist/index3.js +42 -27
  34. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/ui/dist/index6.js +89 -82
  35. package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/ui/dist/index9.js +39 -38
  36. package/dist/libs/tesouro-embedded-components-react/settings-widget/profile/feature/dist/index4.js +32 -32
  37. package/dist/libs/tesouro-embedded-components-react/settings-widget/profile/ui/dist/index2.js +1 -1
  38. package/dist/libs/tesouro-embedded-components-react/settings-widget/profile/ui/dist/index3.js +56 -71
  39. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index10.js +3 -0
  40. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index12.js +86 -66
  41. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index13.js +51 -51
  42. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index15.js +146 -132
  43. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index17.js +95 -99
  44. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index3.js +1 -0
  45. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index4.js +8 -27
  46. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index5.js +69 -72
  47. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index6.js +51 -51
  48. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index.js +9 -11
  49. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index10.js +83 -298
  50. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index11.js +13 -13
  51. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index12.js +122 -75
  52. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index13.js +41 -15
  53. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index14.js +7 -131
  54. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index15.js +147 -48
  55. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index16.js +240 -11
  56. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index17.js +15 -173
  57. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index2.js +38 -10
  58. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index3.js +5 -46
  59. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index4.js +52 -45
  60. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index5.js +101 -25
  61. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index6.js +40 -98
  62. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index7.js +415 -40
  63. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index8.js +261 -332
  64. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index9.js +15 -8
  65. package/dist/libs/tesouro-embedded-components-react/settings-widget/ui/dist/lib/SettingsWidgetUi/SettingsWidgetUi.js +2 -2
  66. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/ApprovalPoliciesSettings.js +9 -8
  67. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApprovalPolicyRules.js +136 -122
  68. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index.js +9 -8
  69. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index11.js +16 -17
  70. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index12.js +99 -100
  71. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index16.js +1 -1
  72. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index17.js +8 -8
  73. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index18.js +10 -55
  74. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index19.js +34 -8
  75. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index20.js +8 -84
  76. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index21.js +86 -0
  77. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index3.js +13 -13
  78. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index5.js +17 -18
  79. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index7.js +33 -42
  80. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  81. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/index.js +24 -24
  82. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/FileDropZone/FileDropZone.js +62 -0
  83. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/LoadingRegion/LoadingRegion.js +1 -0
  84. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/WidgetSuiteProvider.js +12 -4
  85. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/labels.js +9 -0
  86. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/BillPaySection.js +12 -9
  87. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/CardsSection.js +25 -23
  88. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/DashboardQuickActions.js +74 -0
  89. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/DashboardSection.js +20 -16
  90. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/InvoicingSection.js +15 -9
  91. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/SettingsSection.js +15 -8
  92. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/TransfersSection.js +23 -21
  93. package/dist/packages/shared-ui-shadcn/dist/index.js +2336 -2274
  94. package/package.json +1 -1
  95. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index18.js +0 -291
  96. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index19.js +0 -22
  97. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/avatarSwatch.js +0 -26
@@ -1,88 +1,116 @@
1
- import { Badge as e, Button as t } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { AmountConditionType as n, ApprovalOutcomeType as r } from "./index2.js";
3
- import { ApprovalRuleCardLabels as i } from "./index3.js";
4
- import { formatAmount as a } from "./index4.js";
5
- import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
6
- import { RefreshCw as l, SquarePen as u, Trash2 as d } from "lucide-react";
1
+ import { Badge as e, Button as t, Tooltip as n, TooltipContent as r, TooltipProvider as i, TooltipTrigger as a } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { PolicyCardFrame as o } from "../../../../shared/approval-policy/ui/dist/index17.js";
3
+ import "../../../../shared/approval-policy/ui/dist/index.js";
4
+ import { AmountConditionType as s, ApprovalOutcomeType as c } from "./index2.js";
5
+ import { ApprovalRuleCardLabels as l } from "./index3.js";
6
+ import { formatAmount as u } from "./index4.js";
7
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
8
+ import { Trash2 as m } from "lucide-react";
7
9
  // ../../libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index6.js
8
- function f({ conditionType: e, minAmount: t, maxAmount: r }) {
9
- let i = (e) => /* @__PURE__ */ s("strong", { children: a(e) });
10
+ function h({ conditionType: e, minAmount: t, maxAmount: n, labels: r }) {
11
+ let i = (e) => /* @__PURE__ */ f("strong", { children: u(e) });
10
12
  switch (e) {
11
- case n.LessThan: return /* @__PURE__ */ c(o, { children: [
12
- "For ",
13
- /* @__PURE__ */ s("strong", { children: "expenses" }),
14
- " less than ",
15
- i(r ?? 0)
13
+ case s.LessThan: return /* @__PURE__ */ p(d, { children: [
14
+ r.For,
15
+ " ",
16
+ /* @__PURE__ */ f("strong", { children: r.Expenses }),
17
+ " ",
18
+ r.LessThan,
19
+ " ",
20
+ i(n ?? 0)
16
21
  ] });
17
- case n.InRange: return /* @__PURE__ */ c(o, { children: [
18
- "For ",
19
- /* @__PURE__ */ s("strong", { children: "expenses" }),
20
- " greater than or equal to",
22
+ case s.InRange: return /* @__PURE__ */ p(d, { children: [
23
+ r.For,
24
+ " ",
25
+ /* @__PURE__ */ f("strong", { children: r.Expenses }),
26
+ " ",
27
+ r.GreaterThanOrEqual,
21
28
  " ",
22
29
  i(t ?? 0),
23
- " and less than ",
24
- i(r ?? 0)
30
+ " ",
31
+ r.AndLessThan,
32
+ " ",
33
+ i(n ?? 0)
25
34
  ] });
26
- case n.GreaterThanOrEqual: return /* @__PURE__ */ c(o, { children: [
27
- "For ",
28
- /* @__PURE__ */ s("strong", { children: "expenses" }),
29
- " greater than or equal to",
35
+ case s.GreaterThanOrEqual: return /* @__PURE__ */ p(d, { children: [
36
+ r.For,
37
+ " ",
38
+ /* @__PURE__ */ f("strong", { children: r.Expenses }),
39
+ " ",
40
+ r.GreaterThanOrEqual,
30
41
  " ",
31
42
  i(t ?? 0)
32
43
  ] });
33
- default: return /* @__PURE__ */ c(o, { children: ["For all ", /* @__PURE__ */ s("strong", { children: "expenses" })] });
44
+ default: return /* @__PURE__ */ p(d, { children: [
45
+ r.For,
46
+ " ",
47
+ r.All,
48
+ " ",
49
+ /* @__PURE__ */ f("strong", { children: r.Expenses })
50
+ ] });
34
51
  }
35
52
  }
36
- var p = ({ rule: n, onEdit: a, onDelete: o, disabled: p, testIds: m }) => /* @__PURE__ */ c("div", {
37
- "data-testid": m?.root,
38
- className: "ttw:border ttw:border-border ttw:rounded-lg ttw:p-4 ttw:flex ttw:flex-col ttw:gap-2",
39
- children: [/* @__PURE__ */ c("div", {
40
- className: "ttw:flex ttw:items-center ttw:justify-between",
41
- children: [/* @__PURE__ */ s("span", {
42
- className: "ttw:text-sm",
43
- children: /* @__PURE__ */ s(f, {
44
- conditionType: n.conditionType,
45
- minAmount: n.minAmount,
46
- maxAmount: n.maxAmount
47
- })
48
- }), /* @__PURE__ */ c("div", {
49
- className: "ttw:flex ttw:gap-1",
50
- children: [/* @__PURE__ */ s(t, {
51
- variant: "ghost",
52
- size: "icon-sm",
53
- onClick: () => o(n.id),
54
- "aria-label": i.DeleteRuleAriaLabel,
55
- className: "ttw:text-destructive ttw:hover:text-destructive",
56
- disabled: p,
57
- children: /* @__PURE__ */ s(d, {})
58
- }), /* @__PURE__ */ s(t, {
59
- variant: "ghost",
60
- size: "icon-sm",
61
- onClick: () => a(n.id),
62
- "aria-label": i.EditRuleAriaLabel,
63
- className: "ttw:text-muted-foreground ttw:hover:text-foreground",
64
- disabled: p,
65
- children: /* @__PURE__ */ s(u, {})
53
+ var g = ({ rule: s, labels: u, onEdit: d, onDelete: g, disabled: _, testIds: v }) => {
54
+ let y = {
55
+ ...l,
56
+ ...u
57
+ };
58
+ return /* @__PURE__ */ p(o, {
59
+ "data-testid": v?.root,
60
+ children: [/* @__PURE__ */ p("div", {
61
+ className: "ttw:flex ttw:items-center ttw:justify-between",
62
+ children: [/* @__PURE__ */ f("span", {
63
+ className: "ttw:text-sm",
64
+ children: /* @__PURE__ */ f(h, {
65
+ labels: y,
66
+ conditionType: s.conditionType,
67
+ minAmount: s.minAmount,
68
+ maxAmount: s.maxAmount
69
+ })
70
+ }), /* @__PURE__ */ p("div", {
71
+ className: "ttw:flex ttw:gap-1",
72
+ children: [/* @__PURE__ */ f(i, { children: /* @__PURE__ */ p(n, { children: [/* @__PURE__ */ f(a, {
73
+ asChild: !0,
74
+ children: /* @__PURE__ */ f(t, {
75
+ variant: "ghost",
76
+ size: "icon-sm",
77
+ onClick: () => g(s.id),
78
+ "aria-label": y.DeleteRuleAriaLabel,
79
+ className: "ttw:text-destructive ttw:hover:text-destructive",
80
+ disabled: _,
81
+ children: /* @__PURE__ */ f(m, {})
82
+ })
83
+ }), /* @__PURE__ */ f(r, { children: y.DeleteRuleAriaLabel })] }) }), /* @__PURE__ */ f(t, {
84
+ variant: "ghost",
85
+ onClick: () => d(s.id),
86
+ className: "ttw:text-muted-foreground ttw:hover:text-foreground",
87
+ disabled: _,
88
+ children: y.EditRuleAriaLabel
89
+ })]
90
+ })]
91
+ }), s.outcome === c.AutoApprove ? /* @__PURE__ */ f(e, {
92
+ tone: "success",
93
+ className: "ttw:self-start",
94
+ children: y.AutoApprove
95
+ }) : /* @__PURE__ */ p("div", {
96
+ className: "ttw:flex ttw:items-center ttw:gap-1",
97
+ children: [/* @__PURE__ */ f("span", {
98
+ className: "ttw:text-sm ttw:text-muted-foreground",
99
+ children: y.RequireApprovalFrom
100
+ }), /* @__PURE__ */ f("div", {
101
+ className: "ttw:flex ttw:flex-wrap ttw:items-center ttw:gap-1",
102
+ children: s.approvers.map((t, n) => /* @__PURE__ */ p("div", {
103
+ className: "ttw:flex ttw:items-center ttw:gap-1",
104
+ children: [n > 0 ? /* @__PURE__ */ f("span", {
105
+ className: "ttw:text-sm ttw:text-muted-foreground",
106
+ children: y.ApproverSeparator
107
+ }) : null, /* @__PURE__ */ f(e, {
108
+ variant: "secondary",
109
+ children: t.label
110
+ })]
111
+ }, t.id))
66
112
  })]
67
113
  })]
68
- }), n.outcome === r.AutoApprove ? /* @__PURE__ */ c(e, {
69
- className: "ttw:bg-green-100 ttw:text-green-800 ttw:border-green-200 ttw:self-start ttw:gap-1",
70
- children: [/* @__PURE__ */ s(l, {}), i.AutoApprove]
71
- }) : /* @__PURE__ */ c("div", {
72
- className: "ttw:flex ttw:items-center ttw:gap-1",
73
- children: [/* @__PURE__ */ s("span", {
74
- className: "ttw:text-sm ttw:text-muted-foreground",
75
- children: i.RequireApprovalFrom
76
- }), /* @__PURE__ */ s("div", {
77
- className: "ttw:flex ttw:flex-wrap ttw:items-center ttw:gap-1",
78
- children: n.approvers.map((t, n) => /* @__PURE__ */ c("div", {
79
- className: "ttw:flex ttw:items-center ttw:gap-1",
80
- children: [n > 0 ? /* @__PURE__ */ s("span", {
81
- className: "ttw:text-sm ttw:text-muted-foreground",
82
- children: "or"
83
- }) : null, /* @__PURE__ */ s(e, { children: t.label })]
84
- }, t.id))
85
- })]
86
- })]
87
- });
88
- export { p as ApprovalRuleCard };
114
+ });
115
+ };
116
+ export { g as ApprovalRuleCard };
@@ -1,206 +1,178 @@
1
- import { Button as e, Combobox as t, Input as n, Tooltip as r, TooltipContent as i, TooltipProvider as a, TooltipTrigger as o, Typography as s } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { ApprovalOutcomeType as c } from "./index2.js";
3
- import { ApprovalRuleFormLabels as l } from "./index3.js";
4
- import { useId as u, useState as d } from "react";
5
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
6
- import { CircleAlert as m, FilePenLine as h, RefreshCw as g, Trash2 as _ } from "lucide-react";
1
+ import { Button as e, Combobox as t, FieldError as n, Label as r, RadioGroup as i, RadioGroupItem as a } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { AmountConditionBuilder as o } from "../../../../shared/approval-policy/ui/dist/index3.js";
3
+ import "../../../../shared/approval-policy/ui/dist/index.js";
4
+ import { ApprovalOutcomeType as s } from "./index2.js";
5
+ import { ApprovalRuleFormLabels as c } from "./index3.js";
6
+ import { useEffect as l, useId as u, useRef as d, useState as f } from "react";
7
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
8
+ import { FilePenLine as h, RefreshCw as g, Trash2 as _ } from "lucide-react";
7
9
  // ../../libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index7.js
8
- function v({ value: e, onChange: t, onBlur: a, placeholder: s, error: c, disabled: l, testId: u }) {
9
- return /* @__PURE__ */ p("div", {
10
- className: "ttw:relative ttw:w-39",
11
- children: [
12
- /* @__PURE__ */ f("span", {
13
- className: "ttw:absolute ttw:left-3 ttw:top-1/2 ttw:-translate-y-1/2 ttw:text-sm ttw:text-muted-foreground ttw:pointer-events-none",
14
- children: "$"
15
- }),
16
- /* @__PURE__ */ f(n, {
17
- value: e,
18
- onChange: (e) => t(e.target.value),
19
- onBlur: a,
20
- "aria-invalid": !!c,
21
- placeholder: s,
22
- inputMode: "decimal",
23
- disabled: l,
24
- "data-testid": u,
25
- className: `ttw:pl-6${c ? " ttw:pr-8" : ""}`
26
- }),
27
- c ? /* @__PURE__ */ p(r, { children: [/* @__PURE__ */ f(o, {
28
- asChild: !0,
29
- children: /* @__PURE__ */ f(m, { className: "ttw:absolute ttw:right-2.5 ttw:top-1/2 ttw:-translate-y-1/2 ttw:size-4 ttw:text-destructive ttw:cursor-default" })
30
- }), /* @__PURE__ */ f(i, {
31
- side: "top",
32
- children: c
33
- })] }) : null
34
- ]
35
- });
36
- }
37
- var y = ({ values: n, approverOptions: r, validationErrors: i, isEditing: o, disabled: m, isSaveDisabled: y, onValuesChange: b, onSave: x, onCancel: S, onDelete: C, testIds: w }) => {
38
- let T = (e) => b({
39
- ...n,
10
+ var v = ({ values: v, approverOptions: y, validationErrors: b, labels: x, isEditing: S, disabled: C, onValuesChange: w, onSave: T, onCancel: E, onDelete: D, testIds: O }) => {
11
+ let k = {
12
+ ...c,
13
+ ...x
14
+ }, A = (e) => w({
15
+ ...v,
40
16
  ...e
41
- }), [E, D] = d({}), [O, k] = d(!1), A = (e) => D((t) => ({
42
- ...t,
43
- [e]: !0
44
- })), j = {
45
- minAmount: E.minAmount || O ? i.minAmount : void 0,
46
- maxAmount: E.maxAmount || O ? i.maxAmount : void 0,
47
- approvers: O ? i.approvers : void 0
48
- }, M = () => {
49
- k(!0), !(i.minAmount || i.maxAmount || i.approvers) && x();
50
- }, N = u(), P = r.map((e) => ({
17
+ }), j = d(null), [M, N] = f(0);
18
+ l(() => {
19
+ M && j.current?.querySelector("[aria-invalid=\"true\"]")?.focus();
20
+ }, [M]);
21
+ let P = () => {
22
+ T(), N((e) => e + 1);
23
+ }, F = u(), I = u(), L = u(), R = y.map((e) => ({
51
24
  value: e.id,
52
25
  label: e.label
53
- })), F = new Set(P.map((e) => e.value)), I = [...P, ...n.approvers.filter((e) => !F.has(e.id)).map((e) => ({
26
+ })), z = new Set(R.map((e) => e.value)), B = [...R, ...v.approvers.filter((e) => !z.has(e.id)).map((e) => ({
54
27
  value: e.id,
55
28
  label: e.label
56
- }))], L = new Map([...n.approvers.map((e) => [e.id, e]), ...r.map((e) => [e.id, e])]);
57
- return /* @__PURE__ */ p("div", {
58
- "data-testid": w?.root,
29
+ }))], V = new Map([...v.approvers.map((e) => [e.id, e]), ...y.map((e) => [e.id, e])]);
30
+ return /* @__PURE__ */ m("div", {
31
+ ref: j,
32
+ "data-testid": O?.root,
59
33
  className: "ttw:border ttw:border-border ttw:rounded-lg ttw:p-5 ttw:flex ttw:flex-col ttw:gap-4",
60
34
  children: [
61
- /* @__PURE__ */ f(a, { children: /* @__PURE__ */ p("div", {
62
- className: "ttw:flex ttw:flex-wrap ttw:items-center ttw:gap-2",
63
- children: [
64
- /* @__PURE__ */ p(s, {
65
- variant: "body2",
66
- children: [
67
- l.ForExpenses,
68
- " ",
69
- /* @__PURE__ */ f("strong", { children: l.ExpensesBold }),
70
- " ",
71
- l.GreaterThanOrEqualTo
72
- ]
73
- }),
74
- /* @__PURE__ */ f(v, {
75
- value: n.minAmount,
76
- onChange: (e) => T({ minAmount: e }),
77
- onBlur: () => A("minAmount"),
78
- placeholder: l.MinimumPlaceholder,
79
- error: j.minAmount,
80
- disabled: m,
81
- testId: w?.minAmountInput
82
- }),
83
- /* @__PURE__ */ f(s, {
84
- variant: "body2",
85
- children: l.AndLessThan
86
- }),
87
- /* @__PURE__ */ f(v, {
88
- value: n.maxAmount,
89
- onChange: (e) => T({ maxAmount: e }),
90
- onBlur: () => A("maxAmount"),
91
- placeholder: l.MaximumPlaceholder,
92
- error: j.maxAmount,
93
- disabled: m,
94
- testId: w?.maxAmountInput
95
- })
96
- ]
97
- }) }),
98
- /* @__PURE__ */ p("div", {
99
- className: "ttw:flex ttw:flex-col ttw:gap-2",
100
- children: [/* @__PURE__ */ p("label", {
101
- className: "ttw:flex ttw:items-center ttw:gap-2 ttw:cursor-pointer",
102
- children: [
103
- /* @__PURE__ */ f("input", {
104
- type: "radio",
105
- name: N,
106
- value: c.AutoApprove,
107
- checked: n.outcome === c.AutoApprove,
108
- onChange: () => T({
109
- outcome: c.AutoApprove,
110
- approvers: []
111
- }),
112
- disabled: m,
113
- className: "ttw:accent-primary"
114
- }),
115
- /* @__PURE__ */ f(g, { className: "ttw:text-green-600 ttw:size-4 ttw:shrink-0" }),
116
- /* @__PURE__ */ f("span", {
117
- className: "ttw:text-sm ttw:font-medium ttw:text-green-700",
118
- children: l.AutoApprove
119
- })
120
- ]
121
- }), /* @__PURE__ */ p("label", {
122
- className: "ttw:flex ttw:items-start ttw:gap-2 ttw:cursor-pointer",
35
+ /* @__PURE__ */ p(o, {
36
+ value: {
37
+ lower: v.minAmount,
38
+ upper: v.maxAmount
39
+ },
40
+ onChange: ({ lower: e, upper: t }) => A({
41
+ minAmount: e,
42
+ maxAmount: t
43
+ }),
44
+ errors: {
45
+ lower: b.minAmount,
46
+ upper: b.maxAmount
47
+ },
48
+ disabled: C,
49
+ lead: /* @__PURE__ */ m("span", {
50
+ className: "ttw:font-normal",
123
51
  children: [
124
- /* @__PURE__ */ f("input", {
125
- type: "radio",
126
- name: N,
127
- value: c.RequireApproval,
128
- checked: n.outcome === c.RequireApproval,
129
- onChange: () => T({ outcome: c.RequireApproval }),
130
- disabled: m,
131
- className: "ttw:accent-primary ttw:mt-0.5"
132
- }),
133
- /* @__PURE__ */ f(h, { className: "ttw:size-4 ttw:shrink-0 ttw:mt-0.5" }),
134
- /* @__PURE__ */ p("div", { children: [
135
- /* @__PURE__ */ f("span", {
136
- className: "ttw:text-sm ttw:font-medium",
137
- children: l.RequireApproval
138
- }),
139
- /* @__PURE__ */ f("br", {}),
140
- /* @__PURE__ */ f("span", {
141
- className: "ttw:text-xs ttw:text-muted-foreground",
142
- children: l.RequireApprovalCaption
143
- })
144
- ] })
52
+ k.ForExpenses,
53
+ " ",
54
+ /* @__PURE__ */ p("strong", { children: k.ExpensesBold }),
55
+ " ",
56
+ k.GreaterThanOrEqualTo
145
57
  ]
58
+ }),
59
+ labels: {
60
+ IfAmountIsBetween: `${k.ForExpenses} ${k.ExpensesBold} ${k.GreaterThanOrEqualTo}`,
61
+ And: k.AndLessThan,
62
+ LowerPlaceholder: k.MinimumPlaceholder,
63
+ UpperPlaceholder: k.MaximumPlaceholder
64
+ },
65
+ testIds: {
66
+ lowerInput: O?.minAmountInput,
67
+ upperInput: O?.maxAmountInput
68
+ }
69
+ }),
70
+ /* @__PURE__ */ m(i, {
71
+ "aria-label": k.Outcome,
72
+ "aria-required": "true",
73
+ className: "ttw:gap-2",
74
+ value: v.outcome,
75
+ disabled: C,
76
+ onValueChange: (e) => {
77
+ e === s.AutoApprove ? A({
78
+ outcome: e,
79
+ approvers: []
80
+ }) : e === s.RequireApproval && A({ outcome: e });
81
+ },
82
+ children: [/* @__PURE__ */ m("div", {
83
+ className: "ttw:flex ttw:items-center ttw:gap-2",
84
+ children: [/* @__PURE__ */ p(a, {
85
+ id: `${F}-auto`,
86
+ value: s.AutoApprove
87
+ }), /* @__PURE__ */ m(r, {
88
+ htmlFor: `${F}-auto`,
89
+ className: "ttw:cursor-pointer ttw:text-success-foreground",
90
+ children: [/* @__PURE__ */ p(g, {
91
+ "aria-hidden": "true",
92
+ className: "ttw:size-4 ttw:shrink-0"
93
+ }), k.AutoApprove]
94
+ })]
95
+ }), /* @__PURE__ */ m("div", {
96
+ className: "ttw:flex ttw:items-start ttw:gap-2",
97
+ children: [/* @__PURE__ */ p(a, {
98
+ id: `${F}-required`,
99
+ value: s.RequireApproval,
100
+ className: "ttw:mt-0.5"
101
+ }), /* @__PURE__ */ m("div", {
102
+ className: "ttw:flex ttw:flex-col ttw:gap-1",
103
+ children: [/* @__PURE__ */ m(r, {
104
+ htmlFor: `${F}-required`,
105
+ className: "ttw:cursor-pointer",
106
+ children: [/* @__PURE__ */ p(h, {
107
+ "aria-hidden": "true",
108
+ className: "ttw:size-4 ttw:shrink-0"
109
+ }), k.RequireApproval]
110
+ }), /* @__PURE__ */ p("span", {
111
+ className: "ttw:pl-6 ttw:text-xs ttw:text-muted-foreground",
112
+ children: k.RequireApprovalCaption
113
+ })]
114
+ })]
146
115
  })]
147
116
  }),
148
- n.outcome === c.RequireApproval ? /* @__PURE__ */ p("div", {
117
+ v.outcome === s.RequireApproval ? /* @__PURE__ */ m("div", {
149
118
  className: "ttw:flex ttw:flex-col ttw:gap-1",
150
119
  children: [
151
- /* @__PURE__ */ f("span", {
120
+ /* @__PURE__ */ p("label", {
121
+ htmlFor: I,
152
122
  className: "ttw:text-xs ttw:font-medium",
153
- children: l.RequireApprovalFrom
123
+ children: k.RequireApprovalFrom
154
124
  }),
155
- /* @__PURE__ */ f(t, {
156
- items: I,
157
- value: n.approvers.map((e) => e.id),
125
+ /* @__PURE__ */ p(t, {
126
+ items: B,
127
+ value: v.approvers.map((e) => e.id),
158
128
  onValueChange: (e) => {
159
- T({ approvers: (Array.isArray(e) ? e : [e]).flatMap((e) => {
160
- let t = L.get(e);
129
+ A({ approvers: (Array.isArray(e) ? e : [e]).flatMap((e) => {
130
+ let t = V.get(e);
161
131
  return t ? [t] : [];
162
132
  }) });
163
133
  },
164
134
  multiple: !0,
165
- multipleSeparator: l.ApproverSeparator,
166
- labels: { placeholder: l.ChooseApprovers },
167
- disabled: m,
168
- chipBackgroundColor: "#4f46e5",
169
- chipTextColor: "#ffffff"
135
+ multipleSeparator: k.ApproverSeparator,
136
+ labels: { placeholder: k.ChooseApprovers },
137
+ disabled: C,
138
+ inputId: I,
139
+ required: !0,
140
+ invalid: !!b.approvers,
141
+ describedBy: b.approvers ? L : void 0
170
142
  }),
171
- j.approvers ? /* @__PURE__ */ f("span", {
172
- className: "ttw:text-xs ttw:text-destructive",
173
- children: j.approvers
143
+ b.approvers ? /* @__PURE__ */ p(n, {
144
+ id: L,
145
+ children: b.approvers
174
146
  }) : null
175
147
  ]
176
148
  }) : null,
177
- /* @__PURE__ */ p("div", {
178
- className: "ttw:flex ttw:items-center ttw:justify-between ttw:mt-2",
179
- children: [/* @__PURE__ */ f("div", { children: o && C ? /* @__PURE__ */ p(e, {
149
+ /* @__PURE__ */ m("div", {
150
+ className: "ttw:mt-2 ttw:flex ttw:items-center ttw:justify-between",
151
+ children: [/* @__PURE__ */ p("div", { children: S && D ? /* @__PURE__ */ m(e, {
180
152
  variant: "ghost",
181
153
  size: "sm",
182
154
  className: "ttw:text-destructive ttw:hover:text-destructive",
183
- onClick: C,
184
- disabled: m,
185
- children: [/* @__PURE__ */ f(_, {}), l.DeleteRule]
186
- }) : null }), /* @__PURE__ */ p("div", {
155
+ onClick: D,
156
+ disabled: C,
157
+ children: [/* @__PURE__ */ p(_, {}), k.DeleteRule]
158
+ }) : null }), /* @__PURE__ */ m("div", {
187
159
  className: "ttw:flex ttw:gap-2",
188
- children: [/* @__PURE__ */ f(e, {
160
+ children: [/* @__PURE__ */ p(e, {
189
161
  variant: "ghost",
190
162
  size: "sm",
191
- onClick: S,
192
- disabled: m,
193
- children: l.Cancel
194
- }), /* @__PURE__ */ f(e, {
163
+ onClick: E,
164
+ disabled: C,
165
+ children: k.Cancel
166
+ }), /* @__PURE__ */ p(e, {
195
167
  size: "sm",
196
- onClick: M,
197
- disabled: m || y,
198
- "data-testid": w?.saveButton,
199
- children: l.Save
168
+ onClick: P,
169
+ disabled: C,
170
+ "data-testid": O?.saveButton,
171
+ children: k.Save
200
172
  })]
201
173
  })]
202
174
  })
203
175
  ]
204
176
  });
205
177
  };
206
- export { y as ApprovalRuleForm };
178
+ export { v as ApprovalRuleForm };