@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.
- package/dist/index.d.ts +22 -1
- package/dist/index.js +10 -10
- package/dist/lib/AcceptDisclosuresWidget.d.ts +11 -1
- package/dist/lib/AcceptDisclosuresWidget.js +1 -1
- package/dist/lib/BalancesWidget.js +1 -1
- package/dist/lib/BankAccountOnboardingWidget.d.ts +21 -21
- package/dist/lib/BankAccountOnboardingWidget.js +1 -1
- package/dist/lib/CardsWidget.js +1 -1
- package/dist/lib/ExpenseApprovalPoliciesWidget.js +1 -1
- package/dist/lib/ExpenseManagementWidget.js +1 -1
- package/dist/lib/InsightsWidget.js +1 -1
- package/dist/lib/ReceiptMatchWidget.js +1 -1
- package/dist/lib/TransfersWidget.js +1 -1
- package/dist/lib/UploadReceiptWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index4.js +10 -140
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index5.js +152 -0
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/ui/dist/lib/AcceptDisclosuresWidget/AcceptDisclosuresWidget.js +19 -19
- package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index4.js +10 -11
- package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index5.js +15 -64
- package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index6.js +75 -0
- package/dist/libs/tesouro-embedded-components-react/balances-widget/ui/dist/lib/BalancesWidget/BalancesWidget.js +16 -16
- package/dist/libs/tesouro-embedded-components-react/balances-widget/ui/dist/lib/BalancesWidget/SingleBalance/SingleBalance.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index10.js +109 -169
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index11.js +170 -63
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index12.js +73 -81
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index13.js +77 -101
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index14.js +110 -83
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index15.js +91 -7
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index16.js +7 -28
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index17.js +26 -320
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index18.js +341 -0
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index9.js +29 -100
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index11.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index15.js +32 -32
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index16.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index18.js +14 -10
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index19.js +42 -42
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index2.js +80 -77
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index20.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index22.js +14 -10
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index23.js +16 -16
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index27.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index3.js +7 -6
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index5.js +23 -18
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +28 -28
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/index.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/CardDetailsHeader.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index3.js +4 -23
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index4.js +23 -24
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index5.js +24 -30
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index6.js +28 -55
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index7.js +54 -209
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index8.js +206 -81
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +95 -0
- package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardFaceSwatch.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsList.js +31 -30
- package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsListRow.js +11 -10
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index10.js +1 -255
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index11.js +253 -2
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index12.js +2 -71
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index13.js +73 -0
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index5.js +7 -218
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index6.js +219 -79
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index7.js +89 -2
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index8.js +2 -47
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index9.js +49 -1
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ApprovalRuleCard.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ApprovalRuleForm.js +32 -32
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ExpenseApprovalsPage.js +11 -8
- package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index10.js +12 -14
- package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index11.js +21 -62
- package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index12.js +73 -0
- package/dist/libs/tesouro-embedded-components-react/insights-widget/ui/dist/lib/InsightsWidget/InsightsWidget.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/insights-widget/ui/dist/lib/InsightsWidget/SingleInsight/SingleInsight.js +10 -10
- package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/ApprovalPoliciesSettings.js +67 -46
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/testIds.js +26 -0
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApprovalPolicyRules.js +151 -135
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index11.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index14.js +17 -17
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index16.js +17 -15
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index18.js +9 -9
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index20.js +16 -13
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index3.js +13 -13
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index5.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index7.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index9.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShell.js +21 -20
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShellOverlayPortal.js +10 -10
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShellScrollRegion.js +17 -17
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index5.js +18 -99
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index6.js +116 -19
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index7.js +28 -0
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransferMoneyModal/ReviewTransferStep.js +9 -9
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransferMoneyModal/TransferMoneyModal.js +13 -11
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransferMoneyModal/TransferResultStep.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransfersWidget.js +19 -19
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
- package/package.json +1 -1
package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index5.js
CHANGED
|
@@ -1,221 +1,10 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
-
import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
|
|
7
|
-
import { useAllOrganizationRolesQuery as n } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
|
|
8
|
-
import "../../../shared/data-access/dist/index.js";
|
|
9
|
-
import { EmbeddedToaster as r } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
|
|
10
|
-
import { ErrorState as i } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
|
|
11
|
-
import "../../../shared/ui/dist/index.js";
|
|
12
|
-
import { useAnalyticsTrack as a } from "../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
13
|
-
import { WidgetProvider as o } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
14
|
-
import { useWidgetConfig as s } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
15
|
-
import "../../../shared/feature/dist/index.js";
|
|
16
|
-
import { ApproverOptionLabels as c, PermissionErrorLabels as l, ValidationErrorLabels as u } from "./index4.js";
|
|
17
|
-
import { ExpenseApprovalPoliciesAnalyticsEvent as d, WIDGET_NAME as f } from "./index2.js";
|
|
18
|
-
import { AmountConditionType as p, ApprovalOutcomeType as m } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/types.js";
|
|
19
|
-
import { ApprovalRuleToastLabels as h } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/labels.js";
|
|
20
|
-
import { ExpenseApprovalsPage as g } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ExpenseApprovalsPage.js";
|
|
21
|
-
import "../../ui/dist/index.js";
|
|
22
|
-
import { useApprovalPolicies as _ } from "./index3.js";
|
|
23
|
-
import { useEffect as v, useMemo as y, useState as b } from "react";
|
|
24
|
-
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
25
1
|
//#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index5.js
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
var e = {
|
|
3
|
+
ruleCard: "expense-approval-rule-card",
|
|
4
|
+
ruleForm: "expense-approval-rule-form",
|
|
5
|
+
ruleFormSaveButton: "expense-approval-rule-save-button",
|
|
6
|
+
ruleFormMinAmountInput: "expense-approval-rule-min-amount-input",
|
|
7
|
+
ruleFormMaxAmountInput: "expense-approval-rule-max-amount-input"
|
|
31
8
|
};
|
|
32
|
-
function T(e, t) {
|
|
33
|
-
let n = (e ?? "").trim().toLowerCase();
|
|
34
|
-
return n === t || n === `embedded:${t}`;
|
|
35
|
-
}
|
|
36
|
-
function E(e, t) {
|
|
37
|
-
return (e ?? "").toLowerCase().split(":").map((e) => e.trim()).filter(Boolean).some((e) => e === t);
|
|
38
|
-
}
|
|
39
|
-
function D(e) {
|
|
40
|
-
return T(e, "cfo") || T(e, "finance_admin") || T(e, "finance-admin");
|
|
41
|
-
}
|
|
42
|
-
function O(e) {
|
|
43
|
-
let t = e.find((e) => e.isSystemRole === !0 && T(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && D(e.key)), r = e.filter((e) => e.isSystemRole === !0 && e !== t && e !== n && !E(e.key, "employee") && !E(e.key, "bookkeeper")).map((e) => ({
|
|
44
|
-
id: e.id,
|
|
45
|
-
label: e.name
|
|
46
|
-
})), i = e.filter((e) => !e.isSystemRole && e.status?.toLowerCase() === "active").map((e) => ({
|
|
47
|
-
id: e.id,
|
|
48
|
-
label: e.name
|
|
49
|
-
}));
|
|
50
|
-
return [
|
|
51
|
-
...t ? [{
|
|
52
|
-
id: t.id,
|
|
53
|
-
label: c.AdminLabel,
|
|
54
|
-
sublabel: c.AdminSublabel
|
|
55
|
-
}] : [],
|
|
56
|
-
{
|
|
57
|
-
id: "reporting_manager",
|
|
58
|
-
label: c.ReportingManagerLabel,
|
|
59
|
-
sublabel: c.ReportingManagerSublabel
|
|
60
|
-
},
|
|
61
|
-
...n ? [{
|
|
62
|
-
id: n.id,
|
|
63
|
-
label: c.CfoLabel,
|
|
64
|
-
sublabel: c.CfoSublabel
|
|
65
|
-
}] : [],
|
|
66
|
-
...r,
|
|
67
|
-
...i
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
|
-
function k(e) {
|
|
71
|
-
let t = e.minAmount.trim() !== "", n = e.maxAmount.trim() !== "";
|
|
72
|
-
return t && n ? p.InRange : t ? p.GreaterThanOrEqual : n ? p.LessThan : p.All;
|
|
73
|
-
}
|
|
74
|
-
function A(e) {
|
|
75
|
-
return [e.conditionType === p.LessThan || e.conditionType === p.All ? 0 : e.minAmount ?? 0, e.conditionType === p.GreaterThanOrEqual || e.conditionType === p.All ? Infinity : e.maxAmount ?? 0];
|
|
76
|
-
}
|
|
77
|
-
function j(e) {
|
|
78
|
-
if (e.length === 0) return !1;
|
|
79
|
-
let t = e.map(A).sort((e, t) => e[0] - t[0]);
|
|
80
|
-
if (t[0][0] > 0) return !1;
|
|
81
|
-
let n = 0;
|
|
82
|
-
for (let [e, r] of t) {
|
|
83
|
-
if (e > n) return !1;
|
|
84
|
-
n = Math.max(n, r);
|
|
85
|
-
}
|
|
86
|
-
return n === Infinity;
|
|
87
|
-
}
|
|
88
|
-
function M(e) {
|
|
89
|
-
if (e.length === 0) return [];
|
|
90
|
-
let t = e.map(A).sort((e, t) => e[0] - t[0]), n = [], r = 0;
|
|
91
|
-
for (let [e, i] of t) e > r && n.push({
|
|
92
|
-
from: r,
|
|
93
|
-
to: e
|
|
94
|
-
}), r = Math.max(r, i);
|
|
95
|
-
return r !== Infinity && n.push({
|
|
96
|
-
from: r,
|
|
97
|
-
to: null
|
|
98
|
-
}), n;
|
|
99
|
-
}
|
|
100
|
-
function N(e) {
|
|
101
|
-
let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = k(e);
|
|
102
|
-
return [r === p.LessThan || r === p.All ? 0 : t, r === p.GreaterThanOrEqual || r === p.All ? Infinity : n];
|
|
103
|
-
}
|
|
104
|
-
function P(e, t, n) {
|
|
105
|
-
let [r, i] = N(e);
|
|
106
|
-
return t.filter((e) => e.id !== n).some((e) => {
|
|
107
|
-
let [t, n] = A(e);
|
|
108
|
-
return r < n && t < i;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
function F(e, t, n) {
|
|
112
|
-
let r = {}, i = e.minAmount.trim() !== "", a = e.maxAmount.trim() !== "", o = Number(e.minAmount.trim()), s = Number(e.maxAmount.trim());
|
|
113
|
-
return i && (!Number.isFinite(o) || o < 0) && (r.minAmount = u.InvalidMinAmount), a && (!Number.isFinite(s) || s <= 0) && (r.maxAmount = u.InvalidMaxAmount), i && a && !r.minAmount && !r.maxAmount && o >= s && (r.maxAmount = u.MaxLessThanOrEqualToMin), e.outcome === m.RequireApproval && e.approvers.length === 0 && (r.approvers = u.ApproversRequired), !r.minAmount && !r.maxAmount && P(e, t, n) && (a ? r.maxAmount = u.ConflictsWithAnotherRule : r.minAmount = u.ConflictsWithAnotherRule), r;
|
|
114
|
-
}
|
|
115
|
-
function I(e, t) {
|
|
116
|
-
let n = k(t);
|
|
117
|
-
return {
|
|
118
|
-
id: e,
|
|
119
|
-
conditionType: n,
|
|
120
|
-
minAmount: n === p.InRange || n === p.GreaterThanOrEqual ? Number(t.minAmount) : void 0,
|
|
121
|
-
maxAmount: n === p.LessThan || n === p.InRange ? Number(t.maxAmount) : void 0,
|
|
122
|
-
outcome: t.outcome,
|
|
123
|
-
approvers: t.outcome === m.RequireApproval ? t.approvers : []
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function L(e) {
|
|
127
|
-
return {
|
|
128
|
-
minAmount: e.minAmount == null ? "" : String(e.minAmount),
|
|
129
|
-
maxAmount: e.maxAmount == null ? "" : String(e.maxAmount),
|
|
130
|
-
outcome: e.outcome,
|
|
131
|
-
approvers: e.approvers
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
function R() {
|
|
135
|
-
let o = a();
|
|
136
|
-
v(() => {
|
|
137
|
-
o(d.Mounted);
|
|
138
|
-
}, [o]);
|
|
139
|
-
let { initResponse: u } = s(), f = u?.scopes?.includes(t.RoleReadOrg) ?? !1, { data: p, isResolving: m, isError: E } = n({ enabled: f }), k = y(() => O(p?.data ?? []), [p]), A = y(() => {
|
|
140
|
-
let e = p?.data ?? [], t = e.find((e) => e.isSystemRole === !0 && T(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && D(e.key)), r = { reporting_manager: c.ReportingManagerLabel };
|
|
141
|
-
t && (r[t.id] = c.AdminLabel), n && (r[n.id] = c.CfoLabel);
|
|
142
|
-
for (let t of e) r[t.id] || (r[t.id] = t.name);
|
|
143
|
-
return r;
|
|
144
|
-
}, [p]), { rules: N, isLoading: P, saveStatus: R, createRule: z, updateRule: B, deleteRule: V } = _(A), [H, U] = b(!1), [W, G] = b(w), [K, q] = b(null), [J, Y] = b(null);
|
|
145
|
-
v(() => {
|
|
146
|
-
R === "success" && e.success(h.Saved), R === "error" && e.error(h.FailedToSave);
|
|
147
|
-
}, [R]);
|
|
148
|
-
let X = j(N), Z = M(N), Q = P || m || R === "saving", $ = H ? F(W, N) : {}, ee = J && K ? F(J, N, K) : {}, te = () => {
|
|
149
|
-
U(!0), G(w);
|
|
150
|
-
}, ne = () => {
|
|
151
|
-
U(!1);
|
|
152
|
-
}, re = async () => {
|
|
153
|
-
let e = F(W, N);
|
|
154
|
-
if (Object.keys(e).length > 0) return;
|
|
155
|
-
let t = crypto.randomUUID();
|
|
156
|
-
await z(I(t, W)) && (U(!1), G(w));
|
|
157
|
-
}, ie = (e) => {
|
|
158
|
-
G(e);
|
|
159
|
-
}, ae = (e) => {
|
|
160
|
-
let t = N.find((t) => t.id === e);
|
|
161
|
-
t && (U(!1), G(w), q(e), Y(L(t)));
|
|
162
|
-
}, oe = () => {
|
|
163
|
-
q(null), Y(null);
|
|
164
|
-
}, se = async () => {
|
|
165
|
-
if (!K || !J) return;
|
|
166
|
-
let e = F(J, N, K);
|
|
167
|
-
Object.keys(e).length > 0 || await B(K, I(K, J)) && (q(null), Y(null));
|
|
168
|
-
}, ce = (e) => {
|
|
169
|
-
Y(e);
|
|
170
|
-
}, le = async (e) => {
|
|
171
|
-
await V(e), K === e && (q(null), Y(null));
|
|
172
|
-
};
|
|
173
|
-
return u !== void 0 && !f ? /* @__PURE__ */ S(i, {
|
|
174
|
-
title: l.MissingRolePermissionTitle,
|
|
175
|
-
description: l.MissingRolePermissionDescription
|
|
176
|
-
}) : E ? /* @__PURE__ */ S(i, {
|
|
177
|
-
title: l.RolesUnavailableTitle,
|
|
178
|
-
description: l.RolesUnavailableDescription
|
|
179
|
-
}) : /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(r, {}), /* @__PURE__ */ S(g, {
|
|
180
|
-
rules: N,
|
|
181
|
-
isBusy: Q,
|
|
182
|
-
isLoading: P,
|
|
183
|
-
isAddingRule: H,
|
|
184
|
-
newRuleFormValues: W,
|
|
185
|
-
newRuleValidationErrors: $,
|
|
186
|
-
editingRuleId: K,
|
|
187
|
-
editingRuleFormValues: J,
|
|
188
|
-
editingRuleValidationErrors: ee,
|
|
189
|
-
approverOptions: Q ? [] : k,
|
|
190
|
-
allExpensesAreCovered: X,
|
|
191
|
-
gapIntervals: Z,
|
|
192
|
-
onAddRuleClick: te,
|
|
193
|
-
onCancelAddRule: ne,
|
|
194
|
-
onSaveNewRule: () => void re(),
|
|
195
|
-
onNewRuleFormChange: ie,
|
|
196
|
-
onEditRule: ae,
|
|
197
|
-
onCancelEditRule: oe,
|
|
198
|
-
onSaveEditRule: () => void se(),
|
|
199
|
-
onEditRuleFormChange: ce,
|
|
200
|
-
onDeleteRule: (e) => void le(e)
|
|
201
|
-
})] });
|
|
202
|
-
}
|
|
203
|
-
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: p, disclosuresAcceptance: m } = {}) {
|
|
204
|
-
return /* @__PURE__ */ S(o, {
|
|
205
|
-
widgetName: f,
|
|
206
|
-
baseUrl: i,
|
|
207
|
-
widgetToken: n ?? e,
|
|
208
|
-
organizationId: r ?? t,
|
|
209
|
-
configClient: a,
|
|
210
|
-
gatewayRouting: s,
|
|
211
|
-
linkComponent: c,
|
|
212
|
-
implementation: l,
|
|
213
|
-
uiFramework: u,
|
|
214
|
-
errorFallback: d,
|
|
215
|
-
onError: p,
|
|
216
|
-
disclosuresAcceptance: m,
|
|
217
|
-
children: /* @__PURE__ */ S(R, {})
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
9
|
//#endregion
|
|
221
|
-
export {
|
|
10
|
+
export { e as expenseApprovalPoliciesTestIds };
|
package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index6.js
CHANGED
|
@@ -3,89 +3,229 @@
|
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
5
|
import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
|
|
7
|
+
import { useAllOrganizationRolesQuery as n } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
|
|
8
|
+
import "../../../shared/data-access/dist/index.js";
|
|
9
|
+
import { EmbeddedToaster as r } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
|
|
10
|
+
import { ErrorState as i } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
|
|
7
11
|
import "../../../shared/ui/dist/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
12
|
+
import { useAnalyticsTrack as a } from "../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
13
|
+
import { WidgetProvider as o } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
14
|
+
import { useWidgetConfig as s } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
15
|
+
import "../../../shared/feature/dist/index.js";
|
|
16
|
+
import { ApproverOptionLabels as c, PermissionErrorLabels as l, ValidationErrorLabels as u } from "./index4.js";
|
|
17
|
+
import { ExpenseApprovalPoliciesAnalyticsEvent as d, WIDGET_NAME as f } from "./index2.js";
|
|
18
|
+
import { AmountConditionType as p, ApprovalOutcomeType as m } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/types.js";
|
|
19
|
+
import { ApprovalRuleToastLabels as h } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/labels.js";
|
|
20
|
+
import { ExpenseApprovalsPage as g } from "../../ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ExpenseApprovalsPage.js";
|
|
11
21
|
import "../../ui/dist/index.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
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";
|
|
14
26
|
//#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index6.js
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
var T = {
|
|
28
|
+
minAmount: "",
|
|
29
|
+
maxAmount: "",
|
|
30
|
+
outcome: m.AutoApprove,
|
|
31
|
+
approvers: []
|
|
32
|
+
};
|
|
33
|
+
function E(e, t) {
|
|
34
|
+
let n = (e ?? "").trim().toLowerCase();
|
|
35
|
+
return n === t || n === `embedded:${t}`;
|
|
18
36
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
37
|
+
function D(e, t) {
|
|
38
|
+
return (e ?? "").toLowerCase().split(":").map((e) => e.trim()).filter(Boolean).some((e) => e === t);
|
|
39
|
+
}
|
|
40
|
+
function O(e) {
|
|
41
|
+
return E(e, "cfo") || E(e, "finance_admin") || E(e, "finance-admin");
|
|
42
|
+
}
|
|
43
|
+
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) => ({
|
|
45
|
+
id: e.id,
|
|
46
|
+
label: e.name
|
|
47
|
+
})), i = e.filter((e) => !e.isSystemRole && e.status?.toLowerCase() === "active").map((e) => ({
|
|
48
|
+
id: e.id,
|
|
49
|
+
label: e.name
|
|
50
|
+
}));
|
|
51
|
+
return [
|
|
52
|
+
...t ? [{
|
|
53
|
+
id: t.id,
|
|
54
|
+
label: c.AdminLabel,
|
|
55
|
+
sublabel: c.AdminSublabel
|
|
56
|
+
}] : [],
|
|
57
|
+
{
|
|
58
|
+
id: "reporting_manager",
|
|
59
|
+
label: c.ReportingManagerLabel,
|
|
60
|
+
sublabel: c.ReportingManagerSublabel
|
|
61
|
+
},
|
|
62
|
+
...n ? [{
|
|
63
|
+
id: n.id,
|
|
64
|
+
label: c.CfoLabel,
|
|
65
|
+
sublabel: c.CfoSublabel
|
|
66
|
+
}] : [],
|
|
67
|
+
...r,
|
|
68
|
+
...i
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
function A(e) {
|
|
72
|
+
let t = e.minAmount.trim() !== "", n = e.maxAmount.trim() !== "";
|
|
73
|
+
return t && n ? p.InRange : t ? p.GreaterThanOrEqual : n ? p.LessThan : p.All;
|
|
74
|
+
}
|
|
75
|
+
function j(e) {
|
|
76
|
+
return [e.conditionType === p.LessThan || e.conditionType === p.All ? 0 : e.minAmount ?? 0, e.conditionType === p.GreaterThanOrEqual || e.conditionType === p.All ? Infinity : e.maxAmount ?? 0];
|
|
77
|
+
}
|
|
78
|
+
function M(e) {
|
|
79
|
+
if (e.length === 0) return !1;
|
|
80
|
+
let t = e.map(j).sort((e, t) => e[0] - t[0]);
|
|
81
|
+
if (t[0][0] > 0) return !1;
|
|
82
|
+
let n = 0;
|
|
83
|
+
for (let [e, r] of t) {
|
|
84
|
+
if (e > n) return !1;
|
|
85
|
+
n = Math.max(n, r);
|
|
86
|
+
}
|
|
87
|
+
return n === Infinity;
|
|
88
|
+
}
|
|
89
|
+
function N(e) {
|
|
90
|
+
if (e.length === 0) return [];
|
|
91
|
+
let t = e.map(j).sort((e, t) => e[0] - t[0]), n = [], r = 0;
|
|
92
|
+
for (let [e, i] of t) e > r && n.push({
|
|
93
|
+
from: r,
|
|
94
|
+
to: e
|
|
95
|
+
}), r = Math.max(r, i);
|
|
96
|
+
return r !== Infinity && n.push({
|
|
97
|
+
from: r,
|
|
98
|
+
to: null
|
|
99
|
+
}), n;
|
|
100
|
+
}
|
|
101
|
+
function P(e) {
|
|
102
|
+
let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = A(e);
|
|
103
|
+
return [r === p.LessThan || r === p.All ? 0 : t, r === p.GreaterThanOrEqual || r === p.All ? Infinity : n];
|
|
104
|
+
}
|
|
105
|
+
function F(e, t, n) {
|
|
106
|
+
let [r, i] = P(e);
|
|
107
|
+
return t.filter((e) => e.id !== n).some((e) => {
|
|
108
|
+
let [t, n] = j(e);
|
|
109
|
+
return r < n && t < i;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function I(e, t, n) {
|
|
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 = u.InvalidMinAmount), a && (!Number.isFinite(s) || s <= 0) && (r.maxAmount = u.InvalidMaxAmount), i && a && !r.minAmount && !r.maxAmount && o >= s && (r.maxAmount = u.MaxLessThanOrEqualToMin), e.outcome === m.RequireApproval && e.approvers.length === 0 && (r.approvers = u.ApproversRequired), !r.minAmount && !r.maxAmount && F(e, t, n) && (a ? r.maxAmount = u.ConflictsWithAnotherRule : r.minAmount = u.ConflictsWithAnotherRule), r;
|
|
115
|
+
}
|
|
116
|
+
function L(e, t) {
|
|
117
|
+
let n = A(t);
|
|
118
|
+
return {
|
|
119
|
+
id: e,
|
|
120
|
+
conditionType: n,
|
|
121
|
+
minAmount: n === p.InRange || n === p.GreaterThanOrEqual ? Number(t.minAmount) : void 0,
|
|
122
|
+
maxAmount: n === p.LessThan || n === p.InRange ? Number(t.maxAmount) : void 0,
|
|
123
|
+
outcome: t.outcome,
|
|
124
|
+
approvers: t.outcome === m.RequireApproval ? t.approvers : []
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function R(e) {
|
|
128
|
+
return {
|
|
129
|
+
minAmount: e.minAmount == null ? "" : String(e.minAmount),
|
|
130
|
+
maxAmount: e.maxAmount == null ? "" : String(e.maxAmount),
|
|
131
|
+
outcome: e.outcome,
|
|
132
|
+
approvers: e.approvers
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function z() {
|
|
136
|
+
let o = a();
|
|
137
|
+
y(() => {
|
|
138
|
+
o(d.Mounted);
|
|
139
|
+
}, [o]);
|
|
140
|
+
let { initResponse: u } = s(), f = u?.scopes?.includes(t.RoleReadOrg) ?? !1, { data: p, isResolving: m, isError: D } = n({ enabled: f }), A = b(() => k(p?.data ?? []), [p]), j = b(() => {
|
|
141
|
+
let e = p?.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: c.ReportingManagerLabel };
|
|
142
|
+
t && (r[t.id] = c.AdminLabel), n && (r[n.id] = c.CfoLabel);
|
|
143
|
+
for (let t of e) r[t.id] || (r[t.id] = t.name);
|
|
144
|
+
return r;
|
|
145
|
+
}, [p]), { rules: P, isLoading: F, saveStatus: z, createRule: B, updateRule: V, deleteRule: H } = _(j), [U, W] = x(!1), [G, K] = x(T), [q, J] = x(null), [Y, X] = x(null);
|
|
146
|
+
y(() => {
|
|
147
|
+
z === "success" && e.success(h.Saved), z === "error" && e.error(h.FailedToSave);
|
|
148
|
+
}, [z]);
|
|
149
|
+
let Z = M(P), Q = N(P), $ = F || m || z === "saving", ee = U ? I(G, P) : {}, te = Y && q ? I(Y, P, q) : {}, ne = () => {
|
|
150
|
+
W(!0), K(T);
|
|
151
|
+
}, re = () => {
|
|
152
|
+
W(!1);
|
|
153
|
+
}, ie = async () => {
|
|
154
|
+
let e = I(G, P);
|
|
155
|
+
if (Object.keys(e).length > 0) return;
|
|
156
|
+
let t = crypto.randomUUID();
|
|
157
|
+
await B(L(t, G)) && (W(!1), K(T));
|
|
158
|
+
}, ae = (e) => {
|
|
159
|
+
K(e);
|
|
160
|
+
}, oe = (e) => {
|
|
161
|
+
let t = P.find((t) => t.id === e);
|
|
162
|
+
t && (W(!1), K(T), J(e), X(R(t)));
|
|
163
|
+
}, se = () => {
|
|
164
|
+
J(null), X(null);
|
|
165
|
+
}, ce = async () => {
|
|
166
|
+
if (!q || !Y) return;
|
|
167
|
+
let e = I(Y, P, q);
|
|
168
|
+
Object.keys(e).length > 0 || await V(q, L(q, Y)) && (J(null), X(null));
|
|
169
|
+
}, le = (e) => {
|
|
170
|
+
X(e);
|
|
171
|
+
}, ue = async (e) => {
|
|
172
|
+
await H(e), q === e && (J(null), X(null));
|
|
173
|
+
};
|
|
174
|
+
return u !== void 0 && !f ? /* @__PURE__ */ C(i, {
|
|
175
|
+
title: l.MissingRolePermissionTitle,
|
|
176
|
+
description: l.MissingRolePermissionDescription
|
|
177
|
+
}) : D ? /* @__PURE__ */ C(i, {
|
|
178
|
+
title: l.RolesUnavailableTitle,
|
|
179
|
+
description: l.RolesUnavailableDescription
|
|
180
|
+
}) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(r, {}), /* @__PURE__ */ C(g, {
|
|
181
|
+
rules: P,
|
|
182
|
+
isBusy: $,
|
|
183
|
+
isLoading: F,
|
|
184
|
+
isAddingRule: U,
|
|
185
|
+
newRuleFormValues: G,
|
|
186
|
+
newRuleValidationErrors: ee,
|
|
187
|
+
editingRuleId: q,
|
|
188
|
+
editingRuleFormValues: Y,
|
|
189
|
+
editingRuleValidationErrors: te,
|
|
190
|
+
approverOptions: $ ? [] : A,
|
|
191
|
+
allExpensesAreCovered: Z,
|
|
192
|
+
gapIntervals: Q,
|
|
193
|
+
onAddRuleClick: ne,
|
|
194
|
+
onCancelAddRule: re,
|
|
195
|
+
onSaveNewRule: () => void ie(),
|
|
196
|
+
onNewRuleFormChange: ae,
|
|
197
|
+
onEditRule: oe,
|
|
198
|
+
onCancelEditRule: se,
|
|
199
|
+
onSaveEditRule: () => void ce(),
|
|
200
|
+
onEditRuleFormChange: le,
|
|
201
|
+
onDeleteRule: (e) => void ue(e),
|
|
202
|
+
testIds: {
|
|
203
|
+
ruleCard: { root: v.ruleCard },
|
|
204
|
+
ruleForm: {
|
|
205
|
+
root: v.ruleForm,
|
|
206
|
+
saveButton: v.ruleFormSaveButton,
|
|
207
|
+
minAmountInput: v.ruleFormMinAmountInput,
|
|
208
|
+
maxAmountInput: v.ruleFormMaxAmountInput
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
})] });
|
|
212
|
+
}
|
|
213
|
+
function B({ token: e, orgId: t, widgetToken: n, organizationId: r, baseUrl: i, configClient: a, gatewayRouting: s, linkComponent: c, implementation: l, uiFramework: u, errorFallback: d, onError: p, disclosuresAcceptance: m } = {}) {
|
|
214
|
+
return /* @__PURE__ */ C(o, {
|
|
215
|
+
widgetName: f,
|
|
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: p,
|
|
226
|
+
disclosuresAcceptance: m,
|
|
227
|
+
children: /* @__PURE__ */ C(z, {})
|
|
88
228
|
});
|
|
89
229
|
}
|
|
90
230
|
//#endregion
|
|
91
|
-
export {
|
|
231
|
+
export { B as ExpenseApprovalPoliciesWidget, B as default, k as buildApproverOptions, E as isEmbeddedSystemRoleKey, D as roleKeyHasSegment };
|
package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index7.js
CHANGED
|
@@ -1,4 +1,91 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import { EmbeddedToaster as t } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
|
|
7
|
+
import "../../../shared/ui/dist/index.js";
|
|
8
|
+
import { UploadReceiptToastLabels as n } from "../../ui/dist/lib/UploadReceiptWidget/labels.js";
|
|
9
|
+
import { UploadReceiptButton as r } from "../../ui/dist/lib/UploadReceiptWidget/UploadReceiptButton.js";
|
|
10
|
+
import { UploadReceiptModal as i } from "../../ui/dist/lib/UploadReceiptWidget/UploadReceiptModal.js";
|
|
11
|
+
import "../../ui/dist/index.js";
|
|
12
|
+
import { useEffect as a, useRef as o, useState as s } from "react";
|
|
13
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
1
14
|
//#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index7.js
|
|
2
|
-
var
|
|
15
|
+
var u = 3e3, d = 5e3, f = 10;
|
|
16
|
+
function p(e, t) {
|
|
17
|
+
return e ? e.stillProcessing > 0 ? n.MatchingUnfinished(e.stillProcessing) : e.total === 0 ? n.UploadedAll(t) : e.matched === e.total ? n.MatchedAll(e.matched) : n.MatchedPartial(e.matched, e.total) : n.UploadedAll(t);
|
|
18
|
+
}
|
|
19
|
+
function m({ emailAddress: m, onFileUpload: h, onAwaitMatching: g, isUploading: _ = !1 }) {
|
|
20
|
+
let [v, y] = s(!1), [b, x] = s(!1), S = o(!0);
|
|
21
|
+
return a(() => (S.current = !0, () => {
|
|
22
|
+
S.current = !1;
|
|
23
|
+
}), []), /* @__PURE__ */ l("div", {
|
|
24
|
+
className: "ttw:relative",
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ c(t, {}),
|
|
27
|
+
/* @__PURE__ */ c(r, {
|
|
28
|
+
onClick: () => y((e) => !e),
|
|
29
|
+
open: v
|
|
30
|
+
}),
|
|
31
|
+
/* @__PURE__ */ c(i, {
|
|
32
|
+
open: v,
|
|
33
|
+
onClose: () => y(!1),
|
|
34
|
+
emailAddress: m,
|
|
35
|
+
onFilesSelected: async (t) => {
|
|
36
|
+
if (!h || _ || b || t.length === 0) return;
|
|
37
|
+
if (t.length > f) {
|
|
38
|
+
e.error(n.TooManyFiles(f), { duration: d });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
x(!0), y(!1);
|
|
42
|
+
let r = e.loading(n.Uploading(t.length)), i = 0, a = 0;
|
|
43
|
+
for (let e of t) try {
|
|
44
|
+
await h(e), i++;
|
|
45
|
+
} catch {
|
|
46
|
+
a++;
|
|
47
|
+
}
|
|
48
|
+
let o;
|
|
49
|
+
try {
|
|
50
|
+
o = g?.(i);
|
|
51
|
+
} catch {
|
|
52
|
+
o = void 0;
|
|
53
|
+
}
|
|
54
|
+
if (a > 0 || i === 0) {
|
|
55
|
+
if (o?.catch(() => void 0), !S.current) {
|
|
56
|
+
e.dismiss(r);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
e.error(i === 0 ? t.length === 1 ? n.UploadFailedSingle : n.UploadFailedAll(a) : n.UploadedPartial(i, t.length), {
|
|
60
|
+
id: r,
|
|
61
|
+
duration: d
|
|
62
|
+
}), x(!1);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (x(!1), !S.current) {
|
|
66
|
+
o?.catch(() => void 0), e.dismiss(r);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let s = null;
|
|
70
|
+
if (o) {
|
|
71
|
+
e.loading(n.Matching(i), { id: r });
|
|
72
|
+
try {
|
|
73
|
+
s = await o;
|
|
74
|
+
} catch {}
|
|
75
|
+
}
|
|
76
|
+
if (!S.current) {
|
|
77
|
+
e.dismiss(r);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
e.success(p(s, i), {
|
|
81
|
+
id: r,
|
|
82
|
+
duration: u
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
isUploading: _ || b
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
3
90
|
//#endregion
|
|
4
|
-
export {
|
|
91
|
+
export { m as UploadReceiptWidget };
|