@daimo/sdk 1.0.0 → 1.0.2
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/client/createDaimoClient.d.ts +2 -6
- package/dist/client/createDaimoClient.d.ts.map +1 -1
- package/dist/client/createDaimoClient.js +2 -1
- package/dist/client/createDaimoClient.js.map +1 -1
- package/dist/common/legacy/assert.d.ts +6 -0
- package/dist/common/legacy/assert.d.ts.map +1 -0
- package/dist/common/legacy/assert.js +25 -0
- package/dist/common/legacy/assert.js.map +1 -0
- package/dist/common/legacy/client.d.ts +67 -0
- package/dist/common/legacy/client.d.ts.map +1 -0
- package/dist/common/legacy/client.js +55 -0
- package/dist/common/legacy/client.js.map +1 -0
- package/dist/common/legacy/debug.d.ts +5 -0
- package/dist/common/legacy/debug.d.ts.map +1 -0
- package/dist/common/legacy/debug.js +21 -0
- package/dist/common/legacy/debug.js.map +1 -0
- package/dist/common/legacy/format.d.ts +16 -0
- package/dist/common/legacy/format.d.ts.map +1 -0
- package/dist/common/legacy/format.js +34 -0
- package/dist/common/legacy/format.js.map +1 -0
- package/dist/common/legacy/index.d.ts +11 -0
- package/dist/common/legacy/index.d.ts.map +1 -0
- package/dist/common/legacy/index.js +11 -0
- package/dist/common/legacy/index.js.map +1 -0
- package/dist/common/legacy/primitiveTypes.d.ts +11 -0
- package/dist/common/legacy/primitiveTypes.d.ts.map +1 -0
- package/dist/common/legacy/primitiveTypes.js +14 -0
- package/dist/common/legacy/primitiveTypes.js.map +1 -0
- package/dist/common/legacy/session.d.ts +246 -0
- package/dist/common/legacy/session.d.ts.map +1 -0
- package/dist/common/legacy/session.js +124 -0
- package/dist/common/legacy/session.js.map +1 -0
- package/dist/common/legacy/try.d.ts +4 -0
- package/dist/common/legacy/try.d.ts.map +1 -0
- package/dist/common/legacy/try.js +26 -0
- package/dist/common/legacy/try.js.map +1 -0
- package/dist/hooks/DaimoClientContext.d.ts +7 -0
- package/dist/hooks/DaimoClientContext.d.ts.map +1 -0
- package/dist/hooks/DaimoClientContext.js +15 -0
- package/dist/hooks/DaimoClientContext.js.map +1 -0
- package/dist/hooks/formatUserError.d.ts +3 -0
- package/dist/hooks/formatUserError.d.ts.map +1 -0
- package/dist/hooks/formatUserError.js +30 -0
- package/dist/hooks/formatUserError.js.map +1 -0
- package/dist/hooks/index.d.ts +12 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/locale.d.ts +7 -0
- package/dist/hooks/locale.d.ts.map +1 -0
- package/dist/hooks/locale.js +15 -0
- package/dist/hooks/locale.js.map +1 -0
- package/dist/hooks/locales/en.d.ts +60 -0
- package/dist/hooks/locales/en.d.ts.map +1 -0
- package/dist/hooks/locales/en.js +76 -0
- package/dist/hooks/locales/en.js.map +1 -0
- package/dist/hooks/locales/es.d.ts +4 -0
- package/dist/hooks/locales/es.d.ts.map +1 -0
- package/dist/hooks/locales/es.js +60 -0
- package/dist/hooks/locales/es.js.map +1 -0
- package/dist/hooks/navEvent.d.ts +60 -0
- package/dist/hooks/navEvent.d.ts.map +1 -0
- package/dist/hooks/navEvent.js +16 -0
- package/dist/hooks/navEvent.js.map +1 -0
- package/dist/hooks/types.d.ts +71 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +14 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/hooks/usePaymentCallbacks.d.ts +15 -0
- package/dist/hooks/usePaymentCallbacks.d.ts.map +1 -0
- package/dist/hooks/usePaymentCallbacks.js +27 -0
- package/dist/hooks/usePaymentCallbacks.js.map +1 -0
- package/dist/hooks/useSessionNav.d.ts +31 -0
- package/dist/hooks/useSessionNav.d.ts.map +1 -0
- package/dist/hooks/useSessionNav.js +439 -0
- package/dist/hooks/useSessionNav.js.map +1 -0
- package/dist/hooks/useSessionPolling.d.ts +10 -0
- package/dist/hooks/useSessionPolling.d.ts.map +1 -0
- package/dist/hooks/useSessionPolling.js +61 -0
- package/dist/hooks/useSessionPolling.js.map +1 -0
- package/dist/web/ChooseOptionPage.d.ts +9 -0
- package/dist/web/ChooseOptionPage.d.ts.map +1 -0
- package/dist/web/ChooseOptionPage.js +51 -0
- package/dist/web/ChooseOptionPage.js.map +1 -0
- package/dist/web/ConfirmationPage.d.ts +32 -0
- package/dist/web/ConfirmationPage.d.ts.map +1 -0
- package/dist/web/ConfirmationPage.js +72 -0
- package/dist/web/ConfirmationPage.js.map +1 -0
- package/dist/web/ConfirmationSpinner.d.ts +7 -0
- package/dist/web/ConfirmationSpinner.d.ts.map +1 -0
- package/dist/web/ConfirmationSpinner.js +20 -0
- package/dist/web/ConfirmationSpinner.js.map +1 -0
- package/dist/web/DaimoModal.d.ts +15 -0
- package/dist/web/DaimoModal.d.ts.map +1 -0
- package/dist/web/DaimoModal.js +283 -0
- package/dist/web/DaimoModal.js.map +1 -0
- package/dist/web/DeeplinkPage.d.ts +8 -0
- package/dist/web/DeeplinkPage.d.ts.map +1 -0
- package/dist/web/DeeplinkPage.js +13 -0
- package/dist/web/DeeplinkPage.js.map +1 -0
- package/dist/web/ErrorPage.d.ts +28 -0
- package/dist/web/ErrorPage.d.ts.map +1 -0
- package/dist/web/ErrorPage.js +47 -0
- package/dist/web/ErrorPage.js.map +1 -0
- package/dist/web/ExchangePage.d.ts +11 -0
- package/dist/web/ExchangePage.d.ts.map +1 -0
- package/dist/web/ExchangePage.js +13 -0
- package/dist/web/ExchangePage.js.map +1 -0
- package/dist/web/ExpiredPage.d.ts +9 -0
- package/dist/web/ExpiredPage.d.ts.map +1 -0
- package/dist/web/ExpiredPage.js +12 -0
- package/dist/web/ExpiredPage.js.map +1 -0
- package/dist/web/ModalSkeleton.d.ts +7 -0
- package/dist/web/ModalSkeleton.d.ts.map +1 -0
- package/dist/web/ModalSkeleton.js +13 -0
- package/dist/web/ModalSkeleton.js.map +1 -0
- package/dist/web/ProgressDots.d.ts +16 -0
- package/dist/web/ProgressDots.d.ts.map +1 -0
- package/dist/web/ProgressDots.js +55 -0
- package/dist/web/ProgressDots.js.map +1 -0
- package/dist/web/QRCode.d.ts +7 -0
- package/dist/web/QRCode.d.ts.map +1 -0
- package/dist/web/QRCode.js +69 -0
- package/dist/web/QRCode.js.map +1 -0
- package/dist/web/SelectAmountPage.d.ts +21 -0
- package/dist/web/SelectAmountPage.d.ts.map +1 -0
- package/dist/web/SelectAmountPage.js +27 -0
- package/dist/web/SelectAmountPage.js.map +1 -0
- package/dist/web/SelectTokenPage.d.ts +14 -0
- package/dist/web/SelectTokenPage.d.ts.map +1 -0
- package/dist/web/SelectTokenPage.js +71 -0
- package/dist/web/SelectTokenPage.js.map +1 -0
- package/dist/web/WaitingDepositAddressPage.d.ts +14 -0
- package/dist/web/WaitingDepositAddressPage.d.ts.map +1 -0
- package/dist/web/WaitingDepositAddressPage.js +126 -0
- package/dist/web/WaitingDepositAddressPage.js.map +1 -0
- package/dist/web/WalletAmountPage.d.ts +10 -0
- package/dist/web/WalletAmountPage.d.ts.map +1 -0
- package/dist/web/WalletAmountPage.js +158 -0
- package/dist/web/WalletAmountPage.js.map +1 -0
- package/dist/web/api/index.d.ts +10 -0
- package/dist/web/api/index.d.ts.map +1 -1
- package/dist/web/api/navTree.d.ts +7 -2
- package/dist/web/api/navTree.d.ts.map +1 -1
- package/dist/web/buttons.d.ts +15 -0
- package/dist/web/buttons.d.ts.map +1 -0
- package/dist/web/buttons.js +24 -0
- package/dist/web/buttons.js.map +1 -0
- package/dist/web/components/ChooseChainPage.d.ts +2 -1
- package/dist/web/components/ChooseChainPage.d.ts.map +1 -1
- package/dist/web/components/ChooseChainPage.js +4 -4
- package/dist/web/components/ChooseChainPage.js.map +1 -1
- package/dist/web/components/ChooseOptionPage.d.ts +3 -1
- package/dist/web/components/ChooseOptionPage.d.ts.map +1 -1
- package/dist/web/components/ChooseOptionPage.js +31 -11
- package/dist/web/components/ChooseOptionPage.js.map +1 -1
- package/dist/web/components/ChooseWalletPage.d.ts +2 -1
- package/dist/web/components/ChooseWalletPage.d.ts.map +1 -1
- package/dist/web/components/ChooseWalletPage.js +9 -7
- package/dist/web/components/ChooseWalletPage.js.map +1 -1
- package/dist/web/components/ConfirmationPage.d.ts +6 -3
- package/dist/web/components/ConfirmationPage.d.ts.map +1 -1
- package/dist/web/components/ConfirmationPage.js +11 -9
- package/dist/web/components/ConfirmationPage.js.map +1 -1
- package/dist/web/components/DaimoModal.js +25 -18
- package/dist/web/components/DaimoModal.js.map +1 -1
- package/dist/web/components/DeeplinkPage.d.ts +2 -1
- package/dist/web/components/DeeplinkPage.d.ts.map +1 -1
- package/dist/web/components/DeeplinkPage.js +3 -3
- package/dist/web/components/DeeplinkPage.js.map +1 -1
- package/dist/web/components/ExchangePage.d.ts +2 -1
- package/dist/web/components/ExchangePage.d.ts.map +1 -1
- package/dist/web/components/ExchangePage.js +2 -2
- package/dist/web/components/ExchangePage.js.map +1 -1
- package/dist/web/components/SelectAmountPage.d.ts +2 -1
- package/dist/web/components/SelectAmountPage.d.ts.map +1 -1
- package/dist/web/components/SelectAmountPage.js +3 -3
- package/dist/web/components/SelectAmountPage.js.map +1 -1
- package/dist/web/components/SelectTokenPage.d.ts +2 -1
- package/dist/web/components/SelectTokenPage.d.ts.map +1 -1
- package/dist/web/components/SelectTokenPage.js +8 -13
- package/dist/web/components/SelectTokenPage.js.map +1 -1
- package/dist/web/components/WaitingDepositAddressPage.d.ts +2 -1
- package/dist/web/components/WaitingDepositAddressPage.d.ts.map +1 -1
- package/dist/web/components/WaitingDepositAddressPage.js +9 -9
- package/dist/web/components/WaitingDepositAddressPage.js.map +1 -1
- package/dist/web/components/WalletAmountPage.d.ts +2 -1
- package/dist/web/components/WalletAmountPage.d.ts.map +1 -1
- package/dist/web/components/WalletAmountPage.js +14 -11
- package/dist/web/components/WalletAmountPage.js.map +1 -1
- package/dist/web/components/buttons.d.ts.map +1 -1
- package/dist/web/components/buttons.js +4 -8
- package/dist/web/components/buttons.js.map +1 -1
- package/dist/web/components/containers.d.ts.map +1 -1
- package/dist/web/components/containers.js +7 -9
- package/dist/web/components/containers.js.map +1 -1
- package/dist/web/components/icons.d.ts +3 -1
- package/dist/web/components/icons.d.ts.map +1 -1
- package/dist/web/components/icons.js +9 -5
- package/dist/web/components/icons.js.map +1 -1
- package/dist/web/components/shared.d.ts +30 -8
- package/dist/web/components/shared.d.ts.map +1 -1
- package/dist/web/components/shared.js +48 -23
- package/dist/web/components/shared.js.map +1 -1
- package/dist/web/containers.d.ts +19 -0
- package/dist/web/containers.d.ts.map +1 -0
- package/dist/web/containers.js +77 -0
- package/dist/web/containers.js.map +1 -0
- package/dist/web/hooks/locales/en.d.ts +2 -0
- package/dist/web/hooks/locales/en.d.ts.map +1 -1
- package/dist/web/hooks/locales/en.js +10 -8
- package/dist/web/hooks/locales/en.js.map +1 -1
- package/dist/web/hooks/locales/es.d.ts.map +1 -1
- package/dist/web/hooks/locales/es.js +2 -0
- package/dist/web/hooks/locales/es.js.map +1 -1
- package/dist/web/hooks/types.d.ts +1 -0
- package/dist/web/hooks/types.d.ts.map +1 -1
- package/dist/web/hooks/types.js.map +1 -1
- package/dist/web/hooks/useInjectedWallets.d.ts +4 -1
- package/dist/web/hooks/useInjectedWallets.d.ts.map +1 -1
- package/dist/web/hooks/useInjectedWallets.js +123 -28
- package/dist/web/hooks/useInjectedWallets.js.map +1 -1
- package/dist/web/hooks/useSessionNav.d.ts.map +1 -1
- package/dist/web/hooks/useSessionNav.js +73 -33
- package/dist/web/hooks/useSessionNav.js.map +1 -1
- package/dist/web/hooks/useWalletFlow.d.ts +5 -4
- package/dist/web/hooks/useWalletFlow.d.ts.map +1 -1
- package/dist/web/hooks/useWalletFlow.js +75 -39
- package/dist/web/hooks/useWalletFlow.js.map +1 -1
- package/dist/web/hooks/walletProvider.d.ts +10 -2
- package/dist/web/hooks/walletProvider.d.ts.map +1 -1
- package/dist/web/hooks/walletProvider.js +69 -7
- package/dist/web/hooks/walletProvider.js.map +1 -1
- package/dist/web/icons.d.ts +22 -0
- package/dist/web/icons.d.ts.map +1 -0
- package/dist/web/icons.js +33 -0
- package/dist/web/icons.js.map +1 -0
- package/dist/web/index.d.ts +0 -1
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +0 -1
- package/dist/web/index.js.map +1 -1
- package/dist/web/shared.d.ts +93 -0
- package/dist/web/shared.d.ts.map +1 -0
- package/dist/web/shared.js +202 -0
- package/dist/web/shared.js.map +1 -0
- package/dist/web/styles.css +1 -1
- package/dist/web/theme.css +19 -18
- package/dist/web/useCopyToClipboard.d.ts +6 -0
- package/dist/web/useCopyToClipboard.d.ts.map +1 -0
- package/dist/web/useCopyToClipboard.js +20 -0
- package/dist/web/useCopyToClipboard.js.map +1 -0
- package/dist/web/useWalletFlow.d.ts +23 -0
- package/dist/web/useWalletFlow.d.ts.map +1 -0
- package/dist/web/useWalletFlow.js +334 -0
- package/dist/web/useWalletFlow.js.map +1 -0
- package/dist/web/walletProvider.d.ts +34 -0
- package/dist/web/walletProvider.d.ts.map +1 -0
- package/dist/web/walletProvider.js +14 -0
- package/dist/web/walletProvider.js.map +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { isSessionActive } from "../common/legacy/session.js";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useDaimoClient } from "./DaimoClientContext.js";
|
|
4
|
+
import { createNavLogger } from "./navEvent.js";
|
|
5
|
+
const POLL_INTERVAL_MS = 3000;
|
|
6
|
+
/**
|
|
7
|
+
* Polls session status from the server while modal is open until terminal.
|
|
8
|
+
* Terminal = expired or completed.
|
|
9
|
+
*/
|
|
10
|
+
export function useSessionPolling(initialSession, isOpen) {
|
|
11
|
+
const client = useDaimoClient();
|
|
12
|
+
const logNavEvent = createNavLogger(client);
|
|
13
|
+
const [session, setSession] = useState(initialSession);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (session.status === "expired") {
|
|
16
|
+
logNavEvent(session.sessionId, {
|
|
17
|
+
nodeId: null,
|
|
18
|
+
nodeType: null,
|
|
19
|
+
action: "session_expired",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
else if (session.status === "completed") {
|
|
23
|
+
logNavEvent(session.sessionId, {
|
|
24
|
+
nodeId: null,
|
|
25
|
+
nodeType: null,
|
|
26
|
+
action: "session_completed",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else if (session.status === "bounced") {
|
|
30
|
+
logNavEvent(session.sessionId, {
|
|
31
|
+
nodeId: null,
|
|
32
|
+
nodeType: null,
|
|
33
|
+
action: "session_bounced",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}, [session.status, session.sessionId]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const daAddr = session.receivers.evm.address;
|
|
39
|
+
if (!isOpen || !isSessionActive(session.status) || !daAddr)
|
|
40
|
+
return;
|
|
41
|
+
const poll = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const updated = await client.pollSession({
|
|
44
|
+
sessionId: session.sessionId,
|
|
45
|
+
daAddr,
|
|
46
|
+
});
|
|
47
|
+
setSession((prev) => ({
|
|
48
|
+
...prev,
|
|
49
|
+
status: updated.status,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error("failed to poll session:", error);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const interval = setInterval(poll, POLL_INTERVAL_MS);
|
|
57
|
+
return () => clearInterval(interval);
|
|
58
|
+
}, [isOpen, session]);
|
|
59
|
+
return { session, setSession };
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=useSessionPolling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSessionPolling.js","sourceRoot":"","sources":["../../src/hooks/useSessionPolling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MA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;QAC7C,IAAI,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEnE,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;YACtB,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;oBACvC,SAAS,EAAE,OAAO,CAAC,SAAS;oBAC5B,MAAM;iBACP,CAAC,CAAC;gBACH,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBACpB,GAAG,IAAI;oBACP,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB,CAAC,CAAC,CAAC;YACN,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAClD,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QACrD,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEtB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NavNodeChooseOption } from "../common/legacy/session.js";
|
|
2
|
+
type ChooseOptionPageProps = {
|
|
3
|
+
node: NavNodeChooseOption;
|
|
4
|
+
onNavigate: (nodeId: string) => void;
|
|
5
|
+
onBack: (() => void) | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function ChooseOptionPage({ node, onNavigate, onBack, }: ChooseOptionPageProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=ChooseOptionPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChooseOptionPage.d.ts","sourceRoot":"","sources":["../../src/web/ChooseOptionPage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAK3E,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;CAC7B,CAAC;AAQF,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,UAAU,EACV,MAAM,GACP,EAAE,qBAAqB,2CAqDvB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { t } from "../hooks/locale.js";
|
|
3
|
+
import { PageHeader, resolveIconUrl } from "./shared.js";
|
|
4
|
+
/** Max visible rows before scrolling */
|
|
5
|
+
const MAX_VISIBLE_ROWS = 4;
|
|
6
|
+
/** Row height (h-16 = 64px) + gap (gap-3 = 12px) */
|
|
7
|
+
const ROW_HEIGHT = 64;
|
|
8
|
+
const ROW_GAP = 12;
|
|
9
|
+
export function ChooseOptionPage({ node, onNavigate, onBack, }) {
|
|
10
|
+
const useGridLayout = node.layout === "grid";
|
|
11
|
+
const isRootPage = onBack === null;
|
|
12
|
+
// Calculate max height for list layout (4 rows + 3 gaps)
|
|
13
|
+
const needsScroll = !useGridLayout && node.options.length > MAX_VISIBLE_ROWS;
|
|
14
|
+
const maxListHeight = MAX_VISIBLE_ROWS * ROW_HEIGHT + (MAX_VISIBLE_ROWS - 1) * ROW_GAP;
|
|
15
|
+
return (_jsxs("div", { className: "flex flex-col flex-1 min-h-0", children: [_jsx(PageHeader, { title: node.title, onBack: onBack }), useGridLayout ? (_jsx("div", { className: "flex-1 overflow-y-auto scroll-fade px-6 pb-4", children: _jsx("div", { className: "grid grid-cols-4 gap-2", children: node.options.map((option) => (_jsx(GridOptionCell, { option: option, onClick: () => onNavigate(option.id) }, option.id))) }) })) : (_jsx("div", { className: "px-6 pb-4", children: _jsx("div", { className: `flex flex-col gap-3 ${needsScroll ? "overflow-y-auto scroll-fade" : ""}`, style: needsScroll ? { maxHeight: maxListHeight } : undefined, children: node.options.map((option) => (_jsx(OptionRow, { option: option, onClick: () => onNavigate(option.id) }, option.id))) }) })), isRootPage && (_jsx("div", { className: "py-4 text-center", children: _jsx("span", { className: "text-sm text-[var(--daimo-text-muted)]", children: t.poweredByDaimo }) }))] }));
|
|
16
|
+
}
|
|
17
|
+
function GridOptionCell({ option, onClick, }) {
|
|
18
|
+
const icons = getOptionIcons(option);
|
|
19
|
+
const label = option.label ?? option.title;
|
|
20
|
+
return (_jsxs("button", { onClick: onClick, className: "flex flex-col items-center gap-2 p-1 rounded-[var(--daimo-radius-md)] hover:[@media(hover:hover)]:bg-[var(--daimo-surface-secondary)] transition-colors min-w-0", children: [icons.length > 0 && (_jsx("img", { src: resolveIconUrl(icons[0]), alt: label, className: "w-full aspect-square max-w-16 object-contain rounded-[25%]" })), _jsx("span", { className: "text-xs font-medium text-[var(--daimo-text)] text-center leading-tight", children: label })] }));
|
|
21
|
+
}
|
|
22
|
+
function OptionRow({ option, onClick, }) {
|
|
23
|
+
const label = option.label ?? option.title;
|
|
24
|
+
return (_jsxs("button", { onClick: onClick, className: "w-full h-16 shrink-0 flex items-center justify-between px-5 rounded-[var(--daimo-radius-lg)] bg-[var(--daimo-surface-secondary)] hover:[@media(hover:hover)]:bg-[var(--daimo-surface-hover)] transition-colors text-left", children: [_jsx("span", { className: "text-[var(--daimo-text)] font-semibold", children: label }), _jsx(OptionIcons, { option: option })] }));
|
|
25
|
+
}
|
|
26
|
+
/** Get icons array for an option: explicit icons[], single icon, or empty */
|
|
27
|
+
function getOptionIcons(option) {
|
|
28
|
+
if (option.icons && option.icons.length > 0) {
|
|
29
|
+
return option.icons;
|
|
30
|
+
}
|
|
31
|
+
if ("icon" in option && option.icon) {
|
|
32
|
+
return [option.icon];
|
|
33
|
+
}
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
/** Render icons for a list row option */
|
|
37
|
+
function OptionIcons({ option }) {
|
|
38
|
+
const icons = getOptionIcons(option);
|
|
39
|
+
if (icons.length === 0)
|
|
40
|
+
return null;
|
|
41
|
+
// 2x2 grid for 4+ icons
|
|
42
|
+
if (icons.length >= 4) {
|
|
43
|
+
return (_jsx("div", { className: "w-8 h-8 grid grid-cols-2 gap-0.5", children: icons.slice(0, 4).map((icon, i) => (_jsx("img", { src: resolveIconUrl(icon), alt: "", className: "w-[15px] h-[15px] object-contain rounded-[25%]" }, i))) }));
|
|
44
|
+
}
|
|
45
|
+
// Stacked overlapped icons for <4
|
|
46
|
+
return (_jsx("div", { className: "flex items-center", children: icons.map((icon, i) => (_jsx("img", { src: resolveIconUrl(icon), alt: "", className: "w-8 h-8 object-contain rounded-[25%] relative", style: {
|
|
47
|
+
marginLeft: i > 0 ? -10 : 0,
|
|
48
|
+
zIndex: icons.length - i,
|
|
49
|
+
} }, i))) }));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=ChooseOptionPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChooseOptionPage.js","sourceRoot":"","sources":["../../src/web/ChooseOptionPage.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQzD,wCAAwC;AACxC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,oDAAoD;AACpD,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB,MAAM,UAAU,gBAAgB,CAAC,EAC/B,IAAI,EACJ,UAAU,EACV,MAAM,GACgB;IACtB,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC;IAC7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IACvB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,yCAAyC;AACzC,SAAS,WAAW,CAAC,EAAE,MAAM,EAAuB;IAClD,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEpC,wBAAwB;IACxB,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,CACL,cAAK,SAAS,EAAC,kCAAkC,YAC9C,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAClC,cAEE,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,EACzB,GAAG,EAAC,EAAE,EACN,SAAS,EAAC,gDAAgD,IAHrD,CAAC,CAIN,CACH,CAAC,GACE,CACP,CAAC;IACJ,CAAC;IAED,kCAAkC;IAClC,OAAO,CACL,cAAK,SAAS,EAAC,mBAAmB,YAC/B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CACtB,cAEE,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,EACzB,GAAG,EAAC,EAAE,EACN,SAAS,EAAC,+CAA+C,EACzD,KAAK,EAAE;gBACL,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC3B,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;aACzB,IAPI,CAAC,CAQN,CACH,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SessionStatus } from "../common/legacy/session.js";
|
|
2
|
+
type ConfirmationPageProps = {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
/** Session state - drives confirmation status */
|
|
5
|
+
sessionState?: SessionStatus;
|
|
6
|
+
/** Source token chain ID (what user is paying with) */
|
|
7
|
+
sourceChainId?: number;
|
|
8
|
+
/** Source token symbol (what user is paying with) */
|
|
9
|
+
sourceTokenSymbol?: string;
|
|
10
|
+
/** Source token logo URI */
|
|
11
|
+
sourceTokenLogoURI?: string;
|
|
12
|
+
/** Amount in USD being sent */
|
|
13
|
+
sourceAmountUsd?: number;
|
|
14
|
+
/** Pending tx hash - set after wallet confirms but before onchain detection */
|
|
15
|
+
pendingTxHash?: string;
|
|
16
|
+
returnUrl?: string;
|
|
17
|
+
/** Secondary message to show when done (only for session page, not modal) */
|
|
18
|
+
returnLabel?: string;
|
|
19
|
+
/** Back handler - only shown during "confirming" state */
|
|
20
|
+
onBack?: () => void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Confirmation page showing payment progress.
|
|
24
|
+
* - confirming: Wallet popup open, show source token icon
|
|
25
|
+
* - waiting: Tx submitted, show source token icon
|
|
26
|
+
* - processing: Fulfillment STARTED, show spinner
|
|
27
|
+
* - done: Fulfillment COMPLETED, show green checkmark
|
|
28
|
+
* - refunding: Payment bounced, show spinner (future use)
|
|
29
|
+
*/
|
|
30
|
+
export declare function ConfirmationPage({ sessionId, sessionState, sourceChainId, sourceTokenSymbol, sourceTokenLogoURI, sourceAmountUsd, pendingTxHash, returnUrl, returnLabel, onBack, }: ConfirmationPageProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=ConfirmationPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmationPage.d.ts","sourceRoot":"","sources":["../../src/web/ConfirmationPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAkB5D,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4BAA4B;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,+BAA+B;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,SAAS,EACT,WAAW,EACX,MAAM,GACP,EAAE,qBAAqB,2CAyFvB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getChainName } from "../common/chain.js";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { ConfirmationSpinner } from "./ConfirmationSpinner.js";
|
|
5
|
+
import { t } from "../hooks/locale.js";
|
|
6
|
+
import { PageHeader, ShowReceiptButton, TokenIconWithChainBadge, } from "./shared.js";
|
|
7
|
+
/**
|
|
8
|
+
* Confirmation page showing payment progress.
|
|
9
|
+
* - confirming: Wallet popup open, show source token icon
|
|
10
|
+
* - waiting: Tx submitted, show source token icon
|
|
11
|
+
* - processing: Fulfillment STARTED, show spinner
|
|
12
|
+
* - done: Fulfillment COMPLETED, show green checkmark
|
|
13
|
+
* - refunding: Payment bounced, show spinner (future use)
|
|
14
|
+
*/
|
|
15
|
+
export function ConfirmationPage({ sessionId, sessionState, sourceChainId, sourceTokenSymbol, sourceTokenLogoURI, sourceAmountUsd, pendingTxHash, returnUrl, returnLabel, onBack, }) {
|
|
16
|
+
const status = getConfirmationStatus(pendingTxHash, sessionState);
|
|
17
|
+
// For processing status: show "Payment received" then change after 2s
|
|
18
|
+
const [processingMessage, setProcessingMessage] = useState(t.paymentReceived);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (status === "processing") {
|
|
21
|
+
const timer = setTimeout(() => {
|
|
22
|
+
setProcessingMessage(t.processingYourPayment);
|
|
23
|
+
}, 2000);
|
|
24
|
+
return () => clearTimeout(timer);
|
|
25
|
+
}
|
|
26
|
+
}, [status]);
|
|
27
|
+
// Show source token info (amount, chain) when we have basic data
|
|
28
|
+
const showSourceInfo = (status === "confirming" || status === "waiting") &&
|
|
29
|
+
sourceChainId != null &&
|
|
30
|
+
sourceTokenSymbol != null;
|
|
31
|
+
// Show token icon only when we also have a logo URI
|
|
32
|
+
const showSourceIcon = showSourceInfo && sourceTokenLogoURI != null;
|
|
33
|
+
// Show back button only during confirming (before tx submitted)
|
|
34
|
+
const showBack = status === "confirming" && onBack != null;
|
|
35
|
+
// Get display title based on status
|
|
36
|
+
const displayTitle = getDisplayTitle(status, processingMessage);
|
|
37
|
+
// Chain name for display
|
|
38
|
+
const chainName = sourceChainId ? getChainName(sourceChainId) : "";
|
|
39
|
+
return (_jsxs("div", { className: "flex flex-col flex-1 min-h-0", children: [_jsx(PageHeader, { onBack: showBack ? onBack : undefined, title: displayTitle }), _jsxs("div", { className: "flex-1 flex flex-col items-center justify-center p-6 gap-4", children: [showSourceIcon && (_jsx(TokenIconWithChainBadge, { chainId: sourceChainId, symbol: sourceTokenSymbol, logoURI: sourceTokenLogoURI, size: "lg" })), status !== "confirming" && status !== "waiting" && (_jsx(ConfirmationSpinner, { done: status === "done" })), showSourceInfo && (_jsxs("div", { className: "text-center", children: [_jsx("p", { className: "text-3xl font-semibold text-[var(--daimo-text)] tabular-nums", children: sourceAmountUsd != null
|
|
40
|
+
? `$${sourceAmountUsd.toFixed(2)} ${sourceTokenSymbol}`
|
|
41
|
+
: sourceTokenSymbol }), _jsxs("p", { className: "text-lg text-[var(--daimo-text-secondary)]", children: [t.onChain, " ", chainName] })] })), status === "done" && returnUrl && (_jsx("a", { href: returnUrl, className: "w-full max-w-xs min-h-[44px] py-4 px-6 rounded-[var(--daimo-radius-lg)] font-semibold bg-[var(--daimo-surface-secondary)] text-[var(--daimo-text)] hover:[@media(hover:hover)]:bg-[var(--daimo-surface-hover)] active:scale-[0.97] touch-action-manipulation transition-[background-color,transform] duration-150 ease-out text-center flex items-center justify-center", children: t.returnToApp })), status === "done" && !returnUrl && returnLabel && (_jsx("p", { className: "text-center text-[var(--daimo-text-secondary)] px-8 whitespace-pre-line", children: returnLabel })), (status === "waiting" ||
|
|
42
|
+
status === "processing" ||
|
|
43
|
+
status === "done") && _jsx(ShowReceiptButton, { sessionId: sessionId })] })] }));
|
|
44
|
+
}
|
|
45
|
+
/** Derive UI status from session state and pending tx hash */
|
|
46
|
+
function getConfirmationStatus(pendingTxHash, sessionState) {
|
|
47
|
+
if (sessionState === "processing")
|
|
48
|
+
return "processing";
|
|
49
|
+
if (sessionState === "completed")
|
|
50
|
+
return "done";
|
|
51
|
+
if (sessionState === "bounced")
|
|
52
|
+
return "refunding";
|
|
53
|
+
if (pendingTxHash)
|
|
54
|
+
return "waiting";
|
|
55
|
+
return "confirming";
|
|
56
|
+
}
|
|
57
|
+
/** Get display title for status */
|
|
58
|
+
function getDisplayTitle(status, processingMessage) {
|
|
59
|
+
switch (status) {
|
|
60
|
+
case "confirming":
|
|
61
|
+
return t.confirmYourPayment;
|
|
62
|
+
case "waiting":
|
|
63
|
+
return t.waitingForYourPayment;
|
|
64
|
+
case "processing":
|
|
65
|
+
return processingMessage;
|
|
66
|
+
case "done":
|
|
67
|
+
return t.paymentCompleted;
|
|
68
|
+
case "refunding":
|
|
69
|
+
return t.refundingYourPayment;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=ConfirmationPage.js.map
|
|
@@ -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,EAAC,yWAAyW,YAElX,CAAC,CAAC,WAAW,GACZ,CACL,EAEA,MAAM,KAAK,MAAM,IAAI,CAAC,SAAS,IAAI,WAAW,IAAI,CACjD,YAAG,SAAS,EAAC,yEAAyE,YACnF,WAAW,GACV,CACL,EAGA,CAAC,MAAM,KAAK,SAAS;wBACpB,MAAM,KAAK,YAAY;wBACvB,MAAM,KAAK,MAAM,CAAC,IAAI,KAAC,iBAAiB,IAAC,SAAS,EAAE,SAAS,GAAI,IAC/D,IACF,CACP,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,SAAS,qBAAqB,CAC5B,aAAiC,EACjC,YAAuC;IAEvC,IAAI,YAAY,KAAK,YAAY;QAAE,OAAO,YAAY,CAAC;IACvD,IAAI,YAAY,KAAK,WAAW;QAAE,OAAO,MAAM,CAAC;IAChD,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC;IACnD,IAAI,aAAa;QAAE,OAAO,SAAS,CAAC;IACpC,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,mCAAmC;AACnC,SAAS,eAAe,CACtB,MAA0B,EAC1B,iBAAyB;IAEzB,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,YAAY;YACf,OAAO,CAAC,CAAC,kBAAkB,CAAC;QAC9B,KAAK,SAAS;YACZ,OAAO,CAAC,CAAC,qBAAqB,CAAC;QACjC,KAAK,YAAY;YACf,OAAO,iBAAiB,CAAC;QAC3B,KAAK,MAAM;YACT,OAAO,CAAC,CAAC,gBAAgB,CAAC;QAC5B,KAAK,WAAW;YACd,OAAO,CAAC,CAAC,oBAAoB,CAAC;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type ConfirmationSpinnerProps = {
|
|
2
|
+
done: boolean;
|
|
3
|
+
};
|
|
4
|
+
/** Spinner → checkmark transition for payment confirmation. */
|
|
5
|
+
export declare function ConfirmationSpinner({ done }: ConfirmationSpinnerProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=ConfirmationSpinner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmationSpinner.d.ts","sourceRoot":"","sources":["../../src/web/ConfirmationSpinner.tsx"],"names":[],"mappings":"AAAA,KAAK,wBAAwB,GAAG;IAC9B,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,+DAA+D;AAC/D,wBAAgB,mBAAmB,CAAC,EAAE,IAAI,EAAE,EAAE,wBAAwB,2CAyBrE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** Spinner → checkmark transition for payment confirmation. */
|
|
3
|
+
export function ConfirmationSpinner({ done }) {
|
|
4
|
+
return (_jsx("div", { className: "relative w-[100px] h-[100px]", children: _jsxs("div", { className: "absolute inset-[6px] rounded-full flex items-center justify-center overflow-hidden", style: { backgroundColor: "var(--daimo-bg)" }, children: [_jsx(LoadingCircle, { className: `absolute w-full h-full transition-opacity duration-200 ${done ? "opacity-0" : "opacity-100"}`, spinning: !done }), _jsx(TickIcon, { className: `absolute w-full h-full transition-[opacity,transform] duration-200 ${done ? "opacity-100 scale-100" : "opacity-0 scale-50"}`, style: { color: "var(--daimo-checkmark)" } })] }) }));
|
|
5
|
+
}
|
|
6
|
+
function LoadingCircle({ className, spinning, }) {
|
|
7
|
+
return (_jsxs("svg", { className: className, style: {
|
|
8
|
+
color: "var(--daimo-accent)",
|
|
9
|
+
animation: spinning ? "spin 400ms linear infinite" : "none",
|
|
10
|
+
}, viewBox: "0 0 100 100", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: [_jsx("style", { children: `
|
|
11
|
+
@keyframes spin {
|
|
12
|
+
from { transform: rotate(0deg); }
|
|
13
|
+
to { transform: rotate(360deg); }
|
|
14
|
+
}
|
|
15
|
+
` }), _jsx("circle", { cx: "50", cy: "50", r: "50", fill: "currentColor", fillOpacity: "0.15" }), _jsx("circle", { cx: "50", cy: "50", r: "30", stroke: "currentColor", strokeOpacity: "0.4", strokeWidth: "16" }), _jsx("path", { d: "M50 20V20C66.5685 20 80 33.4315 80 50V50", stroke: "currentColor", strokeWidth: "16", strokeLinecap: "round", strokeLinejoin: "round" })] }));
|
|
16
|
+
}
|
|
17
|
+
function TickIcon({ className, style, }) {
|
|
18
|
+
return (_jsx("svg", { className: className, style: style, viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9 18C13.9706 18 18 13.9706 18 9C18 4.02944 13.9706 0 9 0C4.02944 0 0 4.02944 0 9C0 13.9706 4.02944 18 9 18ZM13.274 7.13324C13.6237 6.70579 13.5607 6.07577 13.1332 5.72604C12.7058 5.37632 12.0758 5.43932 11.726 5.86676L7.92576 10.5115L6.20711 8.79289C5.81658 8.40237 5.18342 8.40237 4.79289 8.79289C4.40237 9.18342 4.40237 9.81658 4.79289 10.2071L7.29289 12.7071C7.49267 12.9069 7.76764 13.0128 8.04981 12.9988C8.33199 12.9847 8.59505 12.8519 8.77396 12.6332L13.274 7.13324Z", fill: "currentColor" }) }));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ConfirmationSpinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmationSpinner.js","sourceRoot":"","sources":["../../src/web/ConfirmationSpinner.tsx"],"names":[],"mappings":";AAIA,+DAA+D;AAC/D,MAAM,UAAU,mBAAmB,CAAC,EAAE,IAAI,EAA4B;IACpE,OAAO,CACL,cAAK,SAAS,EAAC,8BAA8B,YAC3C,eACE,SAAS,EAAC,oFAAoF,EAC9F,KAAK,EAAE,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAG7C,KAAC,aAAa,IACZ,SAAS,EAAE,0DACT,IAAI,CAAC,CAAC,CAAC,WAAW,CA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ACtB,MAAM,YAElB,eACE,QAAQ,EAAC,SAAS,EAClB,QAAQ,EAAC,SAAS,EAClB,CAAC,EAAC,4dAA4d,EAC9d,IAAI,EAAC,cAAc,GACnB,GACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ModalSession } from "../common/legacy/session.js";
|
|
2
|
+
import { type DaimoModalEventHandlers } from "../hooks/types.js";
|
|
3
|
+
export type DaimoModalProps = DaimoModalEventHandlers & {
|
|
4
|
+
session: ModalSession | null;
|
|
5
|
+
defaultOpen?: boolean;
|
|
6
|
+
connectedWalletOnly?: boolean;
|
|
7
|
+
embedded?: boolean;
|
|
8
|
+
animate?: boolean;
|
|
9
|
+
maxHeight?: number;
|
|
10
|
+
platform?: "ios" | "android" | "other";
|
|
11
|
+
returnUrl?: string;
|
|
12
|
+
returnLabel?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function DaimoModal(props: DaimoModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
//# sourceMappingURL=DaimoModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DaimoModal.d.ts","sourceRoot":"","sources":["../../src/web/DaimoModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAQb,MAAM,6BAA6B,CAAC;AAWrC,OAAO,EACL,KAAK,uBAAuB,EAG7B,MAAM,mBAAmB,CAAC;AAmB3B,MAAM,MAAM,eAAe,GAAG,uBAAuB,GAAG;IACtD,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AA4BF,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,kDA6BhD"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { tron } from "../common/chain.js";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { formatUserError } from "../hooks/formatUserError.js";
|
|
5
|
+
import { t } from "../hooks/locale.js";
|
|
6
|
+
import { createNavLogger } from "../hooks/navEvent.js";
|
|
7
|
+
import { usePaymentCallbacks } from "../hooks/usePaymentCallbacks.js";
|
|
8
|
+
import { useSessionNav } from "../hooks/useSessionNav.js";
|
|
9
|
+
import { useSessionPolling } from "../hooks/useSessionPolling.js";
|
|
10
|
+
import { useDaimoClient } from "../hooks/DaimoClientContext.js";
|
|
11
|
+
import { findNode, } from "../hooks/types.js";
|
|
12
|
+
import { PrimaryButton } from "./buttons.js";
|
|
13
|
+
import { ChooseOptionPage } from "./ChooseOptionPage.js";
|
|
14
|
+
import { ConfirmationPage } from "./ConfirmationPage.js";
|
|
15
|
+
import { EmbeddedContainer, ModalContainer } from "./containers.js";
|
|
16
|
+
import { DeeplinkPage } from "./DeeplinkPage.js";
|
|
17
|
+
import { ExchangePage } from "./ExchangePage.js";
|
|
18
|
+
import { ExpiredPage } from "./ExpiredPage.js";
|
|
19
|
+
import { SelectAmountPage } from "./SelectAmountPage.js";
|
|
20
|
+
import { SelectTokenPage } from "./SelectTokenPage.js";
|
|
21
|
+
import { ContactSupportButton, ErrorMessage as SharedErrorMessage, } from "./shared.js";
|
|
22
|
+
import { useWalletFlow, isUserRejection } from "./useWalletFlow.js";
|
|
23
|
+
import { WaitingDepositAddressPage } from "./WaitingDepositAddressPage.js";
|
|
24
|
+
import { WalletAmountPage } from "./WalletAmountPage.js";
|
|
25
|
+
function useModalCloseHandler(sessionId, getNodeCtx, isOpen, setIsOpen, onClose) {
|
|
26
|
+
const client = useDaimoClient();
|
|
27
|
+
const logNavEvent = createNavLogger(client);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!isOpen)
|
|
30
|
+
return;
|
|
31
|
+
logNavEvent(sessionId, { ...getNodeCtx(), action: "nav_open" });
|
|
32
|
+
}, [isOpen, sessionId, getNodeCtx]);
|
|
33
|
+
const handleClose = useCallback(() => {
|
|
34
|
+
logNavEvent(sessionId, { ...getNodeCtx(), action: "nav_close" });
|
|
35
|
+
setIsOpen(false);
|
|
36
|
+
onClose?.();
|
|
37
|
+
}, [sessionId, getNodeCtx, setIsOpen, onClose]);
|
|
38
|
+
return { handleClose };
|
|
39
|
+
}
|
|
40
|
+
export function DaimoModal(props) {
|
|
41
|
+
const { session, embedded = false, animate = true, defaultOpen = true, maxHeight, } = props;
|
|
42
|
+
const [isOpen, setIsOpen] = useState(defaultOpen);
|
|
43
|
+
if (!session) {
|
|
44
|
+
if (!isOpen)
|
|
45
|
+
return null;
|
|
46
|
+
const skeleton = _jsx(SkeletonContent, {});
|
|
47
|
+
if (embedded)
|
|
48
|
+
return _jsx(EmbeddedContainer, { children: skeleton });
|
|
49
|
+
return (_jsx(ModalContainer, { animate: animate, maxHeight: maxHeight, children: skeleton }));
|
|
50
|
+
}
|
|
51
|
+
return (_jsx(DaimoModalInner, { ...props, session: session, isOpen: isOpen, setIsOpen: setIsOpen }));
|
|
52
|
+
}
|
|
53
|
+
const CONNECTED_WALLET_NAV = [
|
|
54
|
+
{ type: "ConnectedWallet", id: "ConnectedWallet", title: "Connected Wallet" },
|
|
55
|
+
];
|
|
56
|
+
function DaimoModalInner({ session: initialSession, isOpen, setIsOpen, connectedWalletOnly = false, embedded = false, animate = true, maxHeight, platform, returnUrl, returnLabel, onPaymentStarted, onPaymentCompleted, onOpen, onClose, }) {
|
|
57
|
+
const effectiveInitial = connectedWalletOnly
|
|
58
|
+
? { ...initialSession, navTree: CONNECTED_WALLET_NAV }
|
|
59
|
+
: initialSession;
|
|
60
|
+
const { session, setSession } = useSessionPolling(effectiveInitial, isOpen);
|
|
61
|
+
const nav = useSessionNav(session, setSession, platform);
|
|
62
|
+
const hasConnectedWallet = session.navTree.some((n) => n.type === "ConnectedWallet");
|
|
63
|
+
const walletFlow = useWalletFlow(session.sessionId, session.receivers.evm.address, hasConnectedWallet);
|
|
64
|
+
const autoNavRef = useRef(null);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!isOpen)
|
|
67
|
+
return;
|
|
68
|
+
if (nav.topEntry &&
|
|
69
|
+
nav.topEntry.type !== "choose-option" &&
|
|
70
|
+
nav.topEntry.type !== "deeplink") {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const currentNodeId = nav.topEntry?.nodeId;
|
|
74
|
+
let node = currentNodeId
|
|
75
|
+
? findNode(currentNodeId, session.navTree)
|
|
76
|
+
: (session.navTree[0] ?? null);
|
|
77
|
+
let targetId = null;
|
|
78
|
+
while (node?.type === "ChooseOption") {
|
|
79
|
+
const chooseNode = node;
|
|
80
|
+
if (chooseNode.options?.length !== 1)
|
|
81
|
+
break;
|
|
82
|
+
targetId = chooseNode.options[0].id;
|
|
83
|
+
node = findNode(targetId, session.navTree);
|
|
84
|
+
}
|
|
85
|
+
if (!targetId && node && node.type !== "ChooseOption") {
|
|
86
|
+
targetId = node.id;
|
|
87
|
+
}
|
|
88
|
+
if (targetId && autoNavRef.current !== targetId) {
|
|
89
|
+
autoNavRef.current = targetId;
|
|
90
|
+
nav.handleNavigate(targetId, { autoNav: true });
|
|
91
|
+
}
|
|
92
|
+
}, [isOpen, nav, session.navTree]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (nav.topEntry?.type !== "wallet-connect")
|
|
95
|
+
return;
|
|
96
|
+
if (walletFlow.isConnecting || !walletFlow.wallet)
|
|
97
|
+
return;
|
|
98
|
+
nav.handleWalletConnected();
|
|
99
|
+
}, [nav.topEntry, walletFlow.wallet, walletFlow.isConnecting, nav]);
|
|
100
|
+
const sendingRef = useRef(null);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (nav.topEntry?.type !== "wallet-sending")
|
|
103
|
+
return;
|
|
104
|
+
if (nav.topEntry.txHash || nav.topEntry.error)
|
|
105
|
+
return;
|
|
106
|
+
const sendKey = `${nav.topEntry.nodeId}-${nav.topEntry.amountUsd}`;
|
|
107
|
+
if (sendingRef.current === sendKey)
|
|
108
|
+
return;
|
|
109
|
+
sendingRef.current = sendKey;
|
|
110
|
+
const { token, amountUsd } = nav.topEntry;
|
|
111
|
+
walletFlow
|
|
112
|
+
.sendTransaction(token, amountUsd)
|
|
113
|
+
.then(({ txHash }) => {
|
|
114
|
+
nav.handleWalletTxResult(txHash);
|
|
115
|
+
sendingRef.current = null;
|
|
116
|
+
})
|
|
117
|
+
.catch((err) => {
|
|
118
|
+
sendingRef.current = null;
|
|
119
|
+
if (isUserRejection(err)) {
|
|
120
|
+
nav.handleBack();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
nav.handleWalletTxResult(undefined, formatUserError(err, t.transactionFailed));
|
|
124
|
+
});
|
|
125
|
+
}, [nav, walletFlow]);
|
|
126
|
+
const { handleClose } = useModalCloseHandler(session.sessionId, nav.getNodeCtx, isOpen, setIsOpen, onClose);
|
|
127
|
+
usePaymentCallbacks(session, isOpen, {
|
|
128
|
+
onOpen,
|
|
129
|
+
onPaymentStarted,
|
|
130
|
+
onPaymentCompleted,
|
|
131
|
+
});
|
|
132
|
+
if (!isOpen)
|
|
133
|
+
return null;
|
|
134
|
+
const isTerminal = session.status === "expired" ||
|
|
135
|
+
session.status === "completed" ||
|
|
136
|
+
session.status === "bounced";
|
|
137
|
+
const pageKey = isTerminal
|
|
138
|
+
? session.status
|
|
139
|
+
: `${nav.topEntry?.type ?? "root"}-${nav.topEntry?.nodeId ?? ""}`;
|
|
140
|
+
const renderInContainer = (content, showFooterSpacer = true) => {
|
|
141
|
+
const page = (_jsx("div", { className: "daimo-page-enter flex-1 min-h-0 flex flex-col", children: content }, pageKey));
|
|
142
|
+
if (embedded) {
|
|
143
|
+
return (_jsx(EmbeddedContainer, { showFooterSpacer: showFooterSpacer, children: page }));
|
|
144
|
+
}
|
|
145
|
+
return (_jsx(ModalContainer, { showFooterSpacer: showFooterSpacer, onClose: handleClose, animate: animate, pageKey: pageKey, maxHeight: maxHeight, children: page }));
|
|
146
|
+
};
|
|
147
|
+
if (session.status === "expired") {
|
|
148
|
+
return renderInContainer(_jsx(ExpiredPage, { onClose: handleClose }));
|
|
149
|
+
}
|
|
150
|
+
if (session.status === "processing" ||
|
|
151
|
+
session.status === "completed" ||
|
|
152
|
+
session.status === "bounced") {
|
|
153
|
+
return renderInContainer(_jsx(ConfirmationPage, { sessionId: session.sessionId, sessionState: session.status, returnUrl: returnUrl, returnLabel: returnLabel }));
|
|
154
|
+
}
|
|
155
|
+
const content = renderEntry(nav.topEntry, {
|
|
156
|
+
session,
|
|
157
|
+
canGoBack: nav.canGoBack,
|
|
158
|
+
onNavigate: nav.handleNavigate,
|
|
159
|
+
onBack: nav.handleBack,
|
|
160
|
+
onAmountContinue: nav.handleAmountContinue,
|
|
161
|
+
onRetry: nav.handleRetry,
|
|
162
|
+
onRefresh: nav.handleRefresh,
|
|
163
|
+
walletFlow,
|
|
164
|
+
onWalletSelectToken: nav.handleWalletSelectToken,
|
|
165
|
+
onWalletSending: nav.handleWalletSending,
|
|
166
|
+
});
|
|
167
|
+
const showFooterSpacer = !(!nav.topEntry ||
|
|
168
|
+
(nav.topEntry.type === "choose-option" && !nav.canGoBack));
|
|
169
|
+
return renderInContainer(content, showFooterSpacer);
|
|
170
|
+
}
|
|
171
|
+
function renderEntry(entry, ctx) {
|
|
172
|
+
if (!entry) {
|
|
173
|
+
const rootNode = ctx.session.navTree[0];
|
|
174
|
+
if (!rootNode)
|
|
175
|
+
return _jsx(LoadingMessage, {});
|
|
176
|
+
if (rootNode.type === "ChooseOption") {
|
|
177
|
+
return (_jsx(ChooseOptionPage, { node: rootNode, onNavigate: ctx.onNavigate, onBack: null }));
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
switch (entry.type) {
|
|
182
|
+
case "choose-option": {
|
|
183
|
+
const node = findNode(entry.nodeId, ctx.session.navTree);
|
|
184
|
+
if (!node)
|
|
185
|
+
return null;
|
|
186
|
+
return (_jsx(ChooseOptionPage, { node: node, onNavigate: ctx.onNavigate, onBack: ctx.canGoBack ? ctx.onBack : null }));
|
|
187
|
+
}
|
|
188
|
+
case "deeplink": {
|
|
189
|
+
const node = findNode(entry.nodeId, ctx.session.navTree);
|
|
190
|
+
if (!node)
|
|
191
|
+
return null;
|
|
192
|
+
return _jsx(DeeplinkPage, { node: node, onBack: ctx.canGoBack ? ctx.onBack : null });
|
|
193
|
+
}
|
|
194
|
+
case "select-amount":
|
|
195
|
+
return renderSelectAmount(entry, ctx);
|
|
196
|
+
case "waiting-deposit":
|
|
197
|
+
return renderWaitingDeposit(entry, ctx);
|
|
198
|
+
case "waiting-tron":
|
|
199
|
+
return renderWaitingTron(entry, ctx);
|
|
200
|
+
case "exchange-page":
|
|
201
|
+
return renderExchangePage(entry, ctx);
|
|
202
|
+
case "wallet-connect":
|
|
203
|
+
return renderWalletConnect(ctx);
|
|
204
|
+
case "wallet-select-token":
|
|
205
|
+
return renderWalletSelectToken(ctx);
|
|
206
|
+
case "wallet-select-amount":
|
|
207
|
+
return renderWalletSelectAmount(entry, ctx);
|
|
208
|
+
case "wallet-sending":
|
|
209
|
+
return renderWalletSending(entry, ctx);
|
|
210
|
+
default:
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function renderSelectAmount(entry, ctx) {
|
|
215
|
+
const node = findNode(entry.nodeId, ctx.session.navTree);
|
|
216
|
+
if (!node)
|
|
217
|
+
return null;
|
|
218
|
+
if (entry.flowType === "deposit") {
|
|
219
|
+
const depositNode = node;
|
|
220
|
+
return (_jsx(SelectAmountPage, { node: depositNode, minimumUsd: depositNode.minimumUsd, maximumUsd: depositNode.maximumUsd, tokenSuffix: depositNode.tokenSuffix, chainId: depositNode.chainId, onBack: ctx.canGoBack ? ctx.onBack : undefined, onContinue: ctx.onAmountContinue }));
|
|
221
|
+
}
|
|
222
|
+
if (entry.flowType === "tron") {
|
|
223
|
+
const tronNode = node;
|
|
224
|
+
return (_jsx(SelectAmountPage, { node: { icon: tronNode.icon, title: tronNode.title }, minimumUsd: tronNode.minimumUsd, maximumUsd: tronNode.maximumUsd, tokenSuffix: "USDT", chainId: tron.chainId, onBack: ctx.canGoBack ? ctx.onBack : undefined, onContinue: ctx.onAmountContinue }));
|
|
225
|
+
}
|
|
226
|
+
if (entry.flowType === "exchange") {
|
|
227
|
+
const exchangeNode = node;
|
|
228
|
+
return (_jsx(SelectAmountPage, { node: { icon: exchangeNode.icon, title: exchangeNode.title }, minimumUsd: exchangeNode.minimumUsd, maximumUsd: exchangeNode.maximumUsd, onBack: ctx.canGoBack ? ctx.onBack : undefined, onContinue: ctx.onAmountContinue }));
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
function renderWaitingDeposit(entry, ctx) {
|
|
233
|
+
const node = findNode(entry.nodeId, ctx.session.navTree);
|
|
234
|
+
if (!node)
|
|
235
|
+
return null;
|
|
236
|
+
const selectedToken = node.tokenSuffix === "USDC" || node.tokenSuffix === "USDT" ? node.tokenSuffix : undefined;
|
|
237
|
+
return _jsx(WaitingDepositAddressPage, { node: node, amountUsd: entry.amountUsd, selectedToken: selectedToken, sessionId: ctx.session.sessionId, onBack: ctx.onBack, onRefresh: ctx.onRefresh });
|
|
238
|
+
}
|
|
239
|
+
function renderWaitingTron(entry, ctx) {
|
|
240
|
+
const node = findNode(entry.nodeId, ctx.session.navTree);
|
|
241
|
+
if (!node)
|
|
242
|
+
return null;
|
|
243
|
+
if (entry.error)
|
|
244
|
+
return _jsx(FlowErrorMessage, { error: entry.error, onBack: ctx.onBack, onRetry: ctx.onRetry });
|
|
245
|
+
return (_jsx(WaitingDepositAddressPage, { node: { type: "DepositAddress", id: entry.nodeId, title: node.title, address: entry.address ?? "", chainId: tron.chainId, icon: node.icon, minimumUsd: node.minimumUsd, maximumUsd: node.maximumUsd, expiresAt: entry.expiresAt ?? 0, tokenSuffix: "USDT" }, amountUsd: entry.amountUsd, selectedToken: "USDT", loading: !entry.address, sessionId: ctx.session.sessionId, onBack: ctx.onBack, onRefresh: ctx.onRetry }));
|
|
246
|
+
}
|
|
247
|
+
function renderExchangePage(entry, ctx) {
|
|
248
|
+
const node = findNode(entry.nodeId, ctx.session.navTree);
|
|
249
|
+
if (!node)
|
|
250
|
+
return null;
|
|
251
|
+
if (entry.error)
|
|
252
|
+
return _jsx(FlowErrorMessage, { error: entry.error, onBack: ctx.onBack, onRetry: ctx.onRetry });
|
|
253
|
+
return _jsx(ExchangePage, { node: node, exchangeUrl: entry.exchangeUrl, waitingMessage: entry.waitingMessage, isLoading: !entry.exchangeUrl, onBack: ctx.onBack });
|
|
254
|
+
}
|
|
255
|
+
function renderWalletConnect(ctx) {
|
|
256
|
+
const { walletFlow } = ctx;
|
|
257
|
+
if (walletFlow.isConnecting)
|
|
258
|
+
return _jsx(LoadingMessage, {});
|
|
259
|
+
return (_jsxs("div", { className: "flex flex-col items-center justify-center flex-1 gap-6 p-6", children: [_jsx(PrimaryButton, { onClick: walletFlow.connect, children: t.connectWallet }), walletFlow.connectError && _jsx(SharedErrorMessage, { message: walletFlow.connectError }), _jsx(ContactSupportButton, { subject: "Wallet connection", info: { sessionId: ctx.session.sessionId, error: walletFlow.connectError ?? t.walletUnavailable } })] }));
|
|
260
|
+
}
|
|
261
|
+
function renderWalletSelectToken(ctx) {
|
|
262
|
+
return _jsx(SelectTokenPage, { options: ctx.walletFlow.balances, isLoading: ctx.walletFlow.isLoadingBalances, onSelect: ctx.onWalletSelectToken });
|
|
263
|
+
}
|
|
264
|
+
function renderWalletSelectAmount(entry, ctx) {
|
|
265
|
+
return _jsx(WalletAmountPage, { token: entry.token, onBack: ctx.onBack, onContinue: (amountUsd) => ctx.onWalletSending(entry.token, amountUsd) });
|
|
266
|
+
}
|
|
267
|
+
function renderWalletSending(entry, ctx) {
|
|
268
|
+
if (entry.error)
|
|
269
|
+
return _jsx(FlowErrorMessage, { error: entry.error, onBack: ctx.onBack, onRetry: ctx.onBack });
|
|
270
|
+
return (_jsx(ConfirmationPage, { sessionId: ctx.session.sessionId, sourceChainId: entry.token.balance.token.chainId, sourceTokenSymbol: entry.token.balance.token.symbol, sourceTokenLogoURI: entry.token.balance.token.logoURI, sourceAmountUsd: entry.amountUsd, pendingTxHash: entry.txHash, onBack: !entry.txHash ? ctx.onBack : undefined }));
|
|
271
|
+
}
|
|
272
|
+
function LoadingMessage() {
|
|
273
|
+
return (_jsx("div", { className: "flex items-center justify-center h-full text-[var(--daimo-text-muted)]", children: t.loading }));
|
|
274
|
+
}
|
|
275
|
+
function FlowErrorMessage({ error, onBack, onRetry }) {
|
|
276
|
+
return (_jsxs("div", { className: "flex flex-col items-center justify-center h-full gap-4 text-[var(--daimo-text-muted)]", children: [_jsx("p", { children: error }), _jsxs("div", { className: "flex gap-2", children: [_jsx("button", { className: "px-4 py-2 rounded-lg bg-[var(--daimo-surface)] hover:bg-[var(--daimo-surface-hover)] transition-colors", onClick: onBack, children: t.back }), _jsx("button", { className: "px-4 py-2 rounded-lg bg-[var(--daimo-primary)] text-white hover:opacity-90 transition-opacity", onClick: onRetry, children: t.tryAgain })] })] }));
|
|
277
|
+
}
|
|
278
|
+
function SkeletonContent({ rowCount = 4 }) {
|
|
279
|
+
const skeletonBg = "var(--daimo-skeleton, #e5e7eb)";
|
|
280
|
+
const radiusLg = "var(--daimo-radius-lg, 16px)";
|
|
281
|
+
return (_jsxs("div", { className: "flex flex-col", children: [_jsx("div", { className: "flex items-center justify-center p-6", children: _jsx("div", { className: "h-5 w-32 rounded animate-pulse", style: { backgroundColor: skeletonBg } }) }), _jsx("div", { className: "px-6 pb-4 flex flex-col gap-3", children: [...Array(rowCount)].map((_, i) => (_jsx("div", { className: "h-16 animate-pulse", style: { backgroundColor: skeletonBg, borderRadius: radiusLg, animationDelay: `${i * 100}ms` } }, i))) }), _jsx("div", { className: "py-4 text-center", children: _jsx("span", { className: "inline-block h-4 w-28 rounded animate-pulse", style: { backgroundColor: skeletonBg } }) })] }));
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=DaimoModal.js.map
|