@tesouro/embedded-components-react 0.11.71 → 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 (88) hide show
  1. package/README.md +1 -0
  2. package/dist/index.css +35 -192
  3. package/dist/index.d.ts +75 -71
  4. package/dist/lib/SettingsWidget.d.ts +5 -1
  5. package/dist/lib/WidgetSuite.d.ts +4 -0
  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/packages/shared-ui-shadcn/dist/index.js +2301 -2283
  85. package/package.json +1 -1
  86. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index18.js +0 -291
  87. package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index19.js +0 -22
  88. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/avatarSwatch.js +0 -26
@@ -744,6 +744,10 @@ interface SettingsWidgetProps extends WidgetProviderProps {
744
744
  * falls back to a plain, unlinked sentence when unset, for the same reason
745
745
  * {@link SettingsWidgetProps.helpContactUrl} does. */
746
746
  profileContactUrl?: string;
747
+ /** Forwarded to the embedded Profile section's {@link ProfileWidget} —
748
+ * whether it paints its decorative header band, a soft wash of the theme's
749
+ * primary color. Defaults to `true`; pass `false` to drop it. */
750
+ showProfileHeader?: boolean;
747
751
  /** The section to show. Leave unset to let the widget own the selection;
748
752
  * supply it (with {@link SettingsWidgetProps.onSelectedSectionChange}) to
749
753
  * drive navigation from a route, a search param, or host state. A section
@@ -771,7 +775,7 @@ interface SettingsWidgetProps extends WidgetProviderProps {
771
775
  invoiceContent?: ReactNode;
772
776
  legalContent?: ReactNode;
773
777
  }
774
- declare function SettingsWidget({ labels, featureLabels, acceptInviteRedirectUri, teamInitialView, helpContactUrl, helpFaq, profileContactUrl, selectedSection, defaultSelectedSection, onSelectedSectionChange, additionalSections, profileContent, teamContent, billPayContent, helpContent, expenseContent, accountingContent, invoiceContent, legalContent, ...widgetProviderProps }: SettingsWidgetProps): React.JSX.Element;
778
+ declare function SettingsWidget({ labels, featureLabels, acceptInviteRedirectUri, teamInitialView, helpContactUrl, helpFaq, profileContactUrl, showProfileHeader, selectedSection, defaultSelectedSection, onSelectedSectionChange, additionalSections, profileContent, teamContent, billPayContent, helpContent, expenseContent, accountingContent, invoiceContent, legalContent, ...widgetProviderProps }: SettingsWidgetProps): React.JSX.Element;
775
779
 
776
780
  export { HELP_FAQ_EN, SettingsSection, SettingsWidget };
777
781
  export type { HelpFaqAnswer, HelpFaqBullet, HelpFaqBulletType, HelpFaqItem, HelpFaqSection, SettingsWidgetAdditionalSection, FeatureLabels as SettingsWidgetFeatureLabels, Labels as SettingsWidgetLabels, SettingsWidgetProps, SettingsWidgetSection, SettingsWidgetSectionId };
@@ -2960,6 +2960,10 @@ interface SettingsWidgetProps extends WidgetProviderProps {
2960
2960
  * falls back to a plain, unlinked sentence when unset, for the same reason
2961
2961
  * {@link SettingsWidgetProps.helpContactUrl} does. */
2962
2962
  profileContactUrl?: string;
2963
+ /** Forwarded to the embedded Profile section's {@link ProfileWidget} —
2964
+ * whether it paints its decorative header band, a soft wash of the theme's
2965
+ * primary color. Defaults to `true`; pass `false` to drop it. */
2966
+ showProfileHeader?: boolean;
2963
2967
  /** The section to show. Leave unset to let the widget own the selection;
2964
2968
  * supply it (with {@link SettingsWidgetProps.onSelectedSectionChange}) to
2965
2969
  * drive navigation from a route, a search param, or host state. A section
@@ -234,18 +234,19 @@ function b(t = {}) {
234
234
  return v("error"), !1;
235
235
  }
236
236
  }, [p, C.mutateAsync]), k = c(async (e) => {
237
- if (p) {
238
- b.current && clearTimeout(b.current), v("saving");
239
- try {
240
- await w.mutateAsync({ path: { approval_policy_id: e } }), v("success"), E();
241
- } catch {
242
- v("error");
243
- }
237
+ if (!p) return !1;
238
+ b.current && clearTimeout(b.current), v("saving");
239
+ try {
240
+ return await w.mutateAsync({ path: { approval_policy_id: e } }), v("success"), E(), !0;
241
+ } catch {
242
+ return v("error"), !1;
244
243
  }
245
244
  }, [p, w.mutateAsync]);
246
245
  return {
247
246
  rules: T,
248
247
  isLoading: x.isFetching,
248
+ isError: x.isError,
249
+ refetch: x.refetch,
249
250
  hasLoaded: x.data !== void 0,
250
251
  saveStatus: _,
251
252
  createRule: D,
@@ -15,7 +15,10 @@ var e = {
15
15
  }, n = {
16
16
  MissingRolePermissionTitle: "Approval policies unavailable",
17
17
  MissingRolePermissionDescription: "Your access token is missing the permissions required to manage approval policies. Contact your administrator to update your access.",
18
+ Retry: "Try again",
19
+ PoliciesUnavailableTitle: "Approval policies unavailable",
20
+ PoliciesUnavailableDescription: "Approval policies could not be loaded. Please try again.",
18
21
  RolesUnavailableTitle: "Roles unavailable",
19
- RolesUnavailableDescription: "Approver roles could not be loaded. Refresh the page to try again."
22
+ RolesUnavailableDescription: "Approver roles could not be loaded. Please try again."
20
23
  };
21
24
  export { e as ApproverOptionLabels, n as PermissionErrorLabels, t as ValidationErrorLabels };
@@ -13,73 +13,77 @@ import { ErrorState as o } from "../../../../shared/ui/dist/lib/ErrorState/Error
13
13
  import "../../../../shared/ui/dist/index.js";
14
14
  import { useAnalyticsTrack as s } from "../../../../shared/feature/dist/lib/analytics/hooks.js";
15
15
  import { WidgetProvider as c } from "../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
16
- import { useWidgetConfig as l, useWidgetLoading as ee } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
16
+ import { useWidgetConfig as ee, useWidgetLoading as te } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
17
17
  import "../../../../shared/feature/dist/index.js";
18
- import { ApproverOptionLabels as u, PermissionErrorLabels as d, ValidationErrorLabels as f } from "./index4.js";
19
- import { ExpenseApprovalPoliciesAnalyticsEvent as p, WIDGET_NAME as m } from "./index2.js";
20
- import { AmountConditionType as h, ApprovalOutcomeType as g } from "../../ui/dist/index2.js";
21
- import { ApprovalRuleToastLabels as _ } from "../../ui/dist/index3.js";
22
- import { ExpenseApprovalsPage as v } from "../../ui/dist/index8.js";
18
+ import { DeleteRuleDialogDefaultLabels as ne } from "../../../../shared/approval-policy/ui/dist/index18.js";
19
+ import { DeleteRuleDialog as re } from "../../../../shared/approval-policy/ui/dist/index19.js";
20
+ import "../../../../shared/approval-policy/ui/dist/index.js";
21
+ import { ApproverOptionLabels as l, PermissionErrorLabels as ie, ValidationErrorLabels as u } from "./index4.js";
22
+ import { ExpenseApprovalPoliciesAnalyticsEvent as ae, WIDGET_NAME as d } from "./index2.js";
23
+ import { AmountConditionType as f, ApprovalOutcomeType as p } from "../../ui/dist/index2.js";
24
+ import { ApprovalRuleCardLabels as oe, ApprovalRuleToastLabels as se } from "../../ui/dist/index3.js";
25
+ import { formatAmount as m } from "../../ui/dist/index4.js";
26
+ import { ExpenseApprovalsPage as ce } from "../../ui/dist/index8.js";
23
27
  import "../../ui/dist/index.js";
24
- import { useApprovalPolicies as te } from "./index3.js";
25
- import { expenseApprovalPoliciesTestIds as y } from "./index5.js";
26
- import { useEffect as b, useMemo as x, useState as S } from "react";
27
- import { Fragment as ne, jsx as C, jsxs as w } from "react/jsx-runtime";
28
+ import { useApprovalPolicies as le } from "./index3.js";
29
+ import { expenseApprovalPoliciesTestIds as h } from "./index5.js";
30
+ import { useEffect as g, useMemo as _, useRef as ue, useState as v } from "react";
31
+ import { Fragment as de, jsx as y, jsxs as fe } from "react/jsx-runtime";
28
32
  // ../../libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index6.js
29
- var T = {
33
+ var b = {
30
34
  minAmount: "",
31
35
  maxAmount: "",
32
- outcome: g.AutoApprove,
36
+ outcome: p.AutoApprove,
33
37
  approvers: []
34
38
  };
35
- function E(e, t) {
39
+ function x(e, t) {
36
40
  let n = (e ?? "").trim().toLowerCase();
37
41
  return n === t || n === `embedded:${t}`;
38
42
  }
39
- function D(e, t) {
43
+ function S(e, t) {
40
44
  return (e ?? "").toLowerCase().split(":").map((e) => e.trim()).filter(Boolean).some((e) => e === t);
41
45
  }
42
- function O(e) {
43
- return E(e, "cfo") || E(e, "finance_admin") || E(e, "finance-admin");
46
+ function C(e) {
47
+ return x(e, "cfo") || x(e, "finance_admin") || x(e, "finance-admin");
44
48
  }
45
- function k(e) {
46
- let t = e.find((e) => e.isSystemRole === !0 && E(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && O(e.key)), r = e.filter((e) => e.isSystemRole === !0 && e !== t && e !== n && !D(e.key, "employee") && !D(e.key, "bookkeeper")).map((e) => ({
49
+ function w(e, t = l) {
50
+ let n = e.find((e) => e.isSystemRole === !0 && x(e.key, "admin")), r = e.find((e) => e.isSystemRole === !0 && C(e.key)), i = e.filter((e) => e.isSystemRole === !0 && e !== n && e !== r && !S(e.key, "employee") && !S(e.key, "bookkeeper")).map((e) => ({
47
51
  id: e.id,
48
52
  label: e.name
49
- })), i = e.filter((e) => !e.isSystemRole && e.status?.toLowerCase() === "active").map((e) => ({
53
+ })), a = e.filter((e) => !e.isSystemRole && e.status?.toLowerCase() === "active").map((e) => ({
50
54
  id: e.id,
51
55
  label: e.name
52
56
  }));
53
57
  return [
54
- ...t ? [{
55
- id: t.id,
56
- label: u.AdminLabel,
57
- sublabel: u.AdminSublabel
58
+ ...n ? [{
59
+ id: n.id,
60
+ label: t.AdminLabel,
61
+ sublabel: t.AdminSublabel
58
62
  }] : [],
59
63
  {
60
64
  id: "reporting_manager",
61
- label: u.ReportingManagerLabel,
62
- sublabel: u.ReportingManagerSublabel
65
+ label: t.ReportingManagerLabel,
66
+ sublabel: t.ReportingManagerSublabel
63
67
  },
64
- ...n ? [{
65
- id: n.id,
66
- label: u.CfoLabel,
67
- sublabel: u.CfoSublabel
68
+ ...r ? [{
69
+ id: r.id,
70
+ label: t.CfoLabel,
71
+ sublabel: t.CfoSublabel
68
72
  }] : [],
69
- ...r,
70
- ...i
73
+ ...i,
74
+ ...a
71
75
  ];
72
76
  }
73
- function A(e) {
77
+ function T(e) {
74
78
  let t = e.minAmount.trim() !== "", n = e.maxAmount.trim() !== "";
75
- return t && n ? h.InRange : t ? h.GreaterThanOrEqual : n ? h.LessThan : h.All;
79
+ return t && n ? f.InRange : t ? f.GreaterThanOrEqual : n ? f.LessThan : f.All;
76
80
  }
77
- function j(e) {
78
- return [e.conditionType === h.LessThan || e.conditionType === h.All ? 0 : e.minAmount ?? 0, e.conditionType === h.GreaterThanOrEqual || e.conditionType === h.All ? Infinity : e.maxAmount ?? 0];
81
+ function E(e) {
82
+ return [e.conditionType === f.LessThan || e.conditionType === f.All ? 0 : e.minAmount ?? 0, e.conditionType === f.GreaterThanOrEqual || e.conditionType === f.All ? Infinity : e.maxAmount ?? 0];
79
83
  }
80
- function M(e) {
84
+ function pe(e) {
81
85
  if (e.length === 0) return !1;
82
- let t = e.map(j).sort((e, t) => e[0] - t[0]);
86
+ let t = e.map(E).sort((e, t) => e[0] - t[0]);
83
87
  if (t[0][0] > 0) return !1;
84
88
  let n = 0;
85
89
  for (let [e, r] of t) {
@@ -88,9 +92,9 @@ function M(e) {
88
92
  }
89
93
  return n === Infinity;
90
94
  }
91
- function N(e) {
95
+ function me(e) {
92
96
  if (e.length === 0) return [];
93
- let t = e.map(j).sort((e, t) => e[0] - t[0]), n = [], r = 0;
97
+ let t = e.map(E).sort((e, t) => e[0] - t[0]), n = [], r = 0;
94
98
  for (let [e, i] of t) e > r && n.push({
95
99
  from: r,
96
100
  to: e
@@ -100,33 +104,33 @@ function N(e) {
100
104
  to: null
101
105
  }), n;
102
106
  }
103
- function P(e) {
104
- let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = A(e);
105
- return [r === h.LessThan || r === h.All ? 0 : t, r === h.GreaterThanOrEqual || r === h.All ? Infinity : n];
107
+ function D(e) {
108
+ let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = T(e);
109
+ return [r === f.LessThan || r === f.All ? 0 : t, r === f.GreaterThanOrEqual || r === f.All ? Infinity : n];
106
110
  }
107
- function F(e, t, n) {
108
- let [r, i] = P(e);
111
+ function O(e, t, n) {
112
+ let [r, i] = D(e);
109
113
  return t.filter((e) => e.id !== n).some((e) => {
110
- let [t, n] = j(e);
114
+ let [t, n] = E(e);
111
115
  return r < n && t < i;
112
116
  });
113
117
  }
114
- function I(e, t, n) {
115
- let r = {}, i = e.minAmount.trim() !== "", a = e.maxAmount.trim() !== "", o = Number(e.minAmount.trim()), s = Number(e.maxAmount.trim());
116
- return i && (!Number.isFinite(o) || o < 0) && (r.minAmount = f.InvalidMinAmount), a && (!Number.isFinite(s) || s <= 0) && (r.maxAmount = f.InvalidMaxAmount), i && a && !r.minAmount && !r.maxAmount && o >= s && (r.maxAmount = f.MaxLessThanOrEqualToMin), e.outcome === g.RequireApproval && e.approvers.length === 0 && (r.approvers = f.ApproversRequired), !r.minAmount && !r.maxAmount && F(e, t, n) && (a ? r.maxAmount = f.ConflictsWithAnotherRule : r.minAmount = f.ConflictsWithAnotherRule), r;
118
+ function k(e, t, n, r = u) {
119
+ let i = {}, a = e.minAmount.trim() !== "", o = e.maxAmount.trim() !== "", s = Number(e.minAmount.trim()), c = Number(e.maxAmount.trim());
120
+ return a && (!Number.isFinite(s) || s < 0) && (i.minAmount = r.InvalidMinAmount), o && (!Number.isFinite(c) || c <= 0) && (i.maxAmount = r.InvalidMaxAmount), a && o && !i.minAmount && !i.maxAmount && s >= c && (i.maxAmount = r.MaxLessThanOrEqualToMin), e.outcome === p.RequireApproval && e.approvers.length === 0 && (i.approvers = r.ApproversRequired), !i.minAmount && !i.maxAmount && O(e, t, n) && (o ? i.maxAmount = r.ConflictsWithAnotherRule : i.minAmount = r.ConflictsWithAnotherRule), i;
117
121
  }
118
- function L(e, t) {
119
- let n = A(t);
122
+ function A(e, t) {
123
+ let n = T(t);
120
124
  return {
121
125
  id: e,
122
126
  conditionType: n,
123
- minAmount: n === h.InRange || n === h.GreaterThanOrEqual ? Number(t.minAmount) : void 0,
124
- maxAmount: n === h.LessThan || n === h.InRange ? Number(t.maxAmount) : void 0,
127
+ minAmount: n === f.InRange || n === f.GreaterThanOrEqual ? Number(t.minAmount) : void 0,
128
+ maxAmount: n === f.LessThan || n === f.InRange ? Number(t.maxAmount) : void 0,
125
129
  outcome: t.outcome,
126
- approvers: t.outcome === g.RequireApproval ? t.approvers : []
130
+ approvers: t.outcome === p.RequireApproval ? t.approvers : []
127
131
  };
128
132
  }
129
- function R(e) {
133
+ function he(e) {
130
134
  return {
131
135
  minAmount: e.minAmount == null ? "" : String(e.minAmount),
132
136
  maxAmount: e.maxAmount == null ? "" : String(e.maxAmount),
@@ -134,91 +138,152 @@ function R(e) {
134
138
  approvers: e.approvers
135
139
  };
136
140
  }
137
- function z() {
138
- let c = s();
139
- b(() => {
140
- c(p.Mounted);
141
- }, [c]);
142
- let { initResponse: f } = l(), m = ee(), h = t(n().organizationStatus), g = f?.scopes?.includes(r.RoleReadOrg) ?? !1, { data: D, isResolving: A, isError: j } = i({ enabled: g }), P = x(() => k(D?.data ?? []), [D]), F = x(() => {
143
- let e = D?.data ?? [], t = e.find((e) => e.isSystemRole === !0 && E(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && O(e.key)), r = { reporting_manager: u.ReportingManagerLabel };
144
- t && (r[t.id] = u.AdminLabel), n && (r[n.id] = u.CfoLabel);
141
+ function j({ headerActionContainer: c, labels: d }) {
142
+ let S = _(() => ({
143
+ ...l,
144
+ ...d?.approvers
145
+ }), [d?.approvers]), T = _(() => ({
146
+ ...u,
147
+ ...d?.validation
148
+ }), [d?.validation]), E = _(() => ({
149
+ ...ie,
150
+ ...d?.errors
151
+ }), [d?.errors]), D = _(() => ({
152
+ ...se,
153
+ ...d?.toast
154
+ }), [d?.toast]), O = s();
155
+ g(() => {
156
+ O(ae.Mounted);
157
+ }, [O]);
158
+ let { initResponse: j } = ee(), M = te(), ge = t(n().organizationStatus), N = j?.scopes?.includes(r.RoleReadOrg) ?? !1, { data: P, isResolving: _e, isError: ve, refetch: ye } = i({ enabled: N }), be = _(() => w(P?.data ?? [], S), [P, S]), xe = _(() => {
159
+ let e = P?.data ?? [], t = e.find((e) => e.isSystemRole === !0 && x(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && C(e.key)), r = { reporting_manager: S.ReportingManagerLabel };
160
+ t && (r[t.id] = S.AdminLabel), n && (r[n.id] = S.CfoLabel);
145
161
  for (let t of e) r[t.id] || (r[t.id] = t.name);
146
162
  return r;
147
- }, [D]), { rules: z, isLoading: B, hasLoaded: re, saveStatus: V, createRule: ie, updateRule: H, deleteRule: U } = te(F), [W, G] = S(!1), [K, q] = S(T), [J, Y] = S(null), [X, Z] = S(null);
148
- b(() => {
149
- V === "success" && e.success(_.Saved), V === "error" && e.error(_.FailedToSave);
150
- }, [V]);
151
- let Q = B || m && !f || h && !re, ae = M(z), oe = N(z), $ = Q || A || V === "saving", se = W ? I(K, z) : {}, ce = X && J ? I(X, z, J) : {}, le = () => {
152
- G(!0), q(T);
153
- }, ue = () => {
154
- G(!1);
155
- }, de = async () => {
156
- let e = I(K, z);
163
+ }, [P, S]), { rules: F, isLoading: I, isError: Se, refetch: Ce, hasLoaded: L, saveStatus: R, createRule: we, updateRule: Te, deleteRule: Ee } = le(xe), [z, B] = v(!1), [V, H] = v(null), [U, W] = v(!1), [G, K] = v(b), [q, J] = v(null), [Y, X] = v(null), Z = ue(D);
164
+ g(() => {
165
+ Z.current = D;
166
+ }, [D]), g(() => {
167
+ R === "success" && e.success(Z.current.Saved), R === "error" && e.error(Z.current.FailedToSave);
168
+ }, [R]);
169
+ let Q = I || M && !j || ge && !L, De = pe(F), Oe = me(F), $ = Q || _e || R === "saving", ke = U && z ? k(G, F, void 0, T) : {}, Ae = Y && q && z ? k(Y, F, q, T) : {}, je = () => {
170
+ B(!1), W(!0), K(b);
171
+ }, Me = () => {
172
+ B(!1), W(!1);
173
+ }, Ne = async () => {
174
+ B(!0);
175
+ let e = k(G, F, void 0, T);
157
176
  if (Object.keys(e).length > 0) return;
158
177
  let t = crypto.randomUUID();
159
- await ie(L(t, K)) && (G(!1), q(T));
160
- }, fe = (e) => {
161
- q(e);
162
- }, pe = (e) => {
163
- let t = z.find((t) => t.id === e);
164
- t && (G(!1), q(T), Y(e), Z(R(t)));
165
- }, me = () => {
166
- Y(null), Z(null);
167
- }, he = async () => {
168
- if (!J || !X) return;
169
- let e = I(X, z, J);
170
- Object.keys(e).length > 0 || await H(J, L(J, X)) && (Y(null), Z(null));
171
- }, ge = (e) => {
172
- Z(e);
173
- }, _e = async (e) => {
174
- await U(e), J === e && (Y(null), Z(null));
178
+ await we(A(t, G)) && (W(!1), K(b));
179
+ }, Pe = (e) => {
180
+ K(e);
181
+ }, Fe = (e) => {
182
+ B(!1);
183
+ let t = F.find((t) => t.id === e);
184
+ t && (W(!1), K(b), J(e), X(he(t)));
185
+ }, Ie = () => {
186
+ B(!1), J(null), X(null);
187
+ }, Le = async () => {
188
+ if (B(!0), !q || !Y) return;
189
+ let e = k(Y, F, q, T);
190
+ Object.keys(e).length > 0 || await Te(q, A(q, Y)) && (J(null), X(null));
191
+ }, Re = (e) => {
192
+ X(e);
193
+ }, ze = (() => {
194
+ let e = F.find((e) => e.id === V);
195
+ if (!e) return;
196
+ let t = {
197
+ ...ne,
198
+ ...d?.deleteDialog
199
+ }, n = {
200
+ ...oe,
201
+ ...d?.ruleCard
202
+ }, r = `${n.For} ${n.Expenses}`, i = `${n.For} ${n.All} ${n.Expenses}`;
203
+ e.conditionType === f.LessThan && (i = `${r} ${n.LessThan} ${m(e.maxAmount ?? 0)}`), e.conditionType === f.GreaterThanOrEqual && (i = `${r} ${n.GreaterThanOrEqual} ${m(e.minAmount ?? 0)}`), e.conditionType === f.InRange && (i = `${r} ${n.GreaterThanOrEqual} ${m(e.minAmount ?? 0)} ${n.AndLessThan} ${m(e.maxAmount ?? 0)}`);
204
+ let a = e.outcome === p.AutoApprove ? n.AutoApprove : `${n.RequireApprovalFrom} ${e.approvers.map((e) => e.label).join(` ${n.ApproverSeparator} `)}`;
205
+ return [{
206
+ label: t.Range,
207
+ value: i
208
+ }, {
209
+ label: t.Outcome,
210
+ value: a
211
+ }];
212
+ })(), Be = async () => {
213
+ V && await Ee(V) && (q === V && (J(null), X(null)), H(null));
175
214
  };
176
- return f !== void 0 && !g ? /* @__PURE__ */ C(o, {
177
- title: d.MissingRolePermissionTitle,
178
- description: d.MissingRolePermissionDescription
179
- }) : j ? /* @__PURE__ */ C(o, {
180
- title: d.RolesUnavailableTitle,
181
- description: d.RolesUnavailableDescription
182
- }) : /* @__PURE__ */ w(ne, { children: [/* @__PURE__ */ C(a, {}), /* @__PURE__ */ C(v, {
183
- rules: z,
184
- isBusy: $,
185
- isLoading: Q,
186
- isAddingRule: W,
187
- newRuleFormValues: K,
188
- newRuleValidationErrors: se,
189
- editingRuleId: J,
190
- editingRuleFormValues: X,
191
- editingRuleValidationErrors: ce,
192
- approverOptions: $ ? [] : P,
193
- allExpensesAreCovered: ae,
194
- gapIntervals: oe,
195
- onAddRuleClick: le,
196
- onCancelAddRule: ue,
197
- onSaveNewRule: () => void de(),
198
- onNewRuleFormChange: fe,
199
- onEditRule: pe,
200
- onCancelEditRule: me,
201
- onSaveEditRule: () => void he(),
202
- onEditRuleFormChange: ge,
203
- onDeleteRule: (e) => void _e(e),
204
- testIds: {
205
- ruleCard: { root: y.ruleCard },
206
- ruleForm: {
207
- root: y.ruleForm,
208
- saveButton: y.ruleFormSaveButton,
209
- minAmountInput: y.ruleFormMinAmountInput,
210
- maxAmountInput: y.ruleFormMaxAmountInput
215
+ return j !== void 0 && !N ? /* @__PURE__ */ y(o, {
216
+ title: E.MissingRolePermissionTitle,
217
+ description: E.MissingRolePermissionDescription
218
+ }) : ve ? /* @__PURE__ */ y(o, {
219
+ title: E.RolesUnavailableTitle,
220
+ description: E.RolesUnavailableDescription,
221
+ retryLabel: E.Retry,
222
+ onRetry: () => void ye()
223
+ }) : Se && !I && !L ? /* @__PURE__ */ y(o, {
224
+ title: E.PoliciesUnavailableTitle,
225
+ description: E.PoliciesUnavailableDescription,
226
+ retryLabel: E.Retry,
227
+ onRetry: () => void Ce()
228
+ }) : /* @__PURE__ */ fe(de, { children: [
229
+ /* @__PURE__ */ y(a, {}),
230
+ /* @__PURE__ */ y(ce, {
231
+ rules: F,
232
+ labels: d,
233
+ isBusy: $,
234
+ isLoading: Q,
235
+ isAddingRule: U,
236
+ newRuleFormValues: G,
237
+ newRuleValidationErrors: ke,
238
+ editingRuleId: q,
239
+ editingRuleFormValues: Y,
240
+ editingRuleValidationErrors: Ae,
241
+ approverOptions: $ ? [] : be,
242
+ allExpensesAreCovered: De,
243
+ gapIntervals: Oe,
244
+ onAddRuleClick: je,
245
+ headerActionContainer: c,
246
+ onCancelAddRule: Me,
247
+ onSaveNewRule: () => void Ne(),
248
+ onNewRuleFormChange: Pe,
249
+ onEditRule: Fe,
250
+ onCancelEditRule: Ie,
251
+ onSaveEditRule: () => void Le(),
252
+ onEditRuleFormChange: Re,
253
+ onDeleteRule: H,
254
+ testIds: {
255
+ ruleCard: { root: h.ruleCard },
256
+ ruleForm: {
257
+ root: h.ruleForm,
258
+ saveButton: h.ruleFormSaveButton,
259
+ minAmountInput: h.ruleFormMinAmountInput,
260
+ maxAmountInput: h.ruleFormMaxAmountInput
261
+ }
211
262
  }
212
- }
213
- })] });
263
+ }),
264
+ /* @__PURE__ */ y(re, {
265
+ labels: d?.deleteDialog,
266
+ details: ze,
267
+ open: V !== null,
268
+ onOpenChange: (e) => {
269
+ e || H(null);
270
+ },
271
+ onCancel: () => H(null),
272
+ onConfirm: () => void Be(),
273
+ isDeleting: R === "saving"
274
+ })
275
+ ] });
214
276
  }
215
- function B({ token: e, orgId: t, widgetToken: n, organizationId: r, ...i } = {}) {
216
- return /* @__PURE__ */ C(c, {
217
- ...i,
218
- widgetName: m,
277
+ function M({ token: e, orgId: t, widgetToken: n, organizationId: r, headerActionContainer: i, labels: a, ...o } = {}) {
278
+ return /* @__PURE__ */ y(c, {
279
+ ...o,
280
+ widgetName: d,
219
281
  widgetToken: n === void 0 ? e : n,
220
282
  organizationId: r === void 0 ? t : r,
221
- children: /* @__PURE__ */ C(z, {})
283
+ children: /* @__PURE__ */ y(j, {
284
+ headerActionContainer: i,
285
+ labels: a
286
+ })
222
287
  });
223
288
  }
224
- export { B as ExpenseApprovalPoliciesWidget, B as default, k as buildApproverOptions, E as isEmbeddedSystemRoleKey, D as roleKeyHasSegment };
289
+ export { M as ExpenseApprovalPoliciesWidget, M as default, w as buildApproverOptions, x as isEmbeddedSystemRoleKey, S as roleKeyHasSegment };
@@ -1,8 +1,8 @@
1
1
  import { AmountConditionType as e, ApprovalOutcomeType as t } from "./index2.js";
2
- import { ApprovalRuleToastLabels as n } from "./index3.js";
3
- import "./index4.js";
2
+ import { ApprovalRuleCardLabels as n, ApprovalRuleToastLabels as r } from "./index3.js";
3
+ import { formatAmount as i } from "./index4.js";
4
4
  import "./index5.js";
5
5
  import "./index6.js";
6
6
  import "./index7.js";
7
- import { ExpenseApprovalsPage as r } from "./index8.js";
8
- export { e as AmountConditionType, t as ApprovalOutcomeType, n as ApprovalRuleToastLabels, r as ExpenseApprovalsPage };
7
+ import { ExpenseApprovalsPage as a } from "./index8.js";
8
+ export { e as AmountConditionType, t as ApprovalOutcomeType, n as ApprovalRuleCardLabels, r as ApprovalRuleToastLabels, a as ExpenseApprovalsPage, i as formatAmount };
@@ -10,6 +10,7 @@ var e = {
10
10
  CreateAnotherRule: "Create another rule",
11
11
  LoadingRules: "Loading approval rules"
12
12
  }, t = {
13
+ Outcome: "Approval outcome",
13
14
  ForExpenses: "For",
14
15
  ExpensesBold: "expenses",
15
16
  GreaterThanOrEqualTo: "greater than or equal to",
@@ -26,8 +27,15 @@ var e = {
26
27
  Cancel: "Cancel",
27
28
  Save: "Save"
28
29
  }, n = {
30
+ For: "For",
31
+ All: "all",
32
+ Expenses: "expenses",
33
+ LessThan: "less than",
34
+ GreaterThanOrEqual: "greater than or equal to",
35
+ AndLessThan: "and less than",
29
36
  RequireApprovalFrom: "Require approval from",
30
37
  AutoApprove: "Auto-approve",
38
+ ApproverSeparator: "or",
31
39
  DeleteRuleAriaLabel: "Delete rule",
32
40
  EditRuleAriaLabel: "Edit rule"
33
41
  }, r = {
@@ -40,7 +48,9 @@ var e = {
40
48
  FailedToSave: "Failed to save.",
41
49
  ConflictsWithAnotherRule: "This conflicts with another rule."
42
50
  }, a = {
43
- Prefix: "The system default will apply to transactions",
51
+ Prefix: "The",
52
+ Default: "system default",
53
+ AfterDefault: "will apply to transactions",
44
54
  Suffix: ", requiring approval from a company admin.",
45
55
  Above: "above",
46
56
  RangeSeparator: "–"
@@ -1,8 +1,10 @@
1
1
  // ../../libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index4.js
2
2
  function e(e) {
3
- return `$${e.toLocaleString(void 0, {
4
- minimumFractionDigits: 0,
3
+ return new Intl.NumberFormat("en-US", {
4
+ style: "currency",
5
+ currency: "USD",
6
+ minimumFractionDigits: 2,
5
7
  maximumFractionDigits: 2
6
- })}`;
8
+ }).format(e);
7
9
  }
8
10
  export { e as formatAmount };
@@ -1,36 +1,42 @@
1
1
  import { Button as e, Typography as t } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
2
2
  import { EmptyApprovalRulesLabels as n } from "./index3.js";
3
3
  import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
- import { PlusIcon as a, ShieldCheck as o } from "lucide-react";
4
+ import { ShieldCheck as a } from "lucide-react";
5
5
  // ../../libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index5.js
6
- var s = ({ onAddRule: s, onLearnMore: c }) => /* @__PURE__ */ i("div", {
7
- className: "ttw:flex ttw:flex-col ttw:items-center ttw:py-12 ttw:gap-4 ttw:w-full ttw:max-w-[600px] ttw:mx-auto",
8
- children: [
9
- /* @__PURE__ */ r("div", {
10
- className: "ttw:w-12 ttw:h-12 ttw:rounded-full ttw:bg-muted ttw:flex ttw:items-center ttw:justify-center ttw:text-muted-foreground",
11
- children: /* @__PURE__ */ r(o, { size: 20 })
12
- }),
13
- /* @__PURE__ */ r(t, {
14
- variant: "h6",
15
- children: n.Title
16
- }),
17
- /* @__PURE__ */ r(t, {
18
- variant: "body2",
19
- color: "muted",
20
- className: "ttw:text-center",
21
- children: n.Body
22
- }),
23
- /* @__PURE__ */ i(e, {
24
- onClick: s,
25
- className: "ttw:mt-1",
26
- children: [/* @__PURE__ */ r(a, {}), n.AddRule]
27
- }),
28
- c && /* @__PURE__ */ r(e, {
29
- variant: "link",
30
- className: "ttw:text-muted-foreground",
31
- onClick: c,
32
- children: n.LearnMore
33
- })
34
- ]
35
- });
36
- export { s as EmptyApprovalRules };
6
+ var o = ({ onAddRule: o, labels: s, onLearnMore: c }) => {
7
+ let l = {
8
+ ...n,
9
+ ...s
10
+ };
11
+ return /* @__PURE__ */ i("div", {
12
+ className: "ttw:flex ttw:flex-col ttw:items-center ttw:py-12 ttw:gap-4 ttw:w-full ttw:max-w-[600px] ttw:mx-auto",
13
+ children: [
14
+ /* @__PURE__ */ r("div", {
15
+ className: "ttw:w-12 ttw:h-12 ttw:rounded-full ttw:bg-muted ttw:flex ttw:items-center ttw:justify-center ttw:text-muted-foreground",
16
+ children: /* @__PURE__ */ r(a, { size: 20 })
17
+ }),
18
+ /* @__PURE__ */ r(t, {
19
+ variant: "h6",
20
+ children: l.Title
21
+ }),
22
+ /* @__PURE__ */ r(t, {
23
+ variant: "body2",
24
+ color: "muted",
25
+ className: "ttw:text-center",
26
+ children: l.Body
27
+ }),
28
+ /* @__PURE__ */ r(e, {
29
+ onClick: o,
30
+ className: "ttw:mt-1",
31
+ children: l.AddRule
32
+ }),
33
+ c && /* @__PURE__ */ r(e, {
34
+ variant: "link",
35
+ className: "ttw:text-muted-foreground",
36
+ onClick: c,
37
+ children: l.LearnMore
38
+ })
39
+ ]
40
+ });
41
+ };
42
+ export { o as EmptyApprovalRules };