@tesouro/embedded-components-react 0.3.16 → 0.3.18

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 (111) hide show
  1. package/dist/index.d.ts +22 -1
  2. package/dist/index.js +10 -10
  3. package/dist/lib/AcceptDisclosuresWidget.d.ts +11 -1
  4. package/dist/lib/AcceptDisclosuresWidget.js +1 -1
  5. package/dist/lib/BalancesWidget.js +1 -1
  6. package/dist/lib/BankAccountOnboardingWidget.d.ts +21 -21
  7. package/dist/lib/BankAccountOnboardingWidget.js +1 -1
  8. package/dist/lib/CardsWidget.js +1 -1
  9. package/dist/lib/ExpenseApprovalPoliciesWidget.js +1 -1
  10. package/dist/lib/ExpenseManagementWidget.js +1 -1
  11. package/dist/lib/InsightsWidget.js +1 -1
  12. package/dist/lib/ReceiptMatchWidget.js +1 -1
  13. package/dist/lib/TransfersWidget.js +1 -1
  14. package/dist/lib/UploadReceiptWidget.js +1 -1
  15. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index.js +1 -1
  16. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index4.js +10 -140
  17. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index5.js +152 -0
  18. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/ui/dist/lib/AcceptDisclosuresWidget/AcceptDisclosuresWidget.js +19 -19
  19. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index4.js +10 -11
  21. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index5.js +15 -64
  22. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index6.js +75 -0
  23. package/dist/libs/tesouro-embedded-components-react/balances-widget/ui/dist/lib/BalancesWidget/BalancesWidget.js +16 -16
  24. package/dist/libs/tesouro-embedded-components-react/balances-widget/ui/dist/lib/BalancesWidget/SingleBalance/SingleBalance.js +7 -7
  25. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index.js +1 -1
  26. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index10.js +109 -169
  27. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index11.js +170 -63
  28. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index12.js +73 -81
  29. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index13.js +77 -101
  30. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index14.js +110 -83
  31. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index15.js +91 -7
  32. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index16.js +7 -28
  33. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index17.js +26 -320
  34. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index18.js +341 -0
  35. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index9.js +29 -100
  36. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index.js +0 -1
  37. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index11.js +3 -3
  38. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index15.js +32 -32
  39. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index16.js +2 -2
  40. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index18.js +14 -10
  41. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index19.js +42 -42
  42. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index2.js +80 -77
  43. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index20.js +2 -2
  44. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index22.js +14 -10
  45. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index23.js +16 -16
  46. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index27.js +5 -5
  47. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index3.js +7 -6
  48. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index5.js +23 -18
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +0 -1
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +28 -28
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +0 -1
  52. package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/index.js +0 -1
  53. package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/CardDetailsHeader.js +5 -5
  54. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index.js +3 -3
  55. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index3.js +4 -23
  56. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index4.js +23 -24
  57. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index5.js +24 -30
  58. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index6.js +28 -55
  59. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index7.js +54 -209
  60. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index8.js +206 -81
  61. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +95 -0
  62. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardFaceSwatch.js +2 -2
  63. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsList.js +31 -30
  64. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsListRow.js +11 -10
  65. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index.js +5 -5
  66. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index10.js +1 -255
  67. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index11.js +253 -2
  68. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index12.js +2 -71
  69. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index13.js +73 -0
  70. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index5.js +7 -218
  71. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index6.js +219 -79
  72. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index7.js +89 -2
  73. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index8.js +2 -47
  74. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index9.js +49 -1
  75. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ApprovalRuleCard.js +2 -2
  76. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ApprovalRuleForm.js +32 -32
  77. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ExpenseApprovalsPage.js +11 -8
  78. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index.js +1 -1
  79. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index10.js +12 -14
  80. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index11.js +21 -62
  81. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index12.js +73 -0
  82. package/dist/libs/tesouro-embedded-components-react/insights-widget/ui/dist/lib/InsightsWidget/InsightsWidget.js +6 -6
  83. package/dist/libs/tesouro-embedded-components-react/insights-widget/ui/dist/lib/InsightsWidget/SingleInsight/SingleInsight.js +10 -10
  84. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index5.js +1 -1
  85. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/ApprovalPoliciesSettings.js +67 -46
  86. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/testIds.js +26 -0
  87. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApprovalPolicyRules.js +151 -135
  88. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index11.js +11 -11
  89. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index14.js +17 -17
  90. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index16.js +17 -15
  91. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index18.js +9 -9
  92. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index20.js +16 -13
  93. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index3.js +13 -13
  94. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index5.js +11 -11
  95. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index7.js +5 -5
  96. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index9.js +6 -6
  97. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  98. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShell.js +21 -20
  99. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShellOverlayPortal.js +10 -10
  100. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShellScrollRegion.js +17 -17
  101. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index.js +1 -1
  102. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index5.js +18 -99
  103. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index6.js +116 -19
  104. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index7.js +28 -0
  105. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransferMoneyModal/ReviewTransferStep.js +9 -9
  106. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransferMoneyModal/TransferMoneyModal.js +13 -11
  107. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransferMoneyModal/TransferResultStep.js +7 -7
  108. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransfersWidget.js +19 -19
  109. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +4 -4
  110. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  111. package/package.json +1 -1
@@ -6,62 +6,83 @@ import { EmbeddedToaster as e } from "../../../../ui/dist/lib/EmbeddedToaster.js
6
6
  import { ErrorState as t } from "../../../../ui/dist/lib/ErrorState/ErrorState.js";
7
7
  import "../../../../ui/dist/index.js";
8
8
  import { ApprovalPoliciesSettingsDefaultLabels as n } from "./labels.js";
9
- import { useApprovalPolicyRules as r } from "./useApprovalPolicyRules.js";
10
- import { ApprovalPoliciesHeader as i } from "../../../ui/dist/index11.js";
11
- import { DeleteRuleDialog as a } from "../../../ui/dist/index18.js";
12
- import { ApprovalPoliciesList as o } from "../../../ui/dist/index20.js";
9
+ import { approvalPolicyTestIds as r } from "./testIds.js";
10
+ import { useApprovalPolicyRules as i } from "./useApprovalPolicyRules.js";
11
+ import { ApprovalPoliciesHeader as a } from "../../../ui/dist/index11.js";
12
+ import { DeleteRuleDialog as o } from "../../../ui/dist/index18.js";
13
+ import { ApprovalPoliciesList as s } from "../../../ui/dist/index20.js";
13
14
  import "../../../ui/dist/index.js";
14
- import { useMemo as s } from "react";
15
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
15
+ import { useMemo as c } from "react";
16
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
16
17
  //#region ../../libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/ApprovalPoliciesSettings.js
17
- function u({ labels: u, componentLabels: d, headingComponent: f = "h3" } = {}) {
18
- let p = s(() => ({
18
+ function d({ labels: d, componentLabels: f, headingComponent: p = "h3" } = {}) {
19
+ let m = c(() => ({
19
20
  ...n,
20
- ...u
21
- }), [u]), m = r({
22
- labels: p,
23
- componentLabels: d
21
+ ...d
22
+ }), [d]), h = i({
23
+ labels: m,
24
+ componentLabels: f
24
25
  });
25
- return /* @__PURE__ */ l("div", {
26
+ return /* @__PURE__ */ u("div", {
26
27
  className: "ttw:flex ttw:flex-col ttw:gap-6",
27
28
  children: [
28
- /* @__PURE__ */ c(i, {
29
- labels: d?.header,
30
- headingComponent: f,
31
- onAddRule: m.items.length > 0 && !m.isError ? m.onAddRule : void 0,
32
- addRuleDisabled: m.isBusy || m.editingId !== null || m.addRuleDisabledReason !== void 0,
33
- addRuleDisabledReason: m.addRuleDisabledReason
29
+ /* @__PURE__ */ l(a, {
30
+ labels: f?.header,
31
+ headingComponent: p,
32
+ onAddRule: h.items.length > 0 && !h.isError ? h.onAddRule : void 0,
33
+ addRuleDisabled: h.isBusy || h.editingId !== null || h.addRuleDisabledReason !== void 0,
34
+ addRuleDisabledReason: h.addRuleDisabledReason,
35
+ testIds: {
36
+ addRuleButton: r.addRuleButton,
37
+ addRuleBlocked: r.addRuleBlocked
38
+ }
34
39
  }),
35
- m.isError ? /* @__PURE__ */ c(t, {
36
- title: p.loadErrorTitle,
37
- description: p.loadErrorDescription,
38
- retryLabel: p.loadErrorRetry,
39
- onRetry: m.onRetry
40
- }) : /* @__PURE__ */ c(o, {
41
- items: m.items,
42
- editingId: m.editingId,
43
- onAddRule: m.onAddRule,
44
- gaps: m.gaps,
45
- onSelectGap: m.onSelectGap,
46
- unlistedPoliciesHeading: m.unlistedPoliciesHeading,
47
- unlistedPoliciesBlockAmounts: m.unlistedPoliciesBlockAmounts,
48
- unlistedPoliciesStillApply: m.unlistedPoliciesStillApply,
49
- createRuleDisabledReason: m.addRuleDisabledReason,
50
- isLoading: m.isLoading,
51
- disabled: m.isBusy,
52
- labels: d?.list
40
+ h.isError ? /* @__PURE__ */ l(t, {
41
+ title: m.loadErrorTitle,
42
+ description: m.loadErrorDescription,
43
+ retryLabel: m.loadErrorRetry,
44
+ onRetry: h.onRetry
45
+ }) : /* @__PURE__ */ l(s, {
46
+ items: h.items,
47
+ editingId: h.editingId,
48
+ onAddRule: h.onAddRule,
49
+ gaps: h.gaps,
50
+ onSelectGap: h.onSelectGap,
51
+ unlistedPoliciesHeading: h.unlistedPoliciesHeading,
52
+ unlistedPoliciesBlockAmounts: h.unlistedPoliciesBlockAmounts,
53
+ unlistedPoliciesStillApply: h.unlistedPoliciesStillApply,
54
+ createRuleDisabledReason: h.addRuleDisabledReason,
55
+ isLoading: h.isLoading,
56
+ disabled: h.isBusy,
57
+ labels: f?.list,
58
+ testIds: {
59
+ root: r.list,
60
+ loading: r.listLoading,
61
+ unlistedPoliciesNotice: { root: r.unlistedPoliciesNotice },
62
+ noPolicyBanner: {
63
+ root: r.noPolicyBanner,
64
+ createRuleButton: r.noPolicyBannerCreateRule,
65
+ createRuleBlocked: r.noPolicyBannerCreateRuleBlocked
66
+ },
67
+ gapCoverageAlert: { root: r.gapCoverageAlert }
68
+ }
53
69
  }),
54
- /* @__PURE__ */ c(a, {
55
- open: m.deleteDialog.open,
56
- onOpenChange: m.deleteDialog.onOpenChange,
57
- onConfirm: m.deleteDialog.onConfirm,
58
- onCancel: m.deleteDialog.onCancel,
59
- isDeleting: m.deleteDialog.isDeleting,
60
- labels: d?.deleteDialog
70
+ /* @__PURE__ */ l(o, {
71
+ open: h.deleteDialog.open,
72
+ onOpenChange: h.deleteDialog.onOpenChange,
73
+ onConfirm: h.deleteDialog.onConfirm,
74
+ onCancel: h.deleteDialog.onCancel,
75
+ isDeleting: h.deleteDialog.isDeleting,
76
+ labels: f?.deleteDialog,
77
+ testIds: {
78
+ root: r.deleteDialog,
79
+ cancelButton: r.deleteDialogCancel,
80
+ confirmButton: r.deleteDialogConfirm
81
+ }
61
82
  }),
62
- /* @__PURE__ */ c(e, {})
83
+ /* @__PURE__ */ l(e, {})
63
84
  ]
64
85
  });
65
86
  }
66
87
  //#endregion
67
- export { u as ApprovalPoliciesSettings, u as default };
88
+ export { d as ApprovalPoliciesSettings, d as default };
@@ -0,0 +1,26 @@
1
+ //#region ../../libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/testIds.js
2
+ var e = {
3
+ addRuleButton: "approval-policies-add-rule-button",
4
+ addRuleBlocked: "approval-policies-add-rule-blocked",
5
+ list: "approval-policies-list",
6
+ listLoading: "approval-policies-loading",
7
+ unlistedPoliciesNotice: "unlisted-policies-notice",
8
+ noPolicyBanner: "no-policy-banner",
9
+ noPolicyBannerCreateRule: "no-policy-banner-create-rule-button",
10
+ noPolicyBannerCreateRuleBlocked: "no-policy-banner-create-rule-blocked",
11
+ gapCoverageAlert: "gap-coverage-alert",
12
+ amountConditionBuilder: "amount-condition-builder",
13
+ amountConditionLowerInput: "amount-condition-lower-input",
14
+ amountConditionUpperInput: "amount-condition-upper-input",
15
+ approverGroupsBuilder: "approver-groups-builder",
16
+ approverGroupsLoading: "approver-groups-builder-loading",
17
+ approverGroupsError: "approver-groups-builder-error",
18
+ approverGroupsDescription: "approver-groups-builder-description",
19
+ approverGroupsEmpty: "approver-groups-builder-empty",
20
+ approverGroupsAddStep: "approver-groups-add-button",
21
+ deleteDialog: "delete-rule-dialog",
22
+ deleteDialogCancel: "delete-rule-dialog-cancel-button",
23
+ deleteDialogConfirm: "delete-rule-dialog-confirm-button"
24
+ };
25
+ //#endregion
26
+ export { e as approvalPolicyTestIds };
@@ -13,15 +13,16 @@ import { buildApprovalPolicyTrigger as o, parseApprovalPolicyTrigger as s } from
13
13
  import { validatePolicyDraft as c } from "../../../util/dist/lib/validatePolicyDraft.js";
14
14
  import { buildPolicySentence as l, buildPolicyTitle as u, buildUnlistedPoliciesHeading as ee, gapId as te, lockUnavailableApprovers as ne, toAmountConditionErrors as d, toAmountConditionValue as f, toApproverErrors as re, toApproverGroupRefs as ie, toApproverSteps as ae, toGapRanges as oe } from "./policyViewModel.js";
15
15
  import { useApproverOptions as se } from "./useApproverOptions.js";
16
+ import { approvalPolicyTestIds as p } from "./testIds.js";
16
17
  import { ApprovalPolicyObjectType as ce } from "../../../data-access/dist/lib/queryKeys.js";
17
18
  import { useDeleteApprovalPoliciesIdMutation as le, useGetApprovalPoliciesQuery as ue, usePatchApprovalPoliciesIdMutation as de, usePostApprovalPoliciesMutation as fe } from "../../../data-access/dist/lib/approvalPoliciesApi.js";
18
19
  import "../../../data-access/dist/index.js";
19
- import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
20
+ import { useCallback as m, useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
20
21
  //#region ../../libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApprovalPolicyRules.js
21
- var v = "draft", pe = {
22
+ var y = "draft", pe = {
22
23
  lower: "",
23
24
  upper: ""
24
- }, y = {
25
+ }, b = {
25
26
  lower: !1,
26
27
  upper: !1
27
28
  };
@@ -43,15 +44,15 @@ function me(e) {
43
44
  function he(e) {
44
45
  return [...e].sort((e, t) => (e.condition.min ?? 0) - (t.condition.min ?? 0));
45
46
  }
46
- function b({ labels: a, componentLabels: s }) {
47
- let v = ue(), b = fe(), x = de(), S = le(), C = se(), { organizationId: w } = t(), [T, E] = _(null), [D, O] = _(null), k = g(w);
48
- w && w !== k.current && (k.current = w, E(null), O(null));
49
- let A = g(0), j = p(() => (A.current += 1, {
50
- id: `group-new-${A.current}`,
47
+ function x({ labels: a, componentLabels: s }) {
48
+ let y = ue(), x = fe(), S = de(), C = le(), w = se(), { organizationId: T } = t(), [E, D] = v(null), [O, k] = v(null), A = _(T);
49
+ T && T !== A.current && (A.current = T, D(null), k(null));
50
+ let j = _(0), M = m(() => (j.current += 1, {
51
+ id: `group-new-${j.current}`,
51
52
  selectedItems: []
52
- }), []), M = h(() => me(v.data?.data ?? []), [v.data]), N = h(() => C.isResolving ? [] : he(M.flatMap((e) => {
53
+ }), []), N = g(() => me(y.data?.data ?? []), [y.data]), P = g(() => w.isResolving ? [] : he(N.flatMap((e) => {
53
54
  if (!e.isRepresentable) return [];
54
- let t = ae(e.groups, C.lookup);
55
+ let t = ae(e.groups, w.lookup);
55
56
  return t === void 0 ? [] : [{
56
57
  id: e.id,
57
58
  priority: e.priority,
@@ -59,166 +60,166 @@ function b({ labels: a, componentLabels: s }) {
59
60
  steps: t
60
61
  }];
61
62
  })), [
62
- M,
63
- C.isResolving,
64
- C.lookup
65
- ]), P = T ? T.policyId ?? "draft" : null, F = !w && k.current != null || v.isResolving || C.isResolving, I = T?.policyId != null && T.policyId !== D && !F && !N.some((e) => e.id === T.policyId);
66
- m(() => {
67
- I && (E(null), e.error(a.approverUnavailable));
68
- }, [I, a.approverUnavailable]);
69
- let L = h(() => new Set(N.map((e) => e.id)), [N]), R = h(() => F ? [] : M.filter((e) => !L.has(e.id)), [
70
- F,
71
- M,
72
- L
73
- ]), z = h(() => {
63
+ N,
64
+ w.isResolving,
65
+ w.lookup
66
+ ]), F = E ? E.policyId ?? "draft" : null, I = !T && A.current != null || y.isResolving || w.isResolving, L = E?.policyId != null && E.policyId !== O && !I && !P.some((e) => e.id === E.policyId);
67
+ h(() => {
68
+ L && (D(null), e.error(a.approverUnavailable));
69
+ }, [L, a.approverUnavailable]);
70
+ let R = g(() => new Set(P.map((e) => e.id)), [P]), z = g(() => I ? [] : N.filter((e) => !R.has(e.id)), [
71
+ I,
72
+ N,
73
+ R
74
+ ]), B = g(() => {
74
75
  let e = /* @__PURE__ */ new Map();
75
- for (let t of N) e.set(t.id, t.steps.flatMap((e) => e.selectedItems.map((e) => e.id)));
76
+ for (let t of P) e.set(t.id, t.steps.flatMap((e) => e.selectedItems.map((e) => e.id)));
76
77
  return e;
77
- }, [N]), B = h(() => {
78
+ }, [P]), V = g(() => {
78
79
  let e = /* @__PURE__ */ new Set();
79
- for (let [t, n] of z) if (t !== T?.policyId) for (let t of n) e.add(t);
80
+ for (let [t, n] of B) if (t !== E?.policyId) for (let t of n) e.add(t);
80
81
  return e;
81
- }, [z, T?.policyId]), V = h(() => {
82
- if (!T) return;
83
- let e = (e) => e.id !== T.policyId;
82
+ }, [B, E?.policyId]), H = g(() => {
83
+ if (!E) return;
84
+ let e = (e) => e.id !== E.policyId;
84
85
  return c({
85
- amount: T.amount,
86
- groups: T.steps.map((e) => ({
86
+ amount: E.amount,
87
+ groups: E.steps.map((e) => ({
87
88
  id: e.id,
88
89
  approverIds: e.selectedItems.map((e) => e.id)
89
90
  })),
90
- otherConditions: N.filter(e).map((e) => e.condition),
91
- unlistedConditions: R.filter((t) => t.hasKnownCondition && e(t)).map((e) => e.condition),
92
- approverIdsUsedByOtherRules: [...B].filter((e) => !T.originalApproverIds.has(e))
91
+ otherConditions: P.filter(e).map((e) => e.condition),
92
+ unlistedConditions: z.filter((t) => t.hasKnownCondition && e(t)).map((e) => e.condition),
93
+ approverIdsUsedByOtherRules: [...V].filter((e) => !E.originalApproverIds.has(e))
93
94
  });
94
95
  }, [
95
- T,
96
- N,
97
- R,
98
- B
99
- ]), H = h(() => n(M.filter((e) => e.coversNow).map((e) => e.condition)), [M]), U = h(() => M.filter((e) => e.hasKnownCondition).map((e) => e.condition), [M]), W = h(() => M.length === 0 ? [] : oe(H, a, U), [
100
- M.length,
101
- H,
96
+ E,
97
+ P,
98
+ z,
99
+ V
100
+ ]), U = g(() => n(N.filter((e) => e.coversNow).map((e) => e.condition)), [N]), W = g(() => N.filter((e) => e.hasKnownCondition).map((e) => e.condition), [N]), G = g(() => N.length === 0 ? [] : oe(U, a, W), [
101
+ N.length,
102
+ U,
102
103
  a,
103
- U
104
- ]), ge = h(() => n(U), [U]), _e = !F && M.length > 0 && ge.length === 0 ? N.length === 0 ? a.addRuleFullyCoveredUnlisted : a.addRuleFullyCovered : void 0, [G, ve] = _(0), K = g(null);
105
- m(() => {
106
- G !== 0 && K.current?.scrollIntoView({
104
+ W
105
+ ]), ge = g(() => n(W), [W]), _e = !I && N.length > 0 && ge.length === 0 ? P.length === 0 ? a.addRuleFullyCoveredUnlisted : a.addRuleFullyCovered : void 0, [K, ve] = v(0), q = _(null);
106
+ h(() => {
107
+ K !== 0 && q.current?.scrollIntoView({
107
108
  behavior: globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth",
108
109
  block: "nearest"
109
110
  });
110
- }, [G]);
111
- let q = p((e) => {
112
- E({
111
+ }, [K]);
112
+ let J = m((e) => {
113
+ D({
113
114
  policyId: null,
114
115
  amount: e,
115
- steps: [j()],
116
+ steps: [M()],
116
117
  originalApproverIds: /* @__PURE__ */ new Set(),
117
- touchedAmount: y
118
+ touchedAmount: b
118
119
  }), ve((e) => e + 1);
119
- }, [j]), J = p(() => {
120
- q(pe);
121
- }, [q]), ye = p((e) => {
122
- let t = H.find((t) => te(t) === e);
123
- t && W.find((t) => t.id === e)?.blockedReason === void 0 && q(f({
120
+ }, [M]), ye = m(() => {
121
+ J(pe);
122
+ }, [J]), be = m((e) => {
123
+ let t = U.find((t) => te(t) === e);
124
+ t && G.find((t) => t.id === e)?.blockedReason === void 0 && J(f({
124
125
  type: "between",
125
126
  min: t.min,
126
127
  max: t.max
127
128
  }));
128
129
  }, [
129
- H,
130
- W,
131
- q
132
- ]), Y = p(() => {
133
- E(null);
134
- }, []), X = b.isPending || x.isPending || S.isPending, Z = p(async () => {
135
- if (!T || !V || !V.isValid) return;
136
- let t = V.condition, n = ie(T.steps, C.lookup);
130
+ U,
131
+ G,
132
+ J
133
+ ]), Y = m(() => {
134
+ D(null);
135
+ }, []), X = x.isPending || S.isPending || C.isPending, Z = m(async () => {
136
+ if (!E || !H || !H.isValid) return;
137
+ let t = H.condition, n = ie(E.steps, w.lookup);
137
138
  if (!n) {
138
139
  e.error(a.approverUnavailable);
139
140
  return;
140
141
  }
141
142
  let s = o(t), c = i(n), l = u(t, a);
142
143
  try {
143
- T.policyId === null ? await b.mutateAsync({ body: {
144
+ E.policyId === null ? await x.mutateAsync({ body: {
144
145
  object_type: ce.Payable,
145
146
  name: l,
146
147
  trigger: s,
147
148
  script: c,
148
- priority: r(M.map((e) => e.priority))
149
- } }) : await x.mutateAsync({
150
- path: { approval_policy_id: T.policyId },
149
+ priority: r(N.map((e) => e.priority))
150
+ } }) : await S.mutateAsync({
151
+ path: { approval_policy_id: E.policyId },
151
152
  body: {
152
153
  name: l,
153
154
  trigger: s,
154
155
  script: c
155
156
  }
156
- }), E(null), e.success(a.ruleSaved);
157
+ }), D(null), e.success(a.ruleSaved);
157
158
  } catch {
158
159
  e.error(a.ruleSaveFailed);
159
160
  }
160
161
  }, [
161
- T,
162
- V,
163
- C.lookup,
162
+ E,
163
+ H,
164
+ w.lookup,
164
165
  a,
165
- M,
166
- b,
167
- x
168
- ]), be = p(async () => {
169
- if (D) try {
170
- await S.mutateAsync({ path: { approval_policy_id: D } }), O(null), E(null), e.success(a.ruleDeleted);
166
+ N,
167
+ x,
168
+ S
169
+ ]), xe = m(async () => {
170
+ if (O) try {
171
+ await C.mutateAsync({ path: { approval_policy_id: O } }), k(null), D(null), e.success(a.ruleDeleted);
171
172
  } catch {
172
- O(null), e.error(a.ruleDeleteFailed);
173
+ k(null), e.error(a.ruleDeleteFailed);
173
174
  }
174
175
  }, [
175
- D,
176
- S,
176
+ O,
177
+ C,
177
178
  a
178
- ]), xe = F || X, Q = h(() => {
179
- if (!T || !V || X) return;
180
- let e = d(V.amountErrors, a);
179
+ ]), Se = I || X, Q = g(() => {
180
+ if (!E || !H || X) return;
181
+ let e = d(H.amountErrors, a);
181
182
  if (e) return {
182
- lower: T.touchedAmount.lower ? e.lower : void 0,
183
- upper: T.touchedAmount.upper ? e.upper : void 0
183
+ lower: E.touchedAmount.lower ? e.lower : void 0,
184
+ upper: E.touchedAmount.upper ? e.upper : void 0
184
185
  };
185
186
  }, [
186
- T,
187
- V,
187
+ E,
188
+ H,
188
189
  X,
189
190
  a
190
- ]), $ = h(() => {
191
- if (!V || V.isValid) return;
192
- let e = re(V.groupErrors, a), t = d(V.amountErrors, a), n = [
191
+ ]), $ = g(() => {
192
+ if (!H || H.isValid) return;
193
+ let e = re(H.groupErrors, a), t = d(H.amountErrors, a), n = [
193
194
  ...Object.values(e?.steps ?? {}),
194
195
  t?.lower,
195
196
  t?.upper
196
197
  ].filter((e) => !!e), r = [...new Set(n)];
197
198
  return r.length > 0 ? r : void 0;
198
- }, [V, a]);
199
+ }, [H, a]);
199
200
  return {
200
- items: h(() => {
201
+ items: g(() => {
201
202
  let e = {
202
- onAmountConditionChange: (e) => E((t) => t && {
203
+ onAmountConditionChange: (e) => D((t) => t && {
203
204
  ...t,
204
205
  amount: e
205
206
  }),
206
- onAmountFieldBlur: (e) => E((t) => t && {
207
+ onAmountFieldBlur: (e) => D((t) => t && {
207
208
  ...t,
208
209
  touchedAmount: {
209
210
  ...t.touchedAmount,
210
211
  [e]: !0
211
212
  }
212
213
  }),
213
- onApproverStepsChange: (e) => E((t) => t && {
214
+ onApproverStepsChange: (e) => D((t) => t && {
214
215
  ...t,
215
216
  steps: e
216
217
  }),
217
- onAddApproverStep: () => E((e) => e && {
218
+ onAddApproverStep: () => D((e) => e && {
218
219
  ...e,
219
- steps: [...e.steps, j()]
220
+ steps: [...e.steps, M()]
220
221
  }),
221
- onRemoveApproverStep: (e) => E((t) => t && {
222
+ onRemoveApproverStep: (e) => D((t) => t && {
222
223
  ...t,
223
224
  steps: t.steps.filter((t) => t.id !== e)
224
225
  })
@@ -227,83 +228,98 @@ function b({ labels: a, componentLabels: s }) {
227
228
  title: u(n, a),
228
229
  sentence: l(n, a),
229
230
  approverSteps: r.map((e) => ne(e, {
230
- lookup: C.lookup,
231
+ lookup: w.lookup,
231
232
  labels: a,
232
- usedByOtherRules: i ? B : void 0,
233
+ usedByOtherRules: i ? V : void 0,
233
234
  usedByOtherSteps: i ? new Set(r.filter((t) => t.id !== e.id).flatMap((e) => e.selectedItems.map((e) => e.id))) : void 0
234
235
  })),
235
236
  addApproverStepDisabled: r.some((e) => e.selectedItems.length === 0),
236
- approverOptions: C.options,
237
+ approverOptions: w.options,
237
238
  amountCondition: f(n),
238
239
  amountConditionErrors: i ? Q : void 0,
239
240
  onEdit: () => {
240
- E({
241
+ D({
241
242
  policyId: t,
242
243
  amount: f(n),
243
244
  steps: r,
244
245
  originalApproverIds: new Set(r.flatMap((e) => e.selectedItems.map((e) => e.id))),
245
- touchedAmount: y
246
+ touchedAmount: b
246
247
  });
247
248
  },
248
249
  onCancel: Y,
249
250
  onSave: () => void Z(),
250
251
  onDelete: o,
251
- saveDisabled: i && V ? !V.isValid : !1,
252
+ saveDisabled: i && H ? !H.isValid : !1,
252
253
  saveDisabledReasons: i ? $ : void 0,
253
254
  labels: s?.policyCard,
255
+ testIds: {
256
+ amountConditionBuilder: {
257
+ root: p.amountConditionBuilder,
258
+ lowerInput: p.amountConditionLowerInput,
259
+ upperInput: p.amountConditionUpperInput
260
+ },
261
+ approverGroupsBuilder: {
262
+ root: p.approverGroupsBuilder,
263
+ loading: p.approverGroupsLoading,
264
+ error: p.approverGroupsError,
265
+ description: p.approverGroupsDescription,
266
+ empty: p.approverGroupsEmpty,
267
+ addStepButton: p.approverGroupsAddStep
268
+ }
269
+ },
254
270
  ...e
255
- }), n = N.map((e) => {
256
- let n = P === e.id, r = t(e.id, e.condition, n && T ? T.steps : e.steps, n, () => O(e.id));
257
- return n && T ? {
271
+ }), n = P.map((e) => {
272
+ let n = F === e.id, r = t(e.id, e.condition, n && E ? E.steps : e.steps, n, () => k(e.id));
273
+ return n && E ? {
258
274
  ...r,
259
- amountCondition: T.amount
275
+ amountCondition: E.amount
260
276
  } : r;
261
277
  });
262
- return T?.policyId === null && n.unshift({
263
- ...t("draft", { type: "between" }, T.steps, !0, void 0),
264
- amountCondition: T.amount,
265
- ref: K
278
+ return E?.policyId === null && n.unshift({
279
+ ...t("draft", { type: "between" }, E.steps, !0, void 0),
280
+ amountCondition: E.amount,
281
+ ref: q
266
282
  }), n;
267
283
  }, [
268
- N,
269
- T,
270
284
  P,
285
+ E,
286
+ F,
271
287
  Q,
272
288
  $,
273
- V,
289
+ H,
274
290
  a,
275
291
  s?.policyCard,
276
- C.options,
277
- C.lookup,
278
- B,
292
+ w.options,
293
+ w.lookup,
294
+ V,
279
295
  Y,
280
- j,
296
+ M,
281
297
  Z
282
298
  ]),
283
- editingId: P,
284
- gaps: W,
285
- unlistedPoliciesHeading: ee(R.length, a),
286
- unlistedPoliciesBlockAmounts: R.some((e) => e.hasKnownCondition),
287
- unlistedPoliciesStillApply: R.some((e) => e.isActive),
288
- onAddRule: J,
299
+ editingId: F,
300
+ gaps: G,
301
+ unlistedPoliciesHeading: ee(z.length, a),
302
+ unlistedPoliciesBlockAmounts: z.some((e) => e.hasKnownCondition),
303
+ unlistedPoliciesStillApply: z.some((e) => e.isActive),
304
+ onAddRule: ye,
289
305
  addRuleDisabledReason: _e,
290
- onSelectGap: ye,
291
- isBusy: xe,
292
- isLoading: F,
293
- isError: v.isError || C.isError,
306
+ onSelectGap: be,
307
+ isBusy: Se,
308
+ isLoading: I,
309
+ isError: y.isError || w.isError,
294
310
  onRetry: () => {
295
- v.refetch(), C.refetch();
311
+ y.refetch(), w.refetch();
296
312
  },
297
313
  deleteDialog: {
298
- open: D !== null,
299
- isDeleting: S.isPending,
314
+ open: O !== null,
315
+ isDeleting: C.isPending,
300
316
  onOpenChange: (e) => {
301
- e || O(null);
317
+ e || k(null);
302
318
  },
303
- onConfirm: () => void be(),
304
- onCancel: () => O(null)
319
+ onConfirm: () => void xe(),
320
+ onCancel: () => k(null)
305
321
  }
306
322
  };
307
323
  }
308
324
  //#endregion
309
- export { v as DRAFT_POLICY_ID, b as useApprovalPolicyRules };
325
+ export { y as DRAFT_POLICY_ID, x as useApprovalPolicyRules };
@@ -4,19 +4,19 @@ import { useMemo as s } from "react";
4
4
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
5
5
  import { Plus as u } from "lucide-react";
6
6
  //#region ../../libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index11.js
7
- var d = ({ onAddRule: d, addRuleDisabled: f, addRuleDisabledReason: p, labels: m, headingComponent: h = "h2" }) => {
8
- let g = s(() => ({
7
+ var d = ({ onAddRule: d, addRuleDisabled: f, addRuleDisabledReason: p, labels: m, headingComponent: h = "h2", testIds: g }) => {
8
+ let _ = s(() => ({
9
9
  ...o,
10
10
  ...m
11
- }), [m]), _ = d ? /* @__PURE__ */ l(e, {
11
+ }), [m]), v = d ? /* @__PURE__ */ l(e, {
12
12
  type: "button",
13
13
  variant: "outline",
14
14
  size: "sm",
15
15
  onClick: d,
16
16
  disabled: f,
17
- "data-testid": "approval-policies-add-rule-button",
17
+ "data-testid": g?.addRuleButton,
18
18
  className: "ttw:shrink-0",
19
- children: [/* @__PURE__ */ c(u, {}), g.AddRule]
19
+ children: [/* @__PURE__ */ c(u, {}), _.AddRule]
20
20
  }) : null;
21
21
  return /* @__PURE__ */ l("div", {
22
22
  className: "ttw:flex ttw:items-start ttw:justify-between ttw:gap-4",
@@ -25,24 +25,24 @@ var d = ({ onAddRule: d, addRuleDisabled: f, addRuleDisabledReason: p, labels: m
25
25
  children: [/* @__PURE__ */ c(a, {
26
26
  variant: "h3",
27
27
  component: h,
28
- children: g.Title
28
+ children: _.Title
29
29
  }), /* @__PURE__ */ c(a, {
30
30
  variant: "body2",
31
31
  color: "muted",
32
- children: g.Description
32
+ children: _.Description
33
33
  })]
34
- }), _ && f && p ? /* @__PURE__ */ c(r, { children: /* @__PURE__ */ l(t, { children: [/* @__PURE__ */ c(i, {
34
+ }), v && f && p ? /* @__PURE__ */ c(r, { children: /* @__PURE__ */ l(t, { children: [/* @__PURE__ */ c(i, {
35
35
  asChild: !0,
36
36
  children: /* @__PURE__ */ c("span", {
37
37
  tabIndex: 0,
38
38
  className: "ttw:inline-flex ttw:shrink-0 ttw:cursor-not-allowed ttw:rounded-md",
39
- "data-testid": "approval-policies-add-rule-blocked",
40
- children: _
39
+ "data-testid": g?.addRuleBlocked,
40
+ children: v
41
41
  })
42
42
  }), /* @__PURE__ */ c(n, {
43
43
  side: "top",
44
44
  children: p
45
- })] }) }) : _]
45
+ })] }) }) : v]
46
46
  });
47
47
  };
48
48
  //#endregion