@tesouro/embedded-components-react 0.5.84 → 0.5.85

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.
package/dist/index.d.ts CHANGED
@@ -4232,7 +4232,7 @@ declare function ExpenseManagementWidget({ baseUrl, widgetToken, organizationId,
4232
4232
  type ReceivablesWidgetMoniteProps = MoniteRegionProviderProps & Omit<ReceivablesProps, 'pageTitleComponent' | 'initialView' | 'initialCounterpartId'> & {
4233
4233
  pageTitleComponent?: ReceivablesProps['pageTitleComponent'];
4234
4234
  };
4235
- declare function ReceivablesWidgetMonite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, errorFallback, onError, finopsThemeColors, analytics, disclosuresAcceptance, providerLabels, pageTitleComponent, uiFramework, ...receivablesProps }: ReceivablesWidgetMoniteProps): React.JSX.Element;
4235
+ declare function ReceivablesWidgetMonite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, errorFallback, onError, finopsThemeColors, analytics, disclosuresAcceptance, providerLabels, pageTitleComponent, uiFramework, implementation, ...receivablesProps }: ReceivablesWidgetMoniteProps): React.JSX.Element;
4236
4236
 
4237
4237
  interface ProductFormSheetLabels {
4238
4238
  createTitle: string;
@@ -662,7 +662,7 @@ type MoniteRegionProviderProps = WidgetProviderProps & MoniteWrapperProps;
662
662
  type ReceivablesWidgetMoniteProps = MoniteRegionProviderProps & Omit<ReceivablesProps, 'pageTitleComponent' | 'initialView' | 'initialCounterpartId'> & {
663
663
  pageTitleComponent?: ReceivablesProps['pageTitleComponent'];
664
664
  };
665
- declare function ReceivablesWidgetMonite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, errorFallback, onError, finopsThemeColors, analytics, disclosuresAcceptance, providerLabels, pageTitleComponent, uiFramework, ...receivablesProps }: ReceivablesWidgetMoniteProps): React.JSX.Element;
665
+ declare function ReceivablesWidgetMonite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, errorFallback, onError, finopsThemeColors, analytics, disclosuresAcceptance, providerLabels, pageTitleComponent, uiFramework, implementation, ...receivablesProps }: ReceivablesWidgetMoniteProps): React.JSX.Element;
666
666
 
667
667
  export { ReceivablesWidgetMonite as InvoicingWidget };
668
668
  export type { ReceivablesWidgetMoniteProps as InvoicingWidgetProps };
@@ -46,28 +46,16 @@ function m({ isOpen: e, onClose: t, ...n }) {
46
46
  ...n
47
47
  }) : null;
48
48
  }
49
- function h({ baseUrl: e, widgetToken: t, organizationId: r, configClient: i, gatewayRouting: a, linkComponent: s, implementation: c, uiFramework: l, errorFallback: u, onError: f, analytics: p, disclosuresAcceptance: h, providerLabels: g, isOpen: _, preSelectedReceiptIds: v, onClose: y, targetTransactionId: b, onSingleTransactionUpdate: x }) {
49
+ function h({ isOpen: e, preSelectedReceiptIds: t, onClose: r, targetTransactionId: i, onSingleTransactionUpdate: a, ...s }) {
50
50
  return /* @__PURE__ */ d(n, {
51
+ ...s,
51
52
  widgetName: o,
52
- baseUrl: e,
53
- widgetToken: t,
54
- organizationId: r,
55
- configClient: i,
56
- gatewayRouting: a,
57
- linkComponent: s,
58
- implementation: c,
59
- uiFramework: l,
60
- errorFallback: u,
61
- onError: f,
62
- analytics: p,
63
- disclosuresAcceptance: h,
64
- providerLabels: g,
65
53
  children: /* @__PURE__ */ d(m, {
66
- isOpen: _,
67
- preSelectedReceiptIds: v,
68
- onClose: y,
69
- targetTransactionId: b,
70
- onSingleTransactionUpdate: x
54
+ isOpen: e,
55
+ preSelectedReceiptIds: t,
56
+ onClose: r,
57
+ targetTransactionId: i,
58
+ onSingleTransactionUpdate: a
71
59
  })
72
60
  });
73
61
  }
@@ -17,31 +17,31 @@ import { ApproverOptionLabels as l, PermissionErrorLabels as u, ValidationErrorL
17
17
  import { ExpenseApprovalPoliciesAnalyticsEvent as f, WIDGET_NAME as p } from "./index2.js";
18
18
  import { AmountConditionType as m, ApprovalOutcomeType as h } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/types.js";
19
19
  import { ApprovalRuleToastLabels as g } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/labels.js";
20
- import { ExpenseApprovalsPage as ee } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ExpenseApprovalsPage.js";
20
+ import { ExpenseApprovalsPage as _ } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ExpenseApprovalsPage.js";
21
21
  import "../../ui/dist/index.js";
22
- import { useApprovalPolicies as _ } from "./index3.js";
23
- import { expenseApprovalPoliciesTestIds as v } from "./index5.js";
24
- import { useEffect as y, useMemo as b, useState as x } from "react";
25
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
22
+ import { useApprovalPolicies as v } from "./index3.js";
23
+ import { expenseApprovalPoliciesTestIds as y } from "./index5.js";
24
+ import { useEffect as b, useMemo as x, useState as S } from "react";
25
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
26
26
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index6.js
27
- var T = {
27
+ var E = {
28
28
  minAmount: "",
29
29
  maxAmount: "",
30
30
  outcome: h.AutoApprove,
31
31
  approvers: []
32
32
  };
33
- function E(e, t) {
33
+ function D(e, t) {
34
34
  let n = (e ?? "").trim().toLowerCase();
35
35
  return n === t || n === `embedded:${t}`;
36
36
  }
37
- function D(e, t) {
37
+ function O(e, t) {
38
38
  return (e ?? "").toLowerCase().split(":").map((e) => e.trim()).filter(Boolean).some((e) => e === t);
39
39
  }
40
- function O(e) {
41
- return E(e, "cfo") || E(e, "finance_admin") || E(e, "finance-admin");
42
- }
43
40
  function k(e) {
44
- 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) => ({
41
+ return D(e, "cfo") || D(e, "finance_admin") || D(e, "finance-admin");
42
+ }
43
+ function A(e) {
44
+ let t = e.find((e) => e.isSystemRole === !0 && D(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && k(e.key)), r = e.filter((e) => e.isSystemRole === !0 && e !== t && e !== n && !O(e.key, "employee") && !O(e.key, "bookkeeper")).map((e) => ({
45
45
  id: e.id,
46
46
  label: e.name
47
47
  })), i = e.filter((e) => !e.isSystemRole && e.status?.toLowerCase() === "active").map((e) => ({
@@ -68,16 +68,16 @@ function k(e) {
68
68
  ...i
69
69
  ];
70
70
  }
71
- function A(e) {
71
+ function j(e) {
72
72
  let t = e.minAmount.trim() !== "", n = e.maxAmount.trim() !== "";
73
73
  return t && n ? m.InRange : t ? m.GreaterThanOrEqual : n ? m.LessThan : m.All;
74
74
  }
75
- function j(e) {
75
+ function M(e) {
76
76
  return [e.conditionType === m.LessThan || e.conditionType === m.All ? 0 : e.minAmount ?? 0, e.conditionType === m.GreaterThanOrEqual || e.conditionType === m.All ? Infinity : e.maxAmount ?? 0];
77
77
  }
78
- function te(e) {
78
+ function N(e) {
79
79
  if (e.length === 0) return !1;
80
- let t = e.map(j).sort((e, t) => e[0] - t[0]);
80
+ let t = e.map(M).sort((e, t) => e[0] - t[0]);
81
81
  if (t[0][0] > 0) return !1;
82
82
  let n = 0;
83
83
  for (let [e, r] of t) {
@@ -86,9 +86,9 @@ function te(e) {
86
86
  }
87
87
  return n === Infinity;
88
88
  }
89
- function M(e) {
89
+ function P(e) {
90
90
  if (e.length === 0) return [];
91
- let t = e.map(j).sort((e, t) => e[0] - t[0]), n = [], r = 0;
91
+ let t = e.map(M).sort((e, t) => e[0] - t[0]), n = [], r = 0;
92
92
  for (let [e, i] of t) e > r && n.push({
93
93
  from: r,
94
94
  to: e
@@ -98,23 +98,23 @@ function M(e) {
98
98
  to: null
99
99
  }), n;
100
100
  }
101
- function N(e) {
102
- let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = A(e);
101
+ function F(e) {
102
+ let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = j(e);
103
103
  return [r === m.LessThan || r === m.All ? 0 : t, r === m.GreaterThanOrEqual || r === m.All ? Infinity : n];
104
104
  }
105
- function P(e, t, n) {
106
- let [r, i] = N(e);
105
+ function I(e, t, n) {
106
+ let [r, i] = F(e);
107
107
  return t.filter((e) => e.id !== n).some((e) => {
108
- let [t, n] = j(e);
108
+ let [t, n] = M(e);
109
109
  return r < n && t < i;
110
110
  });
111
111
  }
112
- function F(e, t, n) {
112
+ function L(e, t, n) {
113
113
  let r = {}, i = e.minAmount.trim() !== "", a = e.maxAmount.trim() !== "", o = Number(e.minAmount.trim()), s = Number(e.maxAmount.trim());
114
- return i && (!Number.isFinite(o) || o < 0) && (r.minAmount = d.InvalidMinAmount), a && (!Number.isFinite(s) || s <= 0) && (r.maxAmount = d.InvalidMaxAmount), i && a && !r.minAmount && !r.maxAmount && o >= s && (r.maxAmount = d.MaxLessThanOrEqualToMin), e.outcome === h.RequireApproval && e.approvers.length === 0 && (r.approvers = d.ApproversRequired), !r.minAmount && !r.maxAmount && P(e, t, n) && (a ? r.maxAmount = d.ConflictsWithAnotherRule : r.minAmount = d.ConflictsWithAnotherRule), r;
114
+ return i && (!Number.isFinite(o) || o < 0) && (r.minAmount = d.InvalidMinAmount), a && (!Number.isFinite(s) || s <= 0) && (r.maxAmount = d.InvalidMaxAmount), i && a && !r.minAmount && !r.maxAmount && o >= s && (r.maxAmount = d.MaxLessThanOrEqualToMin), e.outcome === h.RequireApproval && e.approvers.length === 0 && (r.approvers = d.ApproversRequired), !r.minAmount && !r.maxAmount && I(e, t, n) && (a ? r.maxAmount = d.ConflictsWithAnotherRule : r.minAmount = d.ConflictsWithAnotherRule), r;
115
115
  }
116
- function I(e, t) {
117
- let n = A(t);
116
+ function R(e, t) {
117
+ let n = j(t);
118
118
  return {
119
119
  id: e,
120
120
  conditionType: n,
@@ -124,7 +124,7 @@ function I(e, t) {
124
124
  approvers: t.outcome === h.RequireApproval ? t.approvers : []
125
125
  };
126
126
  }
127
- function L(e) {
127
+ function z(e) {
128
128
  return {
129
129
  minAmount: e.minAmount == null ? "" : String(e.minAmount),
130
130
  maxAmount: e.maxAmount == null ? "" : String(e.maxAmount),
@@ -132,67 +132,67 @@ function L(e) {
132
132
  approvers: e.approvers
133
133
  };
134
134
  }
135
- function R() {
135
+ function B() {
136
136
  let o = a();
137
- y(() => {
137
+ b(() => {
138
138
  o(f.Mounted);
139
139
  }, [o]);
140
- let { initResponse: d } = s(), p = c(), m = d?.scopes?.includes(t.RoleReadOrg) ?? !1, { data: h, isResolving: D, isError: A } = n({ enabled: m }), j = b(() => k(h?.data ?? []), [h]), N = b(() => {
141
- let e = h?.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: l.ReportingManagerLabel };
140
+ let { initResponse: d } = s(), p = c(), m = d?.scopes?.includes(t.RoleReadOrg) ?? !1, { data: h, isResolving: O, isError: j } = n({ enabled: m }), M = x(() => A(h?.data ?? []), [h]), F = x(() => {
141
+ let e = h?.data ?? [], t = e.find((e) => e.isSystemRole === !0 && D(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && k(e.key)), r = { reporting_manager: l.ReportingManagerLabel };
142
142
  t && (r[t.id] = l.AdminLabel), n && (r[n.id] = l.CfoLabel);
143
143
  for (let t of e) r[t.id] || (r[t.id] = t.name);
144
144
  return r;
145
- }, [h]), { rules: P, isLoading: R, saveStatus: z, createRule: B, updateRule: V, deleteRule: H } = _(N), [U, W] = x(!1), [G, K] = x(T), [q, J] = x(null), [Y, X] = x(null);
146
- y(() => {
147
- z === "success" && e.success(g.Saved), z === "error" && e.error(g.FailedToSave);
148
- }, [z]);
149
- let Z = R || p && !d, ne = te(P), re = M(P), Q = Z || D || z === "saving", $ = U ? F(G, P) : {}, ie = Y && q ? F(Y, P, q) : {}, ae = () => {
150
- W(!0), K(T);
151
- }, oe = () => {
145
+ }, [h]), { rules: I, isLoading: B, saveStatus: V, createRule: ee, updateRule: te, deleteRule: H } = v(F), [U, W] = S(!1), [G, K] = S(E), [q, J] = S(null), [Y, X] = S(null);
146
+ b(() => {
147
+ V === "success" && e.success(g.Saved), V === "error" && e.error(g.FailedToSave);
148
+ }, [V]);
149
+ let Z = B || p && !d, ne = N(I), re = P(I), Q = Z || O || V === "saving", ie = U ? L(G, I) : {}, ae = Y && q ? L(Y, I, q) : {}, oe = () => {
150
+ W(!0), K(E);
151
+ }, se = () => {
152
152
  W(!1);
153
- }, se = async () => {
154
- let e = F(G, P);
153
+ }, $ = async () => {
154
+ let e = L(G, I);
155
155
  if (Object.keys(e).length > 0) return;
156
156
  let t = crypto.randomUUID();
157
- await B(I(t, G)) && (W(!1), K(T));
157
+ await ee(R(t, G)) && (W(!1), K(E));
158
158
  }, ce = (e) => {
159
159
  K(e);
160
160
  }, le = (e) => {
161
- let t = P.find((t) => t.id === e);
162
- t && (W(!1), K(T), J(e), X(L(t)));
161
+ let t = I.find((t) => t.id === e);
162
+ t && (W(!1), K(E), J(e), X(z(t)));
163
163
  }, ue = () => {
164
164
  J(null), X(null);
165
165
  }, de = async () => {
166
166
  if (!q || !Y) return;
167
- let e = F(Y, P, q);
168
- Object.keys(e).length > 0 || await V(q, I(q, Y)) && (J(null), X(null));
167
+ let e = L(Y, I, q);
168
+ Object.keys(e).length > 0 || await te(q, R(q, Y)) && (J(null), X(null));
169
169
  }, fe = (e) => {
170
170
  X(e);
171
171
  }, pe = async (e) => {
172
172
  await H(e), q === e && (J(null), X(null));
173
173
  };
174
- return d !== void 0 && !m ? /* @__PURE__ */ C(i, {
174
+ return d !== void 0 && !m ? /* @__PURE__ */ w(i, {
175
175
  title: u.MissingRolePermissionTitle,
176
176
  description: u.MissingRolePermissionDescription
177
- }) : A ? /* @__PURE__ */ C(i, {
177
+ }) : j ? /* @__PURE__ */ w(i, {
178
178
  title: u.RolesUnavailableTitle,
179
179
  description: u.RolesUnavailableDescription
180
- }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(r, {}), /* @__PURE__ */ C(ee, {
181
- rules: P,
180
+ }) : /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(r, {}), /* @__PURE__ */ w(_, {
181
+ rules: I,
182
182
  isBusy: Q,
183
183
  isLoading: Z,
184
184
  isAddingRule: U,
185
185
  newRuleFormValues: G,
186
- newRuleValidationErrors: $,
186
+ newRuleValidationErrors: ie,
187
187
  editingRuleId: q,
188
188
  editingRuleFormValues: Y,
189
- editingRuleValidationErrors: ie,
190
- approverOptions: Q ? [] : j,
189
+ editingRuleValidationErrors: ae,
190
+ approverOptions: Q ? [] : M,
191
191
  allExpensesAreCovered: ne,
192
192
  gapIntervals: re,
193
- onAddRuleClick: ae,
194
- onCancelAddRule: oe,
195
- onSaveNewRule: () => void se(),
193
+ onAddRuleClick: oe,
194
+ onCancelAddRule: se,
195
+ onSaveNewRule: () => void $(),
196
196
  onNewRuleFormChange: ce,
197
197
  onEditRule: le,
198
198
  onCancelEditRule: ue,
@@ -200,33 +200,24 @@ function R() {
200
200
  onEditRuleFormChange: fe,
201
201
  onDeleteRule: (e) => void pe(e),
202
202
  testIds: {
203
- ruleCard: { root: v.ruleCard },
203
+ ruleCard: { root: y.ruleCard },
204
204
  ruleForm: {
205
- root: v.ruleForm,
206
- saveButton: v.ruleFormSaveButton,
207
- minAmountInput: v.ruleFormMinAmountInput,
208
- maxAmountInput: v.ruleFormMaxAmountInput
205
+ root: y.ruleForm,
206
+ saveButton: y.ruleFormSaveButton,
207
+ minAmountInput: y.ruleFormMinAmountInput,
208
+ maxAmountInput: y.ruleFormMaxAmountInput
209
209
  }
210
210
  }
211
211
  })] });
212
212
  }
213
- function z({ token: e, orgId: t, widgetToken: n, organizationId: r, baseUrl: i, configClient: a, gatewayRouting: s, linkComponent: c, implementation: l, uiFramework: u, errorFallback: d, onError: f, disclosuresAcceptance: m, providerLabels: h } = {}) {
214
- return /* @__PURE__ */ C(o, {
213
+ function V({ token: e, orgId: t, widgetToken: n, organizationId: r, ...i } = {}) {
214
+ return /* @__PURE__ */ w(o, {
215
+ ...i,
215
216
  widgetName: p,
216
- baseUrl: i,
217
- widgetToken: n ?? e,
218
- organizationId: r ?? t,
219
- configClient: a,
220
- gatewayRouting: s,
221
- linkComponent: c,
222
- implementation: l,
223
- uiFramework: u,
224
- errorFallback: d,
225
- onError: f,
226
- disclosuresAcceptance: m,
227
- providerLabels: h,
228
- children: /* @__PURE__ */ C(R, {})
217
+ widgetToken: n === void 0 ? e : n,
218
+ organizationId: r === void 0 ? t : r,
219
+ children: /* @__PURE__ */ w(B, {})
229
220
  });
230
221
  }
231
222
  //#endregion
232
- export { z as ExpenseApprovalPoliciesWidget, z as default, k as buildApproverOptions, E as isEmbeddedSystemRoleKey, D as roleKeyHasSegment };
223
+ export { V as ExpenseApprovalPoliciesWidget, V as default, A as buildApproverOptions, D as isEmbeddedSystemRoleKey, O as roleKeyHasSegment };
@@ -63,21 +63,12 @@ function x() {
63
63
  })]
64
64
  })] });
65
65
  }
66
- function S({ token: e, orgId: t, widgetToken: n, organizationId: r, baseUrl: a, configClient: o, gatewayRouting: s, linkComponent: c, implementation: u, uiFramework: d, errorFallback: f, onError: p, disclosuresAcceptance: m, providerLabels: g } = {}) {
66
+ function S({ token: e, orgId: t, widgetToken: n, organizationId: r, ...a } = {}) {
67
67
  return /* @__PURE__ */ h(i, {
68
+ ...a,
68
69
  widgetName: l,
69
- baseUrl: a,
70
- widgetToken: n ?? e,
71
- organizationId: r ?? t,
72
- configClient: o,
73
- gatewayRouting: s,
74
- linkComponent: c,
75
- implementation: u,
76
- uiFramework: d,
77
- errorFallback: f,
78
- onError: p,
79
- disclosuresAcceptance: m,
80
- providerLabels: g,
70
+ widgetToken: n === void 0 ? e : n,
71
+ organizationId: r === void 0 ? t : r,
81
72
  children: /* @__PURE__ */ h(x, {})
82
73
  });
83
74
  }
@@ -19,7 +19,7 @@ function c(n) {
19
19
  i(r.Mounted);
20
20
  }, [i]), /* @__PURE__ */ o(t, { ...n });
21
21
  }
22
- function l({ baseUrl: e, widgetToken: t, organizationId: r, configClient: a, gatewayRouting: l, linkComponent: u, errorFallback: d, onError: f, finopsThemeColors: p, analytics: m, disclosuresAcceptance: h, providerLabels: g, pageTitleComponent: _ = s, uiFramework: v, ...y }) {
22
+ function l({ baseUrl: e, widgetToken: t, organizationId: r, configClient: a, gatewayRouting: l, linkComponent: u, errorFallback: d, onError: f, finopsThemeColors: p, analytics: m, disclosuresAcceptance: h, providerLabels: g, pageTitleComponent: _ = s, uiFramework: v, implementation: y, ...b }) {
23
23
  return /* @__PURE__ */ o(n, {
24
24
  widgetName: i,
25
25
  baseUrl: e,
@@ -35,8 +35,9 @@ function l({ baseUrl: e, widgetToken: t, organizationId: r, configClient: a, gat
35
35
  disclosuresAcceptance: h,
36
36
  providerLabels: g,
37
37
  uiFramework: v,
38
+ implementation: y,
38
39
  children: /* @__PURE__ */ o(c, {
39
- ...y,
40
+ ...b,
40
41
  pageTitleComponent: _
41
42
  })
42
43
  });
@@ -1,5 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.5.84", n = "7cfd4f4027097f08bd71300e75898565395239f2", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.5.85", n = "68fc96a752f86bf0bf9db00b4c901ab85e52d0de", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.5.84",
3
+ "version": "0.5.85",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {