@tesouro/embedded-components-react 0.11.141 → 0.11.167
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/NOTICE +24 -0
- package/README.md +15 -37
- package/dist/experimental/BalanceHistoryWidget.d.ts +0 -11
- package/dist/experimental/QuickViewWidget.d.ts +0 -11
- package/dist/experimental/RemoteCheckCapture.d.ts +0 -11
- package/dist/experimental/index.d.ts +0 -11
- package/dist/fixtures/index.d.ts +27 -1
- package/dist/index.css +6976 -6246
- package/dist/index.d.ts +64 -173
- package/dist/index.js +9 -10
- package/dist/lib/AcceptDisclosuresWidget.d.ts +0 -11
- package/dist/lib/BalancesWidget.d.ts +0 -11
- package/dist/lib/BankAccountOnboardingWidget.d.ts +0 -11
- package/dist/lib/BankAccountsWidget.d.ts +2 -11
- package/dist/lib/BankingComplianceBannerWidget.d.ts +0 -11
- package/dist/lib/BillPayWidget.d.ts +0 -11
- package/dist/lib/CardDetailsWidget.d.ts +0 -11
- package/dist/lib/CounterpartsWidget.d.ts +1 -12
- package/dist/lib/CounterpartsWidgetPublic.d.ts +1 -12
- package/dist/lib/CreditCardsWidget.d.ts +0 -11
- package/dist/lib/DebitCardsWidget.d.ts +0 -11
- package/dist/lib/ExpenseManagementWidget.d.ts +1 -12
- package/dist/lib/InsightsWidget.d.ts +0 -11
- package/dist/lib/LinkedAccountsWidget.d.ts +0 -11
- package/dist/lib/OfferWidget.d.ts +0 -11
- package/dist/lib/ReceivablesWidget.d.ts +60 -17
- package/dist/lib/ReceivablesWidget.js +3 -2
- package/dist/lib/SettingsWidget.d.ts +0 -11
- package/dist/lib/TransfersWidget.d.ts +0 -11
- package/dist/lib/WidgetProvider.d.ts +0 -11
- package/dist/lib/WidgetProviderPublic.d.ts +0 -11
- package/dist/lib/WidgetSuite.d.ts +60 -15
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/lib/AcceptDisclosuresWidget/AcceptDisclosuresWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/lib/BankAccountOnboardingWidget/BankAccountOnboardingWidget.js +20 -19
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index10.js +8 -8
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index4.js +2 -3
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/ui/dist/index10.js +83 -82
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/ui/dist/index4.js +84 -79
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/ui/dist/index9.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/lib/formatters.js +2 -3
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/lib/useBankAccountsWidget.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/lib/AccountCard.js +51 -46
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/lib/labels.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/feature/dist/index4.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index16.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index17.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/feature/dist/index10.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/feature/dist/index4.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/lib/useActivateCard.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/lib/useCardLock.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/lib/useEditCardNickname.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/feature/dist/index8.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsActions.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index7.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/ExpenseManagementWidget/ExpenseManagementWidget.js +10 -9
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/lib/TransactionDetails/TransactionDetailsFeature.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/feature/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index16.js +66 -74
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +3 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +351 -318
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +126 -133
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +63 -56
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/invoicesFilter.js +78 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/invoicesFilterLabels.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +14 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/recurrence.js +138 -129
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/recurringSeries.js +119 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/statusCards.js +37 -28
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/tabs.js +1 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useInvoicesFilter.js +131 -81
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useLocalDayStart.js +15 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +46 -46
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js +13 -13
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableBankAccount.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +440 -438
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentTerms.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableRecurrence.js +62 -56
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +47 -16
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +78 -86
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +180 -158
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useRecurringSeriesTable.js +132 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/invoicing.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/receivables.js +153 -137
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +22 -19
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +6 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index60.js +137 -129
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index61.js +21 -46
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index62.js +143 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index63.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index64.js +47 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +25 -25
- package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/lib/useLinkedAccountsWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/useProductDelete.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/mocks/products.js +3 -11
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/scenarios.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/data-access/dist/index2.js +36 -77
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/summarizeCardSpend.js +11 -13
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/useCardSpendSummary.js +20 -17
- package/dist/libs/tesouro-embedded-components-react/remote-check-capture/feature/dist/lib/RemoteCheckCaptureWidget/useRemoteCheckCaptureWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/chart-of-accounts/feature/dist/index7.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/mocks/settings.js +7 -0
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index7.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index8.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index8.js +4 -9
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index12.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index16.js +2 -3
- package/dist/libs/tesouro-embedded-components-react/settings-widget/ui/dist/lib/SettingsWidgetUi/SettingsWidgetUi.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApprovalPolicyRules.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index3.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/subEntityForms.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useDeleteController.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +43 -43
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +233 -211
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +66 -42
- package/dist/libs/tesouro-embedded-components-react/shared/document-status/util/dist/lib/receivableFilledTone.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/expense-requirements/feature/dist/lib/ExpenseRequirementsWidget.js +5 -4
- 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/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/toasts.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/index.js +28 -28
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/EmbeddedToaster.js +33 -32
- package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/lib/TransfersWidget/useTransferMoneyModalController.js +9 -8
- package/dist/node_modules/sonner/dist/index.js +620 -0
- package/dist/packages/shared-ui-shadcn/dist/index.js +6072 -6062
- package/dist/scenarios/index.d.ts +1 -3
- package/dist/scenarios/index.js +17 -20
- package/package.json +17 -4
- package/dist/lib/CustomersWidget.d.ts +0 -993
- package/dist/lib/CustomersWidget.js +0 -2
- package/dist/lib/ProductsWidget.d.ts +0 -893
- package/dist/lib/ProductsWidget.js +0 -2
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/index.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/lib/CustomersWidget/CustomersWidget.js +0 -41
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/lib/analytics/events.js +0 -3
- package/dist/libs/tesouro-embedded-components-react/customers-widget/feature/dist/scenarios.js +0 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useUtcDayStart.js +0 -15
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
5
|
+
import { toast as e } from "../../../../../../../node_modules/sonner/dist/index.js";
|
|
6
|
+
import { formatLabel as t } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
7
|
import { coerceAmountValueToMinorUnits as n } from "../../../../../shared/util/dist/lib/coerceAmountValueToMinorUnits.js";
|
|
7
8
|
import { amountOutputToMajorUnits as r, minorExponentForCurrency as i } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
8
9
|
import { currencySymbolForCode as a, formatMoneyExact as o } from "../../../../../shared/util/dist/lib/formatMoneyExact.js";
|
|
@@ -157,13 +158,13 @@ function b({ labels: r, featureLabels: m, embeddedBankAccounts: h, verifiedExter
|
|
|
157
158
|
]), ye = u(() => {
|
|
158
159
|
j("accounts");
|
|
159
160
|
}, []), be = u(async () => {
|
|
160
|
-
let
|
|
161
|
-
if (
|
|
161
|
+
let t = s(I, X);
|
|
162
|
+
if (t === null) {
|
|
162
163
|
H(r.modalAmountInvalidError);
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
165
166
|
if (!J && !Y) {
|
|
166
|
-
|
|
167
|
+
e.error(r.modalUnsupportedPairError);
|
|
167
168
|
return;
|
|
168
169
|
}
|
|
169
170
|
let n;
|
|
@@ -172,18 +173,18 @@ function b({ labels: r, featureLabels: m, embeddedBankAccounts: h, verifiedExter
|
|
|
172
173
|
n === "INTERNAL_TO_INTERNAL" ? await S.mutateAsync({ body: {
|
|
173
174
|
fromBankAccountId: M,
|
|
174
175
|
toBankAccountId: P,
|
|
175
|
-
amount:
|
|
176
|
+
amount: t,
|
|
176
177
|
currencyCode: X
|
|
177
178
|
} }) : await C.mutateAsync({ body: {
|
|
178
179
|
fromBankAccountId: M,
|
|
179
180
|
toBankAccountId: P,
|
|
180
|
-
amount:
|
|
181
|
+
amount: t,
|
|
181
182
|
currencyCode: X,
|
|
182
183
|
type: n,
|
|
183
184
|
secCode: m.defaultSecCode
|
|
184
185
|
} }), j("result"), x(c.TransferSubmitted, { transferType: n });
|
|
185
186
|
} catch {
|
|
186
|
-
|
|
187
|
+
e.error(r.modalSubmitFailedError);
|
|
187
188
|
}
|
|
188
189
|
}, [
|
|
189
190
|
I,
|
|
@@ -205,7 +206,7 @@ function b({ labels: r, featureLabels: m, embeddedBankAccounts: h, verifiedExter
|
|
|
205
206
|
open: O,
|
|
206
207
|
onOpenChange: ue,
|
|
207
208
|
step: A,
|
|
208
|
-
stepLabel: A === "result" ? void 0 :
|
|
209
|
+
stepLabel: A === "result" ? void 0 : t(r.modalStepLabel, {
|
|
209
210
|
current: String(A === "review" ? 2 : 1),
|
|
210
211
|
total: String(ne)
|
|
211
212
|
}),
|
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import e from "react";
|
|
4
|
+
import t from "react-dom";
|
|
5
|
+
// ../../node_modules/sonner/dist/index.mjs
|
|
6
|
+
var n = (e) => {
|
|
7
|
+
switch (e) {
|
|
8
|
+
case "success": return a;
|
|
9
|
+
case "info": return s;
|
|
10
|
+
case "warning": return o;
|
|
11
|
+
case "error": return c;
|
|
12
|
+
default: return null;
|
|
13
|
+
}
|
|
14
|
+
}, r = Array(12).fill(0), i = ({ visible: t, className: n }) => /*#__PURE__*/ e.createElement("div", {
|
|
15
|
+
className: ["sonner-loading-wrapper", n].filter(Boolean).join(" "),
|
|
16
|
+
"data-visible": t
|
|
17
|
+
}, /*#__PURE__*/ e.createElement("div", { className: "sonner-spinner" }, r.map((t, n) => /*#__PURE__*/ e.createElement("div", {
|
|
18
|
+
className: "sonner-loading-bar",
|
|
19
|
+
key: `spinner-bar-${n}`
|
|
20
|
+
})))), a = /*#__PURE__*/ e.createElement("svg", {
|
|
21
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
22
|
+
viewBox: "0 0 20 20",
|
|
23
|
+
fill: "currentColor",
|
|
24
|
+
height: "20",
|
|
25
|
+
width: "20",
|
|
26
|
+
"aria-hidden": "true"
|
|
27
|
+
}, /*#__PURE__*/ e.createElement("path", {
|
|
28
|
+
fillRule: "evenodd",
|
|
29
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
30
|
+
clipRule: "evenodd"
|
|
31
|
+
})), o = /*#__PURE__*/ e.createElement("svg", {
|
|
32
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
33
|
+
viewBox: "0 0 24 24",
|
|
34
|
+
fill: "currentColor",
|
|
35
|
+
height: "20",
|
|
36
|
+
width: "20",
|
|
37
|
+
"aria-hidden": "true"
|
|
38
|
+
}, /*#__PURE__*/ e.createElement("path", {
|
|
39
|
+
fillRule: "evenodd",
|
|
40
|
+
d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
|
|
41
|
+
clipRule: "evenodd"
|
|
42
|
+
})), s = /*#__PURE__*/ e.createElement("svg", {
|
|
43
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
44
|
+
viewBox: "0 0 20 20",
|
|
45
|
+
fill: "currentColor",
|
|
46
|
+
height: "20",
|
|
47
|
+
width: "20",
|
|
48
|
+
"aria-hidden": "true"
|
|
49
|
+
}, /*#__PURE__*/ e.createElement("path", {
|
|
50
|
+
fillRule: "evenodd",
|
|
51
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
52
|
+
clipRule: "evenodd"
|
|
53
|
+
})), c = /*#__PURE__*/ e.createElement("svg", {
|
|
54
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
55
|
+
viewBox: "0 0 20 20",
|
|
56
|
+
fill: "currentColor",
|
|
57
|
+
height: "20",
|
|
58
|
+
width: "20",
|
|
59
|
+
"aria-hidden": "true"
|
|
60
|
+
}, /*#__PURE__*/ e.createElement("path", {
|
|
61
|
+
fillRule: "evenodd",
|
|
62
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
|
|
63
|
+
clipRule: "evenodd"
|
|
64
|
+
})), ee = /*#__PURE__*/ e.createElement("svg", {
|
|
65
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
66
|
+
width: "12",
|
|
67
|
+
height: "12",
|
|
68
|
+
viewBox: "0 0 24 24",
|
|
69
|
+
fill: "none",
|
|
70
|
+
stroke: "currentColor",
|
|
71
|
+
strokeWidth: "1.5",
|
|
72
|
+
strokeLinecap: "round",
|
|
73
|
+
strokeLinejoin: "round",
|
|
74
|
+
"aria-hidden": "true"
|
|
75
|
+
}, /*#__PURE__*/ e.createElement("line", {
|
|
76
|
+
x1: "18",
|
|
77
|
+
y1: "6",
|
|
78
|
+
x2: "6",
|
|
79
|
+
y2: "18"
|
|
80
|
+
}), /*#__PURE__*/ e.createElement("line", {
|
|
81
|
+
x1: "6",
|
|
82
|
+
y1: "6",
|
|
83
|
+
x2: "18",
|
|
84
|
+
y2: "18"
|
|
85
|
+
})), l = () => {
|
|
86
|
+
let [t, n] = e.useState(document.hidden);
|
|
87
|
+
return e.useEffect(() => {
|
|
88
|
+
let e = () => {
|
|
89
|
+
n(document.hidden);
|
|
90
|
+
};
|
|
91
|
+
return document.addEventListener("visibilitychange", e), () => document.removeEventListener("visibilitychange", e);
|
|
92
|
+
}, []), t;
|
|
93
|
+
}, u = 1, d = 100, f = (e) => typeof e?.id == "number" || e?.id?.length > 0 ? e.id : u++, p = new class {
|
|
94
|
+
constructor() {
|
|
95
|
+
this.subscribe = (e) => (this.subscribers.push(e), this.getActiveToasts().forEach((t) => e(t)), () => {
|
|
96
|
+
let t = this.subscribers.indexOf(e);
|
|
97
|
+
this.subscribers.splice(t, 1);
|
|
98
|
+
}), this.publish = (e) => {
|
|
99
|
+
this.subscribers.forEach((t) => t(e));
|
|
100
|
+
}, this.addToast = (e) => {
|
|
101
|
+
this.publish(e), this.toasts = [...this.toasts, e], this.trimHistory();
|
|
102
|
+
}, this.trimHistory = () => {
|
|
103
|
+
let e = this.toasts.length - d;
|
|
104
|
+
e <= 0 || (this.toasts = this.toasts.filter((t) => e > 0 && this.dismissedToasts.has(t.id) ? (this.dismissedToasts.delete(t.id), e--, !1) : !0));
|
|
105
|
+
}, this.create = (e) => {
|
|
106
|
+
let { message: t, ...n } = e, r = f(e), i = this.pendingDismissals.get(r);
|
|
107
|
+
i !== void 0 && (cancelAnimationFrame(i), this.pendingDismissals.delete(r), this.dismissedToasts.delete(r));
|
|
108
|
+
let a = this.dismissedToasts.has(r), o = e.dismissible === void 0 || e.dismissible;
|
|
109
|
+
return a && (this.dismissedToasts.delete(r), this.toasts = this.toasts.filter((e) => e.id !== r)), !a && this.toasts.find((e) => e.id === r) ? this.toasts = this.toasts.map((n) => n.id === r ? (this.publish({
|
|
110
|
+
...n,
|
|
111
|
+
...e,
|
|
112
|
+
id: r,
|
|
113
|
+
title: t
|
|
114
|
+
}), {
|
|
115
|
+
...n,
|
|
116
|
+
...e,
|
|
117
|
+
id: r,
|
|
118
|
+
dismissible: o,
|
|
119
|
+
title: t
|
|
120
|
+
}) : n) : this.addToast({
|
|
121
|
+
title: t,
|
|
122
|
+
...n,
|
|
123
|
+
dismissible: o,
|
|
124
|
+
id: r
|
|
125
|
+
}), r;
|
|
126
|
+
}, this.dismiss = (e) => {
|
|
127
|
+
if (e == null) return this.getActiveToasts().forEach((e) => {
|
|
128
|
+
this.dismissedToasts.add(e.id), this.subscribers.forEach((t) => t({
|
|
129
|
+
id: e.id,
|
|
130
|
+
dismiss: !0
|
|
131
|
+
}));
|
|
132
|
+
}), e;
|
|
133
|
+
this.dismissedToasts.add(e);
|
|
134
|
+
let t = this.pendingDismissals.get(e);
|
|
135
|
+
return t !== void 0 && cancelAnimationFrame(t), this.pendingDismissals.set(e, requestAnimationFrame(() => {
|
|
136
|
+
this.pendingDismissals.delete(e), this.subscribers.forEach((t) => t({
|
|
137
|
+
id: e,
|
|
138
|
+
dismiss: !0
|
|
139
|
+
}));
|
|
140
|
+
})), e;
|
|
141
|
+
}, this.message = (e, t) => this.create({
|
|
142
|
+
...t,
|
|
143
|
+
message: e,
|
|
144
|
+
type: void 0
|
|
145
|
+
}), this.error = (e, t) => this.create({
|
|
146
|
+
...t,
|
|
147
|
+
message: e,
|
|
148
|
+
type: "error"
|
|
149
|
+
}), this.success = (e, t) => this.create({
|
|
150
|
+
...t,
|
|
151
|
+
type: "success",
|
|
152
|
+
message: e
|
|
153
|
+
}), this.info = (e, t) => this.create({
|
|
154
|
+
...t,
|
|
155
|
+
type: "info",
|
|
156
|
+
message: e
|
|
157
|
+
}), this.warning = (e, t) => this.create({
|
|
158
|
+
...t,
|
|
159
|
+
type: "warning",
|
|
160
|
+
message: e
|
|
161
|
+
}), this.loading = (e, t) => this.create({
|
|
162
|
+
...t,
|
|
163
|
+
type: "loading",
|
|
164
|
+
message: e
|
|
165
|
+
}), this.promise = (t, n) => {
|
|
166
|
+
if (!n) return;
|
|
167
|
+
let r;
|
|
168
|
+
n.loading !== void 0 && (r = this.create({
|
|
169
|
+
...n,
|
|
170
|
+
promise: t,
|
|
171
|
+
type: "loading",
|
|
172
|
+
message: n.loading,
|
|
173
|
+
description: typeof n.description == "function" ? void 0 : n.description
|
|
174
|
+
}));
|
|
175
|
+
let i = Promise.resolve(t instanceof Function ? t() : t), a = r !== void 0, o, s = i.then(async (t) => {
|
|
176
|
+
if (o = ["resolve", t], e.isValidElement(t)) a = !1, this.create({
|
|
177
|
+
id: r,
|
|
178
|
+
type: "default",
|
|
179
|
+
message: t
|
|
180
|
+
});
|
|
181
|
+
else if (h(t) && !t.ok) {
|
|
182
|
+
a = !1;
|
|
183
|
+
let i = typeof n.error == "function" ? await n.error(`HTTP error! status: ${t.status}`) : n.error, o = typeof n.description == "function" ? await n.description(`HTTP error! status: ${t.status}`) : n.description, s = typeof i == "object" && !e.isValidElement(i) ? i : { message: i };
|
|
184
|
+
this.create({
|
|
185
|
+
id: r,
|
|
186
|
+
type: "error",
|
|
187
|
+
description: o,
|
|
188
|
+
...s
|
|
189
|
+
});
|
|
190
|
+
} else if (t instanceof Error) {
|
|
191
|
+
a = !1;
|
|
192
|
+
let i = typeof n.error == "function" ? await n.error(t) : n.error, o = typeof n.description == "function" ? await n.description(t) : n.description, s = typeof i == "object" && !e.isValidElement(i) ? i : { message: i };
|
|
193
|
+
this.create({
|
|
194
|
+
id: r,
|
|
195
|
+
type: "error",
|
|
196
|
+
description: o,
|
|
197
|
+
...s
|
|
198
|
+
});
|
|
199
|
+
} else if (n.success !== void 0) {
|
|
200
|
+
a = !1;
|
|
201
|
+
let i = typeof n.success == "function" ? await n.success(t) : n.success, o = typeof n.description == "function" ? await n.description(t) : n.description, s = typeof i == "object" && !e.isValidElement(i) ? i : { message: i };
|
|
202
|
+
this.create({
|
|
203
|
+
id: r,
|
|
204
|
+
type: "success",
|
|
205
|
+
description: o,
|
|
206
|
+
...s
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}).catch(async (t) => {
|
|
210
|
+
if (o = ["reject", t], n.error !== void 0) {
|
|
211
|
+
a = !1;
|
|
212
|
+
let i = typeof n.error == "function" ? await n.error(t) : n.error, o = typeof n.description == "function" ? await n.description(t) : n.description, s = typeof i == "object" && !e.isValidElement(i) ? i : { message: i };
|
|
213
|
+
this.create({
|
|
214
|
+
id: r,
|
|
215
|
+
type: "error",
|
|
216
|
+
description: o,
|
|
217
|
+
...s
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}).finally(() => {
|
|
221
|
+
a && (this.dismiss(r), r = void 0), n.finally == null || n.finally.call(n);
|
|
222
|
+
}), c = () => new Promise((e, t) => s.then(() => o[0] === "reject" ? t(o[1]) : e(o[1])).catch(t));
|
|
223
|
+
return typeof r != "string" && typeof r != "number" ? { unwrap: c } : Object.assign(r, { unwrap: c });
|
|
224
|
+
}, this.custom = (e, t) => {
|
|
225
|
+
let n = f(t);
|
|
226
|
+
return this.create({
|
|
227
|
+
...t,
|
|
228
|
+
jsx: e(n),
|
|
229
|
+
id: n,
|
|
230
|
+
type: void 0
|
|
231
|
+
}), n;
|
|
232
|
+
}, this.getActiveToasts = () => this.toasts.filter((e) => !this.dismissedToasts.has(e.id)), this.subscribers = [], this.toasts = [], this.dismissedToasts = /* @__PURE__ */ new Set(), this.pendingDismissals = /* @__PURE__ */ new Map();
|
|
233
|
+
}
|
|
234
|
+
}(), m = (e, t) => p.message(e, t), h = (e) => e && typeof e == "object" && "ok" in e && typeof e.ok == "boolean" && "status" in e && typeof e.status == "number", g = Object.assign(m, {
|
|
235
|
+
success: p.success,
|
|
236
|
+
info: p.info,
|
|
237
|
+
warning: p.warning,
|
|
238
|
+
error: p.error,
|
|
239
|
+
custom: p.custom,
|
|
240
|
+
message: p.message,
|
|
241
|
+
promise: p.promise,
|
|
242
|
+
dismiss: p.dismiss,
|
|
243
|
+
loading: p.loading
|
|
244
|
+
}, {
|
|
245
|
+
getHistory: () => p.toasts,
|
|
246
|
+
getToasts: () => p.getActiveToasts()
|
|
247
|
+
});
|
|
248
|
+
function _(e) {
|
|
249
|
+
return e.label !== void 0;
|
|
250
|
+
}
|
|
251
|
+
var v = 3, y = "24px", b = "16px", x = 4e3, te = 356, ne = 14, re = 45, ie = 200;
|
|
252
|
+
function S(...e) {
|
|
253
|
+
return e.filter(Boolean).join(" ");
|
|
254
|
+
}
|
|
255
|
+
function C(e) {
|
|
256
|
+
let [t, n] = e.split("-"), r = [];
|
|
257
|
+
return t && r.push(t), n && r.push(n), r;
|
|
258
|
+
}
|
|
259
|
+
var ae = (t) => {
|
|
260
|
+
let { invert: r, toast: a, unstyled: o, interacting: s, setHeights: c, visibleToasts: u, heights: d, index: f, toasts: p, expanded: m, removeToast: h, defaultRichColors: g, closeButton: v, style: y, cancelButtonStyle: b, actionButtonStyle: te, className: ne = "", descriptionClassName: ae = "", duration: w, position: T, gap: E, expandByDefault: D, classNames: O, icons: k, closeButtonAriaLabel: oe = "Close toast" } = t, [A, j] = e.useState(null), [M, N] = e.useState(null), [P, F] = e.useState(!1), [I, L] = e.useState(!1), [R, z] = e.useState(!1), [B, se] = e.useState(!1), [ce, le] = e.useState(!1), [ue, V] = e.useState(0), [de, H] = e.useState(0), U = e.useRef(a.duration || w || x), fe = e.useRef(null), W = e.useRef(null), pe = f === 0, me = f + 1 <= u, G = a.type, he = G ?? "default", K = a.dismissible !== !1, ge = a.className || "", _e = a.descriptionClassName || "", q = e.useMemo(() => d.findIndex((e) => e.toastId === a.id) || 0, [d, a.id]), ve = e.useMemo(() => a.closeButton ?? v, [a.closeButton, v]), ye = e.useMemo(() => a.duration || w || x, [a.duration, w]), J = e.useRef(0), Y = e.useRef(0), be = e.useRef(0), X = e.useRef(null), [xe, Se] = T.split("-"), Ce = e.useMemo(() => d.reduce((e, t, n) => n >= q ? e : e + t.height, 0), [d, q]), we = l(), Z = e.useMemo(() => t.swipeDirections ?? C(T), [t.swipeDirections, T]), Te = a.invert || r, Q = G === "loading";
|
|
261
|
+
Y.current = e.useMemo(() => q * E + Ce, [q, Ce]), e.useEffect(() => {
|
|
262
|
+
U.current = ye;
|
|
263
|
+
}, [ye]), e.useEffect(() => {
|
|
264
|
+
F(!0);
|
|
265
|
+
}, []), e.useEffect(() => {
|
|
266
|
+
let e = W.current;
|
|
267
|
+
if (e) {
|
|
268
|
+
let t = e.getBoundingClientRect().height;
|
|
269
|
+
return H(t), c((e) => [{
|
|
270
|
+
toastId: a.id,
|
|
271
|
+
height: t,
|
|
272
|
+
position: a.position
|
|
273
|
+
}, ...e]), () => c((e) => e.filter((e) => e.toastId !== a.id));
|
|
274
|
+
}
|
|
275
|
+
}, [c, a.id]), e.useLayoutEffect(() => {
|
|
276
|
+
if (!P) return;
|
|
277
|
+
let e = W.current, t = e.style.height;
|
|
278
|
+
e.style.height = "auto";
|
|
279
|
+
let n = e.getBoundingClientRect().height;
|
|
280
|
+
e.style.height = t, H(n), c((e) => e.find((e) => e.toastId === a.id) ? e.map((e) => e.toastId === a.id ? {
|
|
281
|
+
...e,
|
|
282
|
+
height: n
|
|
283
|
+
} : e) : [{
|
|
284
|
+
toastId: a.id,
|
|
285
|
+
height: n,
|
|
286
|
+
position: a.position
|
|
287
|
+
}, ...e]);
|
|
288
|
+
}, [
|
|
289
|
+
P,
|
|
290
|
+
a.title,
|
|
291
|
+
a.description,
|
|
292
|
+
c,
|
|
293
|
+
a.id,
|
|
294
|
+
a.jsx,
|
|
295
|
+
a.action,
|
|
296
|
+
a.cancel
|
|
297
|
+
]);
|
|
298
|
+
let $ = e.useCallback(() => {
|
|
299
|
+
L(!0), V(Y.current), c((e) => e.filter((e) => e.toastId !== a.id)), setTimeout(() => {
|
|
300
|
+
h(a);
|
|
301
|
+
}, ie);
|
|
302
|
+
}, [
|
|
303
|
+
a,
|
|
304
|
+
h,
|
|
305
|
+
c,
|
|
306
|
+
Y
|
|
307
|
+
]);
|
|
308
|
+
e.useEffect(() => {
|
|
309
|
+
if (a.promise && G === "loading" || a.duration === Infinity || a.type === "loading") return;
|
|
310
|
+
let e;
|
|
311
|
+
return m || s || we ? (() => {
|
|
312
|
+
if (be.current < J.current) {
|
|
313
|
+
let e = (/* @__PURE__ */ new Date()).getTime() - J.current;
|
|
314
|
+
U.current -= e;
|
|
315
|
+
}
|
|
316
|
+
be.current = (/* @__PURE__ */ new Date()).getTime();
|
|
317
|
+
})() : U.current !== Infinity && (J.current = (/* @__PURE__ */ new Date()).getTime(), e = setTimeout(() => {
|
|
318
|
+
a.onAutoClose == null || a.onAutoClose.call(a, a), $();
|
|
319
|
+
}, U.current)), () => clearTimeout(e);
|
|
320
|
+
}, [
|
|
321
|
+
m,
|
|
322
|
+
s,
|
|
323
|
+
a,
|
|
324
|
+
G,
|
|
325
|
+
we,
|
|
326
|
+
$
|
|
327
|
+
]), e.useEffect(() => {
|
|
328
|
+
a.delete && ($(), a.onDismiss == null || a.onDismiss.call(a, a));
|
|
329
|
+
}, [$, a.delete]);
|
|
330
|
+
function Ee() {
|
|
331
|
+
return k?.loading ? /*#__PURE__*/ e.createElement("div", {
|
|
332
|
+
className: S(O?.loader, a?.classNames?.loader, "sonner-loader"),
|
|
333
|
+
"data-visible": G === "loading"
|
|
334
|
+
}, k.loading) : /*#__PURE__*/ e.createElement(i, {
|
|
335
|
+
className: S(O?.loader, a?.classNames?.loader),
|
|
336
|
+
visible: G === "loading"
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
let De = a.icon || k?.[G] || n(G);
|
|
340
|
+
return /*#__PURE__*/ e.createElement("li", {
|
|
341
|
+
tabIndex: 0,
|
|
342
|
+
ref: W,
|
|
343
|
+
className: S(ne, ge, O?.toast, a?.classNames?.toast, O?.[he], a?.classNames?.[he]),
|
|
344
|
+
"data-sonner-toast": "",
|
|
345
|
+
"data-rich-colors": a.richColors ?? g,
|
|
346
|
+
"data-styled": !(a.jsx || a.unstyled || o),
|
|
347
|
+
"data-mounted": P,
|
|
348
|
+
"data-promise": !!a.promise,
|
|
349
|
+
"data-swiped": ce,
|
|
350
|
+
"data-removed": I,
|
|
351
|
+
"data-visible": me,
|
|
352
|
+
"data-y-position": xe,
|
|
353
|
+
"data-x-position": Se,
|
|
354
|
+
"data-index": f,
|
|
355
|
+
"data-front": pe,
|
|
356
|
+
"data-swiping": R,
|
|
357
|
+
"data-dismissible": K,
|
|
358
|
+
"data-type": G,
|
|
359
|
+
"data-invert": Te,
|
|
360
|
+
"data-swipe-out": B,
|
|
361
|
+
"data-swipe-direction": M,
|
|
362
|
+
"data-expanded": !!(m || D && P),
|
|
363
|
+
"data-testid": a.testId,
|
|
364
|
+
style: {
|
|
365
|
+
"--index": f,
|
|
366
|
+
"--toasts-before": f,
|
|
367
|
+
"--z-index": p.length - f,
|
|
368
|
+
"--offset": `${I ? ue : Y.current}px`,
|
|
369
|
+
"--initial-height": D ? "auto" : `${de}px`,
|
|
370
|
+
...y,
|
|
371
|
+
...a.style
|
|
372
|
+
},
|
|
373
|
+
onDragEnd: () => {
|
|
374
|
+
z(!1), j(null), X.current = null;
|
|
375
|
+
},
|
|
376
|
+
onPointerDown: (e) => {
|
|
377
|
+
e.button !== 2 && !Q && K && (fe.current = /* @__PURE__ */ new Date(), V(Y.current), e.target.setPointerCapture(e.pointerId), e.target.tagName !== "BUTTON" && (z(!0), X.current = {
|
|
378
|
+
x: e.clientX,
|
|
379
|
+
y: e.clientY
|
|
380
|
+
}));
|
|
381
|
+
},
|
|
382
|
+
onPointerUp: () => {
|
|
383
|
+
if (B || !K) return;
|
|
384
|
+
X.current = null;
|
|
385
|
+
let e = Number(W.current?.style.getPropertyValue("--swipe-amount-x").replace("px", "") || 0), t = Number(W.current?.style.getPropertyValue("--swipe-amount-y").replace("px", "") || 0), n = (/* @__PURE__ */ new Date()).getTime() - fe.current?.getTime(), r = A === "x" ? e : t, i = Math.abs(r) / n;
|
|
386
|
+
if ((A === "x" ? Z.includes(e > 0 ? "right" : "left") : Z.includes(t > 0 ? "bottom" : "top")) && (Math.abs(r) >= re || i > .11)) V(Y.current), a.onDismiss == null || a.onDismiss.call(a, a), N(A === "x" ? e > 0 ? "right" : "left" : t > 0 ? "down" : "up"), $(), se(!0);
|
|
387
|
+
else {
|
|
388
|
+
var o, s;
|
|
389
|
+
(o = W.current) == null || o.style.setProperty("--swipe-amount-x", "0px"), (s = W.current) == null || s.style.setProperty("--swipe-amount-y", "0px"), le(!1), z(!1), j(null);
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
onPointerMove: (e) => {
|
|
393
|
+
var t, n;
|
|
394
|
+
if (!X.current || !K || window.getSelection()?.toString().length > 0) return;
|
|
395
|
+
let r = e.clientY - X.current.y, i = e.clientX - X.current.x;
|
|
396
|
+
!A && (Math.abs(i) > 1 || Math.abs(r) > 1) && j(Math.abs(i) > Math.abs(r) ? "x" : "y");
|
|
397
|
+
let a = {
|
|
398
|
+
x: 0,
|
|
399
|
+
y: 0
|
|
400
|
+
}, o = (e) => 1 / (1.5 + Math.abs(e) / 20);
|
|
401
|
+
if (A === "y") {
|
|
402
|
+
if (Z.includes("top") || Z.includes("bottom")) {
|
|
403
|
+
if (Z.includes("top") && r < 0 || Z.includes("bottom") && r > 0) a.y = r;
|
|
404
|
+
else {
|
|
405
|
+
let e = r * o(r);
|
|
406
|
+
a.y = Math.abs(e) < Math.abs(r) ? e : r;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
} else if (A === "x" && (Z.includes("left") || Z.includes("right"))) {
|
|
410
|
+
if (Z.includes("left") && i < 0 || Z.includes("right") && i > 0) a.x = i;
|
|
411
|
+
else {
|
|
412
|
+
let e = i * o(i);
|
|
413
|
+
a.x = Math.abs(e) < Math.abs(i) ? e : i;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
(Math.abs(a.x) > 0 || Math.abs(a.y) > 0) && le(!0), (t = W.current) == null || t.style.setProperty("--swipe-amount-x", `${a.x}px`), (n = W.current) == null || n.style.setProperty("--swipe-amount-y", `${a.y}px`);
|
|
417
|
+
}
|
|
418
|
+
}, ve && !a.jsx && G !== "loading" ? /*#__PURE__*/ e.createElement("button", {
|
|
419
|
+
"aria-label": oe,
|
|
420
|
+
"data-disabled": Q,
|
|
421
|
+
"data-close-button": !0,
|
|
422
|
+
onClick: Q || !K ? () => {} : () => {
|
|
423
|
+
$(), a.onDismiss == null || a.onDismiss.call(a, a);
|
|
424
|
+
},
|
|
425
|
+
className: S(O?.closeButton, a?.classNames?.closeButton)
|
|
426
|
+
}, k?.close ?? ee) : null, (G || a.icon || a.promise) && a.icon !== null && (k?.[G] !== null || a.icon) ? /*#__PURE__*/ e.createElement("div", {
|
|
427
|
+
"data-icon": "",
|
|
428
|
+
className: S(O?.icon, a?.classNames?.icon)
|
|
429
|
+
}, G === "loading" ? a.icon || Ee() : a.promise ? Ee() : null, G === "loading" ? null : De) : null, /*#__PURE__*/ e.createElement("div", {
|
|
430
|
+
"data-content": "",
|
|
431
|
+
className: S(O?.content, a?.classNames?.content)
|
|
432
|
+
}, /*#__PURE__*/ e.createElement("div", {
|
|
433
|
+
"data-title": "",
|
|
434
|
+
className: S(O?.title, a?.classNames?.title)
|
|
435
|
+
}, a.jsx ? a.jsx : typeof a.title == "function" ? a.title() : a.title), a.description ? /*#__PURE__*/ e.createElement("div", {
|
|
436
|
+
"data-description": "",
|
|
437
|
+
className: S(ae, _e, O?.description, a?.classNames?.description)
|
|
438
|
+
}, typeof a.description == "function" ? a.description() : a.description) : null), /*#__PURE__*/ e.isValidElement(a.cancel) ? a.cancel : a.cancel && _(a.cancel) ? /*#__PURE__*/ e.createElement("button", {
|
|
439
|
+
"data-button": !0,
|
|
440
|
+
"data-cancel": !0,
|
|
441
|
+
style: a.cancelButtonStyle || b,
|
|
442
|
+
onClick: (e) => {
|
|
443
|
+
_(a.cancel) && K && (a.cancel.onClick == null || a.cancel.onClick.call(a.cancel, e), $());
|
|
444
|
+
},
|
|
445
|
+
className: S(O?.cancelButton, a?.classNames?.cancelButton)
|
|
446
|
+
}, a.cancel.label) : null, /*#__PURE__*/ e.isValidElement(a.action) ? a.action : a.action && _(a.action) ? /*#__PURE__*/ e.createElement("button", {
|
|
447
|
+
"data-button": !0,
|
|
448
|
+
"data-action": !0,
|
|
449
|
+
style: a.actionButtonStyle || te,
|
|
450
|
+
onClick: (e) => {
|
|
451
|
+
_(a.action) && (a.action.onClick == null || a.action.onClick.call(a.action, e), !e.defaultPrevented && $());
|
|
452
|
+
},
|
|
453
|
+
className: S(O?.actionButton, a?.classNames?.actionButton)
|
|
454
|
+
}, a.action.label) : null);
|
|
455
|
+
};
|
|
456
|
+
function w() {
|
|
457
|
+
if (typeof window > "u" || typeof document > "u") return "ltr";
|
|
458
|
+
let e = document.documentElement.getAttribute("dir");
|
|
459
|
+
return e === "auto" || !e ? window.getComputedStyle(document.documentElement).direction : e;
|
|
460
|
+
}
|
|
461
|
+
function T(e, t) {
|
|
462
|
+
let n = {};
|
|
463
|
+
return [e, t].forEach((e, t) => {
|
|
464
|
+
let r = t === 1, i = r ? "--mobile-offset" : "--offset", a = r ? b : y;
|
|
465
|
+
function o(e) {
|
|
466
|
+
[
|
|
467
|
+
"top",
|
|
468
|
+
"right",
|
|
469
|
+
"bottom",
|
|
470
|
+
"left"
|
|
471
|
+
].forEach((t) => {
|
|
472
|
+
n[`${i}-${t}`] = typeof e == "number" ? `${e}px` : e;
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
typeof e == "number" || typeof e == "string" ? o(e) : typeof e == "object" ? [
|
|
476
|
+
"top",
|
|
477
|
+
"right",
|
|
478
|
+
"bottom",
|
|
479
|
+
"left"
|
|
480
|
+
].forEach((t) => {
|
|
481
|
+
e[t] === void 0 ? n[`${i}-${t}`] = a : n[`${i}-${t}`] = typeof e[t] == "number" ? `${e[t]}px` : e[t];
|
|
482
|
+
}) : o(a);
|
|
483
|
+
}), n;
|
|
484
|
+
}
|
|
485
|
+
var E = /*#__PURE__*/ e.forwardRef(function(n, r) {
|
|
486
|
+
let { id: i, invert: a, position: o = "bottom-right", hotkey: s = ["altKey", "KeyT"], expand: c, closeButton: ee, className: l, offset: u, mobileOffset: d, theme: f = "light", richColors: m, duration: h, style: g, visibleToasts: _ = v, toastOptions: y, dir: b = w(), gap: x = ne, icons: re, customAriaLabel: ie, containerAriaLabel: S = "Notifications" } = n, [C, E] = e.useState([]), D = e.useMemo(() => i ? C.filter((e) => e.toasterId === i) : C.filter((e) => !e.toasterId), [C, i]), O = e.useMemo(() => Array.from(new Set([o].concat(D.filter((e) => e.position).map((e) => e.position)))), [D, o]), [k, oe] = e.useState([]), [A, j] = e.useState(!1), [M, N] = e.useState(!1), [P, F] = e.useState(f === "system" ? typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : f), I = e.useRef(null), L = s.join("+").replace(/Key/g, "").replace(/Digit/g, ""), R = e.useRef(null), z = e.useRef(!1), B = e.useCallback((e) => {
|
|
487
|
+
E((t) => (t.find((t) => t.id === e.id)?.delete || p.dismiss(e.id), t.filter(({ id: t }) => t !== e.id)));
|
|
488
|
+
}, []);
|
|
489
|
+
return e.useEffect(() => p.subscribe((e) => {
|
|
490
|
+
e.dismiss ? requestAnimationFrame(() => {
|
|
491
|
+
E((t) => t.map((t) => t.id === e.id ? {
|
|
492
|
+
...t,
|
|
493
|
+
delete: !0
|
|
494
|
+
} : t));
|
|
495
|
+
}) : setTimeout(() => {
|
|
496
|
+
t.flushSync(() => {
|
|
497
|
+
E((t) => {
|
|
498
|
+
let n = t.findIndex((t) => t.id === e.id);
|
|
499
|
+
return n === -1 ? [e, ...t] : [
|
|
500
|
+
...t.slice(0, n),
|
|
501
|
+
{
|
|
502
|
+
...t[n],
|
|
503
|
+
...e
|
|
504
|
+
},
|
|
505
|
+
...t.slice(n + 1)
|
|
506
|
+
];
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
}), []), e.useEffect(() => {
|
|
511
|
+
if (f !== "system") {
|
|
512
|
+
F(f);
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
if (f === "system" && (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? F("dark") : F("light")), typeof window > "u") return;
|
|
516
|
+
let e = window.matchMedia("(prefers-color-scheme: dark)");
|
|
517
|
+
try {
|
|
518
|
+
e.addEventListener("change", ({ matches: e }) => {
|
|
519
|
+
F(e ? "dark" : "light");
|
|
520
|
+
});
|
|
521
|
+
} catch {
|
|
522
|
+
e.addListener(({ matches: e }) => {
|
|
523
|
+
try {
|
|
524
|
+
F(e ? "dark" : "light");
|
|
525
|
+
} catch (e) {
|
|
526
|
+
console.error(e);
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
}, [f]), e.useEffect(() => {
|
|
531
|
+
C.length <= 1 && j(!1);
|
|
532
|
+
}, [C]), e.useEffect(() => {
|
|
533
|
+
let e = (e) => {
|
|
534
|
+
if (s.length > 0 && s.every((t) => e[t] || e.code === t)) {
|
|
535
|
+
var t;
|
|
536
|
+
j(!0), (t = I.current) == null || t.focus();
|
|
537
|
+
}
|
|
538
|
+
e.code === "Escape" && (document.activeElement === I.current || I.current?.contains(document.activeElement)) && j(!1);
|
|
539
|
+
};
|
|
540
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
541
|
+
}, [s]), e.useEffect(() => {
|
|
542
|
+
if (I.current) return () => {
|
|
543
|
+
R.current && (R.current.focus({ preventScroll: !0 }), R.current = null, z.current = !1);
|
|
544
|
+
};
|
|
545
|
+
}, [I.current]), /*#__PURE__*/ e.createElement("section", {
|
|
546
|
+
ref: r,
|
|
547
|
+
"aria-label": ie ?? `${S} ${L}`,
|
|
548
|
+
tabIndex: -1,
|
|
549
|
+
"aria-live": "polite",
|
|
550
|
+
"aria-relevant": "additions text",
|
|
551
|
+
"aria-atomic": "false",
|
|
552
|
+
suppressHydrationWarning: !0,
|
|
553
|
+
"data-react-aria-top-layer": !0
|
|
554
|
+
}, O.map((t, r) => {
|
|
555
|
+
let [i, o] = t.split("-");
|
|
556
|
+
return D.length ? /*#__PURE__*/ e.createElement("ol", {
|
|
557
|
+
key: t,
|
|
558
|
+
dir: b === "auto" ? w() : b,
|
|
559
|
+
tabIndex: -1,
|
|
560
|
+
ref: I,
|
|
561
|
+
className: l,
|
|
562
|
+
"data-sonner-toaster": !0,
|
|
563
|
+
"data-sonner-theme": P,
|
|
564
|
+
"data-y-position": i,
|
|
565
|
+
"data-x-position": o,
|
|
566
|
+
style: {
|
|
567
|
+
"--front-toast-height": `${k[0]?.height || 0}px`,
|
|
568
|
+
"--width": `${te}px`,
|
|
569
|
+
"--gap": `${x}px`,
|
|
570
|
+
...g,
|
|
571
|
+
...T(u, d)
|
|
572
|
+
},
|
|
573
|
+
onBlur: (e) => {
|
|
574
|
+
z.current && !e.currentTarget.contains(e.relatedTarget) && (z.current = !1, R.current &&= (R.current.focus({ preventScroll: !0 }), null));
|
|
575
|
+
},
|
|
576
|
+
onFocus: (e) => {
|
|
577
|
+
e.target instanceof HTMLElement && e.target.dataset.dismissible === "false" || z.current || (z.current = !0, R.current = e.relatedTarget);
|
|
578
|
+
},
|
|
579
|
+
onMouseEnter: () => j(!0),
|
|
580
|
+
onMouseMove: () => j(!0),
|
|
581
|
+
onMouseLeave: () => {
|
|
582
|
+
M || j(!1);
|
|
583
|
+
},
|
|
584
|
+
onDragEnd: () => j(!1),
|
|
585
|
+
onPointerDown: (e) => {
|
|
586
|
+
e.target instanceof HTMLElement && e.target.dataset.dismissible === "false" || N(!0);
|
|
587
|
+
},
|
|
588
|
+
onPointerUp: () => N(!1)
|
|
589
|
+
}, D.filter((e) => !e.position && r === 0 || e.position === t).map((r, i) => /*#__PURE__*/ e.createElement(ae, {
|
|
590
|
+
key: r.id,
|
|
591
|
+
icons: re,
|
|
592
|
+
index: i,
|
|
593
|
+
toast: r,
|
|
594
|
+
defaultRichColors: m,
|
|
595
|
+
duration: y?.duration ?? h,
|
|
596
|
+
className: y?.className,
|
|
597
|
+
descriptionClassName: y?.descriptionClassName,
|
|
598
|
+
invert: a,
|
|
599
|
+
visibleToasts: _,
|
|
600
|
+
closeButton: y?.closeButton ?? ee,
|
|
601
|
+
interacting: M,
|
|
602
|
+
position: t,
|
|
603
|
+
style: y?.style,
|
|
604
|
+
unstyled: y?.unstyled,
|
|
605
|
+
classNames: y?.classNames,
|
|
606
|
+
cancelButtonStyle: y?.cancelButtonStyle,
|
|
607
|
+
actionButtonStyle: y?.actionButtonStyle,
|
|
608
|
+
closeButtonAriaLabel: y?.closeButtonAriaLabel,
|
|
609
|
+
removeToast: B,
|
|
610
|
+
toasts: D.filter((e) => e.position == r.position),
|
|
611
|
+
heights: k.filter((e) => e.position == r.position),
|
|
612
|
+
setHeights: oe,
|
|
613
|
+
expandByDefault: c,
|
|
614
|
+
gap: x,
|
|
615
|
+
expanded: A,
|
|
616
|
+
swipeDirections: n.swipeDirections
|
|
617
|
+
}))) : null;
|
|
618
|
+
}));
|
|
619
|
+
});
|
|
620
|
+
export { E as Toaster, g as toast };
|