cilantro-react 0.1.0 → 0.1.1
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/README.md +155 -2
- package/dist/index.d.mts +132 -15
- package/dist/index.d.ts +132 -15
- package/dist/index.js +604 -315
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +535 -253
- package/dist/index.mjs.map +1 -1
- package/dist/themes/default.css +43 -0
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -43,6 +43,8 @@ __export(index_exports, {
|
|
|
43
43
|
SIGNER_TYPES: () => SIGNER_TYPES,
|
|
44
44
|
SignerList: () => SignerList,
|
|
45
45
|
SignerSelector: () => SignerSelector,
|
|
46
|
+
Skeleton: () => Skeleton,
|
|
47
|
+
ThemeProvider: () => ThemeProvider,
|
|
46
48
|
TransactionSigningForm: () => TransactionSigningForm,
|
|
47
49
|
WalletProvider: () => WalletProvider,
|
|
48
50
|
WalletSelector: () => WalletSelector,
|
|
@@ -53,11 +55,16 @@ __export(index_exports, {
|
|
|
53
55
|
signAndSendTransactionWithSigner: () => signAndSendTransactionWithSigner,
|
|
54
56
|
signMessageWithSigner: () => signMessageWithSigner,
|
|
55
57
|
signTransactionWithSigner: () => signTransactionWithSigner,
|
|
58
|
+
useCanSign: () => useCanSign,
|
|
56
59
|
useCilantroAuth: () => useCilantroAuth,
|
|
60
|
+
useDelegatedKeys: () => useDelegatedKeys,
|
|
57
61
|
useMessageSigning: () => useMessageSigning,
|
|
62
|
+
useSelectedWallet: () => useSelectedWallet,
|
|
58
63
|
useSignerSelection: () => useSignerSelection,
|
|
59
64
|
useSigners: () => useSigners,
|
|
65
|
+
useSignersForSelectedWallet: () => useSignersForSelectedWallet,
|
|
60
66
|
useTransactionSigning: () => useTransactionSigning,
|
|
67
|
+
useWalletAddress: () => useWalletAddress,
|
|
61
68
|
useWallets: () => useWallets
|
|
62
69
|
});
|
|
63
70
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -485,6 +492,18 @@ function CilantroProvider({
|
|
|
485
492
|
);
|
|
486
493
|
}
|
|
487
494
|
|
|
495
|
+
// src/hooks/useSelectedWallet.ts
|
|
496
|
+
function useSelectedWallet() {
|
|
497
|
+
const { selectedWallet, isLoading, refreshWallets } = useWallets();
|
|
498
|
+
return { selectedWallet, isLoading, refreshWallets };
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// src/hooks/useWalletAddress.ts
|
|
502
|
+
function useWalletAddress() {
|
|
503
|
+
const { selectedWallet } = useWallets();
|
|
504
|
+
return selectedWallet?.address ?? selectedWallet?.walletAddress ?? null;
|
|
505
|
+
}
|
|
506
|
+
|
|
488
507
|
// src/hooks/useSigners.ts
|
|
489
508
|
var import_react4 = require("react");
|
|
490
509
|
|
|
@@ -632,8 +651,76 @@ function useSigners(options = {}) {
|
|
|
632
651
|
return { signers, isLoading, error, refresh };
|
|
633
652
|
}
|
|
634
653
|
|
|
635
|
-
// src/hooks/
|
|
654
|
+
// src/hooks/useSignersForSelectedWallet.ts
|
|
655
|
+
function useSignersForSelectedWallet(options = {}) {
|
|
656
|
+
const { walletId: walletIdOverride } = options;
|
|
657
|
+
const { selectedWallet } = useWallets();
|
|
658
|
+
const effectiveWalletId = walletIdOverride ?? selectedWallet?.id ?? selectedWallet?.walletId ?? null;
|
|
659
|
+
return useSigners({ walletId: effectiveWalletId });
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// src/hooks/useDelegatedKeys.ts
|
|
636
663
|
var import_react5 = require("react");
|
|
664
|
+
var import_delegated_keys = require("cilantro-sdk/delegated-keys");
|
|
665
|
+
function normalizeKeys(list) {
|
|
666
|
+
return list.filter((k) => k != null && typeof k === "object" && "id" in k).map((k) => ({
|
|
667
|
+
id: String(k.id ?? ""),
|
|
668
|
+
walletId: String(k.walletId ?? ""),
|
|
669
|
+
name: k.name,
|
|
670
|
+
publicKey: String(k.publicKey ?? ""),
|
|
671
|
+
permissions: k.permissions ?? {},
|
|
672
|
+
isActive: k.isActive !== false,
|
|
673
|
+
createdAt: k.createdAt,
|
|
674
|
+
expiresAt: k.expiresAt,
|
|
675
|
+
...k
|
|
676
|
+
}));
|
|
677
|
+
}
|
|
678
|
+
function useDelegatedKeys(options = {}) {
|
|
679
|
+
const { walletId, filterActive = true } = options;
|
|
680
|
+
const { token } = useCilantroAuth();
|
|
681
|
+
const [keys, setKeys] = (0, import_react5.useState)([]);
|
|
682
|
+
const [isLoading, setIsLoading] = (0, import_react5.useState)(false);
|
|
683
|
+
const [error, setError] = (0, import_react5.useState)(null);
|
|
684
|
+
const loadKeys = (0, import_react5.useCallback)(async () => {
|
|
685
|
+
if (!walletId) {
|
|
686
|
+
setKeys([]);
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
setIsLoading(true);
|
|
690
|
+
setError(null);
|
|
691
|
+
try {
|
|
692
|
+
if (token) setSdkAuth(token);
|
|
693
|
+
const result = await (0, import_delegated_keys.findAll)(walletId);
|
|
694
|
+
const keysData = extractResponseData(result) ?? [];
|
|
695
|
+
const list = Array.isArray(keysData) ? keysData : [];
|
|
696
|
+
let loaded = normalizeKeys(list);
|
|
697
|
+
if (filterActive) {
|
|
698
|
+
const now = Date.now();
|
|
699
|
+
loaded = loaded.filter((key) => {
|
|
700
|
+
if (!key.isActive) return false;
|
|
701
|
+
const exp = key.expiresAt ? new Date(key.expiresAt).getTime() : null;
|
|
702
|
+
return exp === null || exp > now;
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
setKeys(loaded);
|
|
706
|
+
} catch (err) {
|
|
707
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
708
|
+
setKeys([]);
|
|
709
|
+
} finally {
|
|
710
|
+
setIsLoading(false);
|
|
711
|
+
}
|
|
712
|
+
}, [walletId, token, filterActive]);
|
|
713
|
+
(0, import_react5.useEffect)(() => {
|
|
714
|
+
loadKeys();
|
|
715
|
+
}, [loadKeys]);
|
|
716
|
+
const refresh = (0, import_react5.useCallback)(async () => {
|
|
717
|
+
if (walletId) await loadKeys();
|
|
718
|
+
}, [walletId, loadKeys]);
|
|
719
|
+
return { keys, isLoading, error, refresh };
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// src/hooks/useSignerSelection.ts
|
|
723
|
+
var import_react6 = require("react");
|
|
637
724
|
function useSignerSelection(options = {}) {
|
|
638
725
|
const { walletId: walletIdOverride, signingMethod = "sdk-signer" } = options;
|
|
639
726
|
const { selectedWallet } = useWallets();
|
|
@@ -641,17 +728,17 @@ function useSignerSelection(options = {}) {
|
|
|
641
728
|
const { signers: availableSigners, isLoading: isLoadingSigners } = useSigners({
|
|
642
729
|
walletId: effectiveWalletId || null
|
|
643
730
|
});
|
|
644
|
-
const [selectedWalletId, setSelectedWalletId] = (0,
|
|
645
|
-
const [selectedSigner, setSelectedSigner] = (0,
|
|
646
|
-
(0,
|
|
731
|
+
const [selectedWalletId, setSelectedWalletId] = (0, import_react6.useState)(effectiveWalletId);
|
|
732
|
+
const [selectedSigner, setSelectedSigner] = (0, import_react6.useState)(null);
|
|
733
|
+
(0, import_react6.useEffect)(() => {
|
|
647
734
|
setSelectedWalletId(effectiveWalletId);
|
|
648
735
|
}, [effectiveWalletId]);
|
|
649
|
-
(0,
|
|
736
|
+
(0, import_react6.useEffect)(() => {
|
|
650
737
|
if (signingMethod !== "sdk-signer") {
|
|
651
738
|
setSelectedSigner(null);
|
|
652
739
|
}
|
|
653
740
|
}, [signingMethod]);
|
|
654
|
-
const reset = (0,
|
|
741
|
+
const reset = (0, import_react6.useCallback)(() => {
|
|
655
742
|
setSelectedWalletId("");
|
|
656
743
|
setSelectedSigner(null);
|
|
657
744
|
}, []);
|
|
@@ -666,8 +753,43 @@ function useSignerSelection(options = {}) {
|
|
|
666
753
|
};
|
|
667
754
|
}
|
|
668
755
|
|
|
756
|
+
// src/hooks/useCanSign.ts
|
|
757
|
+
var import_react7 = require("react");
|
|
758
|
+
function useCanSign(options = {}) {
|
|
759
|
+
const {
|
|
760
|
+
signingMethod = "sdk-signer",
|
|
761
|
+
requireSigner = true,
|
|
762
|
+
walletAdapterConnected
|
|
763
|
+
} = options;
|
|
764
|
+
const { token } = useCilantroAuth();
|
|
765
|
+
const { selectedWallet } = useWallets();
|
|
766
|
+
const { selectedSigner } = useSignerSelection({ signingMethod });
|
|
767
|
+
return (0, import_react7.useMemo)(() => {
|
|
768
|
+
const hasToken = !!token;
|
|
769
|
+
const hasWallet = !!selectedWallet?.id || !!selectedWallet?.walletId;
|
|
770
|
+
const isSdkSigner = signingMethod === "sdk-signer";
|
|
771
|
+
const hasSigner = isSdkSigner ? !!selectedSigner : walletAdapterConnected !== void 0 ? walletAdapterConnected : hasWallet;
|
|
772
|
+
const canSign = hasToken && hasWallet && (requireSigner ? hasSigner : true);
|
|
773
|
+
return {
|
|
774
|
+
hasToken,
|
|
775
|
+
hasWallet,
|
|
776
|
+
hasSigner,
|
|
777
|
+
canSignMessage: canSign,
|
|
778
|
+
canSignTransaction: canSign
|
|
779
|
+
};
|
|
780
|
+
}, [
|
|
781
|
+
token,
|
|
782
|
+
selectedWallet?.id,
|
|
783
|
+
selectedWallet?.walletId,
|
|
784
|
+
selectedSigner,
|
|
785
|
+
signingMethod,
|
|
786
|
+
requireSigner,
|
|
787
|
+
walletAdapterConnected
|
|
788
|
+
]);
|
|
789
|
+
}
|
|
790
|
+
|
|
669
791
|
// src/hooks/useMessageSigning.ts
|
|
670
|
-
var
|
|
792
|
+
var import_react8 = require("react");
|
|
671
793
|
|
|
672
794
|
// src/core/signer-signing/core.ts
|
|
673
795
|
var import_web3 = require("@solana/web3.js");
|
|
@@ -1210,9 +1332,9 @@ function useMessageSigning(options) {
|
|
|
1210
1332
|
walletAdapterSignMessage,
|
|
1211
1333
|
walletAdapterPublicKey
|
|
1212
1334
|
} = options;
|
|
1213
|
-
const [messageText, setMessageText] = (0,
|
|
1214
|
-
const [signResultState, setSignResultState] = (0,
|
|
1215
|
-
const [isSigning, setIsSigning] = (0,
|
|
1335
|
+
const [messageText, setMessageText] = (0, import_react8.useState)("Hello, Solana!");
|
|
1336
|
+
const [signResultState, setSignResultState] = (0, import_react8.useState)({ status: "idle" });
|
|
1337
|
+
const [isSigning, setIsSigning] = (0, import_react8.useState)(false);
|
|
1216
1338
|
const handleSign = async () => {
|
|
1217
1339
|
setIsSigning(true);
|
|
1218
1340
|
setSignResultState({ status: "loading" });
|
|
@@ -1270,7 +1392,7 @@ function useMessageSigning(options) {
|
|
|
1270
1392
|
}
|
|
1271
1393
|
|
|
1272
1394
|
// src/hooks/useTransactionSigning.ts
|
|
1273
|
-
var
|
|
1395
|
+
var import_react9 = require("react");
|
|
1274
1396
|
function useTransactionSigning(options) {
|
|
1275
1397
|
const {
|
|
1276
1398
|
token,
|
|
@@ -1281,9 +1403,9 @@ function useTransactionSigning(options) {
|
|
|
1281
1403
|
walletAdapterPublicKey,
|
|
1282
1404
|
connection
|
|
1283
1405
|
} = options;
|
|
1284
|
-
const [transactionResultState, setTransactionResultState] = (0,
|
|
1285
|
-
const [isSigningTransaction, setIsSigningTransaction] = (0,
|
|
1286
|
-
const [isSendingTransaction, setIsSendingTransaction] = (0,
|
|
1406
|
+
const [transactionResultState, setTransactionResultState] = (0, import_react9.useState)({ status: "idle" });
|
|
1407
|
+
const [isSigningTransaction, setIsSigningTransaction] = (0, import_react9.useState)(false);
|
|
1408
|
+
const [isSendingTransaction, setIsSendingTransaction] = (0, import_react9.useState)(false);
|
|
1287
1409
|
const signTransaction = async (transaction) => {
|
|
1288
1410
|
setIsSigningTransaction(true);
|
|
1289
1411
|
setTransactionResultState({ status: "loading" });
|
|
@@ -1462,14 +1584,30 @@ var SelectItem = React.forwardRef(({ className, children, ...props }, ref) => /*
|
|
|
1462
1584
|
));
|
|
1463
1585
|
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
1464
1586
|
|
|
1465
|
-
// src/
|
|
1587
|
+
// src/ui/skeleton.tsx
|
|
1588
|
+
var React2 = __toESM(require("react"));
|
|
1466
1589
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1590
|
+
var Skeleton = React2.forwardRef(
|
|
1591
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1592
|
+
"div",
|
|
1593
|
+
{
|
|
1594
|
+
ref,
|
|
1595
|
+
className: cn("rounded-md bg-muted animate-pulse", className),
|
|
1596
|
+
...props
|
|
1597
|
+
}
|
|
1598
|
+
)
|
|
1599
|
+
);
|
|
1600
|
+
Skeleton.displayName = "Skeleton";
|
|
1601
|
+
|
|
1602
|
+
// src/components/WalletSelector.tsx
|
|
1603
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1467
1604
|
function WalletSelector(props) {
|
|
1468
1605
|
const {
|
|
1469
1606
|
value,
|
|
1470
1607
|
onWalletChange,
|
|
1471
1608
|
className,
|
|
1472
1609
|
classNames,
|
|
1610
|
+
useSkeleton = true,
|
|
1473
1611
|
placeholder = "Select a wallet",
|
|
1474
1612
|
renderTrigger,
|
|
1475
1613
|
renderList,
|
|
@@ -1487,7 +1625,7 @@ function WalletSelector(props) {
|
|
|
1487
1625
|
onWalletChange?.(id, wallets.find((w) => w.id === id || w.walletId === id) ?? null);
|
|
1488
1626
|
};
|
|
1489
1627
|
if (children) {
|
|
1490
|
-
return /* @__PURE__ */ (0,
|
|
1628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: children({
|
|
1491
1629
|
wallets,
|
|
1492
1630
|
selectedWallet: selected,
|
|
1493
1631
|
selectWallet: (id) => {
|
|
@@ -1499,23 +1637,44 @@ function WalletSelector(props) {
|
|
|
1499
1637
|
}) });
|
|
1500
1638
|
}
|
|
1501
1639
|
if (renderTrigger || renderList) {
|
|
1502
|
-
return /* @__PURE__ */ (0,
|
|
1640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn(className, classNames?.root), "data-cilantro-wallet-selector": true, children: [
|
|
1503
1641
|
renderTrigger?.({ selectedWallet: selected, wallets, isLoading, open: false, setOpen: () => {
|
|
1504
1642
|
} }),
|
|
1505
1643
|
renderList?.({ wallets, selectedWallet: selected, onSelect: handleSelect, isLoading })
|
|
1506
1644
|
] });
|
|
1507
1645
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1646
|
+
if (isLoading && useSkeleton) {
|
|
1647
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1648
|
+
"div",
|
|
1649
|
+
{
|
|
1650
|
+
className: cn(className, classNames?.root, classNames?.loading),
|
|
1651
|
+
"data-cilantro-wallet-selector": true,
|
|
1652
|
+
"aria-busy": "true",
|
|
1653
|
+
"aria-live": "polite",
|
|
1654
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1655
|
+
"div",
|
|
1656
|
+
{
|
|
1657
|
+
className: cn(
|
|
1658
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2",
|
|
1659
|
+
classNames?.trigger
|
|
1660
|
+
),
|
|
1661
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Skeleton, { className: cn("h-4 flex-1 rounded", classNames?.skeleton) })
|
|
1662
|
+
}
|
|
1663
|
+
)
|
|
1664
|
+
}
|
|
1665
|
+
);
|
|
1666
|
+
}
|
|
1667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-wallet-selector": true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Select, { value: effectiveValue || void 0, onValueChange: handleValueChange, disabled: isLoading, children: [
|
|
1668
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectTrigger, { className: classNames?.trigger, "aria-label": "Select wallet", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectValue, { placeholder: isLoading ? "Loading..." : placeholder }) }),
|
|
1669
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectContent, { className: classNames?.content, children: wallets.map((w) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectItem, { value: w.id, className: classNames?.item, children: w.walletName || w.id }, w.id)) })
|
|
1511
1670
|
] }) });
|
|
1512
1671
|
}
|
|
1513
1672
|
|
|
1514
1673
|
// src/ui/button.tsx
|
|
1515
|
-
var
|
|
1674
|
+
var React3 = __toESM(require("react"));
|
|
1516
1675
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
1517
1676
|
var import_class_variance_authority = require("class-variance-authority");
|
|
1518
|
-
var
|
|
1677
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1519
1678
|
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
1520
1679
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
1521
1680
|
{
|
|
@@ -1532,7 +1691,8 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
1532
1691
|
default: "h-10 px-4 py-2",
|
|
1533
1692
|
sm: "h-9 rounded-md px-3",
|
|
1534
1693
|
lg: "h-11 rounded-md px-8",
|
|
1535
|
-
icon: "h-10 w-10"
|
|
1694
|
+
icon: "h-10 w-10",
|
|
1695
|
+
touch: "h-12 min-h-[44px] min-w-[44px] rounded-md px-4"
|
|
1536
1696
|
}
|
|
1537
1697
|
},
|
|
1538
1698
|
defaultVariants: {
|
|
@@ -1541,16 +1701,16 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
1541
1701
|
}
|
|
1542
1702
|
}
|
|
1543
1703
|
);
|
|
1544
|
-
var Button =
|
|
1704
|
+
var Button = React3.forwardRef(
|
|
1545
1705
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
1546
1706
|
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
1547
|
-
return /* @__PURE__ */ (0,
|
|
1707
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
|
|
1548
1708
|
}
|
|
1549
1709
|
);
|
|
1550
1710
|
Button.displayName = "Button";
|
|
1551
1711
|
|
|
1552
1712
|
// src/components/SignerSelector.tsx
|
|
1553
|
-
var
|
|
1713
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1554
1714
|
function SignerSelector({
|
|
1555
1715
|
selectedWalletId,
|
|
1556
1716
|
availableSigners,
|
|
@@ -1559,15 +1719,16 @@ function SignerSelector({
|
|
|
1559
1719
|
onSignerSelect,
|
|
1560
1720
|
className,
|
|
1561
1721
|
classNames,
|
|
1722
|
+
useSkeleton = true,
|
|
1562
1723
|
renderList,
|
|
1563
1724
|
children
|
|
1564
1725
|
}) {
|
|
1565
1726
|
if (!selectedWalletId) return null;
|
|
1566
1727
|
if (children) {
|
|
1567
|
-
return /* @__PURE__ */ (0,
|
|
1728
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: children({ signers: availableSigners, selectedSigner, onSignerSelect, isLoading: isLoadingSigners }) });
|
|
1568
1729
|
}
|
|
1569
1730
|
if (renderList) {
|
|
1570
|
-
return /* @__PURE__ */ (0,
|
|
1731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-signer-selector": true, children: renderList({
|
|
1571
1732
|
signers: availableSigners,
|
|
1572
1733
|
selectedSigner,
|
|
1573
1734
|
onSelect: onSignerSelect,
|
|
@@ -1577,29 +1738,53 @@ function SignerSelector({
|
|
|
1577
1738
|
getSignerUniqueId
|
|
1578
1739
|
}) });
|
|
1579
1740
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1741
|
+
const loadingContent = isLoadingSigners && useSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1742
|
+
"div",
|
|
1582
1743
|
{
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
")"
|
|
1594
|
-
]
|
|
1744
|
+
className: cn("space-y-1", classNames?.loading),
|
|
1745
|
+
"aria-busy": "true",
|
|
1746
|
+
"aria-live": "polite",
|
|
1747
|
+
children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1748
|
+
Skeleton,
|
|
1749
|
+
{
|
|
1750
|
+
className: cn("h-8 w-full rounded-md", classNames?.skeleton)
|
|
1751
|
+
},
|
|
1752
|
+
i
|
|
1753
|
+
))
|
|
1595
1754
|
}
|
|
1596
|
-
)
|
|
1755
|
+
) : isLoadingSigners ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "Loading signers..." }) : null;
|
|
1756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1757
|
+
"div",
|
|
1758
|
+
{
|
|
1759
|
+
className: cn(className, classNames?.root),
|
|
1760
|
+
"data-cilantro-signer-selector": true,
|
|
1761
|
+
role: "listbox",
|
|
1762
|
+
"aria-label": "Select signer",
|
|
1763
|
+
"aria-busy": isLoadingSigners,
|
|
1764
|
+
"aria-live": "polite",
|
|
1765
|
+
children: loadingContent ?? (availableSigners.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "No signers for this wallet." }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: cn("space-y-1", classNames?.list), children: availableSigners.map((signer) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1766
|
+
Button,
|
|
1767
|
+
{
|
|
1768
|
+
type: "button",
|
|
1769
|
+
variant: selectedSigner?.id === signer.id ? "secondary" : "ghost",
|
|
1770
|
+
size: "sm",
|
|
1771
|
+
className: cn("w-full justify-start", classNames?.item),
|
|
1772
|
+
onClick: () => onSignerSelect(signer),
|
|
1773
|
+
"aria-pressed": selectedSigner?.id === signer.id,
|
|
1774
|
+
children: [
|
|
1775
|
+
getSignerDisplayName(signer),
|
|
1776
|
+
" (",
|
|
1777
|
+
getSignerTypeLabel(signer.type || signer.signerType || ""),
|
|
1778
|
+
")"
|
|
1779
|
+
]
|
|
1780
|
+
}
|
|
1781
|
+
) }, signer.id)) }))
|
|
1782
|
+
}
|
|
1783
|
+
);
|
|
1597
1784
|
}
|
|
1598
1785
|
|
|
1599
1786
|
// src/components/DelegatedKeySelector.tsx
|
|
1600
|
-
var
|
|
1601
|
-
var import_delegated_keys = require("cilantro-sdk/delegated-keys");
|
|
1602
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1787
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1603
1788
|
function DelegatedKeySelector(props) {
|
|
1604
1789
|
const {
|
|
1605
1790
|
walletId,
|
|
@@ -1608,55 +1793,14 @@ function DelegatedKeySelector(props) {
|
|
|
1608
1793
|
filterActive = true,
|
|
1609
1794
|
className,
|
|
1610
1795
|
classNames,
|
|
1796
|
+
useSkeleton = true,
|
|
1611
1797
|
placeholder = "Select a delegated key",
|
|
1612
1798
|
children
|
|
1613
1799
|
} = props;
|
|
1614
|
-
const {
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
const loadKeys = (0, import_react8.useCallback)(async () => {
|
|
1619
|
-
if (!walletId) {
|
|
1620
|
-
setKeys([]);
|
|
1621
|
-
return;
|
|
1622
|
-
}
|
|
1623
|
-
setIsLoading(true);
|
|
1624
|
-
setError(null);
|
|
1625
|
-
try {
|
|
1626
|
-
if (token) setSdkAuth(token);
|
|
1627
|
-
const result = await (0, import_delegated_keys.findAll)(walletId);
|
|
1628
|
-
const keysData = extractResponseData(result) ?? [];
|
|
1629
|
-
const list = Array.isArray(keysData) ? keysData : [];
|
|
1630
|
-
let loaded = list.filter((k) => k != null && typeof k === "object" && "id" in k).map((k) => ({
|
|
1631
|
-
id: String(k.id ?? ""),
|
|
1632
|
-
walletId: String(k.walletId ?? ""),
|
|
1633
|
-
name: k.name,
|
|
1634
|
-
publicKey: String(k.publicKey ?? ""),
|
|
1635
|
-
permissions: k.permissions ?? {},
|
|
1636
|
-
isActive: k.isActive !== false,
|
|
1637
|
-
createdAt: k.createdAt,
|
|
1638
|
-
expiresAt: k.expiresAt,
|
|
1639
|
-
...k
|
|
1640
|
-
}));
|
|
1641
|
-
if (filterActive) {
|
|
1642
|
-
const now = Date.now();
|
|
1643
|
-
loaded = loaded.filter((key) => {
|
|
1644
|
-
if (!key.isActive) return false;
|
|
1645
|
-
const exp = key.expiresAt ? new Date(key.expiresAt).getTime() : null;
|
|
1646
|
-
return exp === null || exp > now;
|
|
1647
|
-
});
|
|
1648
|
-
}
|
|
1649
|
-
setKeys(loaded);
|
|
1650
|
-
} catch (err) {
|
|
1651
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
1652
|
-
setKeys([]);
|
|
1653
|
-
} finally {
|
|
1654
|
-
setIsLoading(false);
|
|
1655
|
-
}
|
|
1656
|
-
}, [walletId, token, filterActive]);
|
|
1657
|
-
(0, import_react8.useEffect)(() => {
|
|
1658
|
-
loadKeys();
|
|
1659
|
-
}, [loadKeys]);
|
|
1800
|
+
const { keys, isLoading, error, refresh: loadKeys } = useDelegatedKeys({
|
|
1801
|
+
walletId,
|
|
1802
|
+
filterActive
|
|
1803
|
+
});
|
|
1660
1804
|
const onSelect = (key) => {
|
|
1661
1805
|
onChange?.(key.id, key);
|
|
1662
1806
|
};
|
|
@@ -1665,22 +1809,52 @@ function DelegatedKeySelector(props) {
|
|
|
1665
1809
|
onChange?.(id, key);
|
|
1666
1810
|
};
|
|
1667
1811
|
if (children) {
|
|
1668
|
-
return /* @__PURE__ */ (0,
|
|
1812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: children({ keys, selectedKeyId: value, onSelect, isLoading, error, refresh: loadKeys }) });
|
|
1669
1813
|
}
|
|
1670
1814
|
if (!walletId) {
|
|
1671
|
-
return /* @__PURE__ */ (0,
|
|
1815
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: cn(className, classNames?.root, "text-sm text-muted-foreground"), children: "Select a wallet first" });
|
|
1672
1816
|
}
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1817
|
+
if (isLoading && useSkeleton) {
|
|
1818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1819
|
+
"div",
|
|
1820
|
+
{
|
|
1821
|
+
className: cn(className, classNames?.root, classNames?.loading),
|
|
1822
|
+
"data-cilantro-delegated-key-selector": true,
|
|
1823
|
+
"aria-busy": "true",
|
|
1824
|
+
"aria-live": "polite",
|
|
1825
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1826
|
+
"div",
|
|
1827
|
+
{
|
|
1828
|
+
className: cn(
|
|
1829
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2",
|
|
1830
|
+
classNames?.trigger
|
|
1831
|
+
),
|
|
1832
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Skeleton, { className: cn("h-4 flex-1 rounded", classNames?.skeleton) })
|
|
1833
|
+
}
|
|
1834
|
+
)
|
|
1835
|
+
}
|
|
1836
|
+
);
|
|
1837
|
+
}
|
|
1838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1839
|
+
"div",
|
|
1840
|
+
{
|
|
1841
|
+
className: cn(className, classNames?.root),
|
|
1842
|
+
"data-cilantro-delegated-key-selector": true,
|
|
1843
|
+
"aria-busy": isLoading,
|
|
1844
|
+
"aria-live": "polite",
|
|
1845
|
+
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "Loading delegated keys..." }) : error ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: cn("text-sm text-destructive", classNames?.message), role: "alert", children: error }) : keys.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "No delegated keys found." }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Select, { value: (value ?? "") || void 0, onValueChange: handleValueChange, children: [
|
|
1846
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectTrigger, { className: classNames?.trigger, "aria-label": "Select delegated key", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectValue, { placeholder }) }),
|
|
1847
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectContent, { className: classNames?.content, children: keys.map((k) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectItem, { value: k.id, className: classNames?.item, children: k.name || k.publicKey.slice(0, 8) + "..." }, k.id)) })
|
|
1848
|
+
] })
|
|
1849
|
+
}
|
|
1850
|
+
);
|
|
1677
1851
|
}
|
|
1678
1852
|
|
|
1679
1853
|
// src/ui/textarea.tsx
|
|
1680
|
-
var
|
|
1681
|
-
var
|
|
1682
|
-
var Textarea =
|
|
1683
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1854
|
+
var React4 = __toESM(require("react"));
|
|
1855
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1856
|
+
var Textarea = React4.forwardRef(
|
|
1857
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1684
1858
|
"textarea",
|
|
1685
1859
|
{
|
|
1686
1860
|
className: cn(
|
|
@@ -1695,21 +1869,21 @@ var Textarea = React3.forwardRef(
|
|
|
1695
1869
|
Textarea.displayName = "Textarea";
|
|
1696
1870
|
|
|
1697
1871
|
// src/ui/label.tsx
|
|
1698
|
-
var
|
|
1872
|
+
var React5 = __toESM(require("react"));
|
|
1699
1873
|
var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
|
|
1700
1874
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
1701
|
-
var
|
|
1875
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1702
1876
|
var labelVariants = (0, import_class_variance_authority2.cva)(
|
|
1703
1877
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
1704
1878
|
);
|
|
1705
|
-
var Label =
|
|
1879
|
+
var Label = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(LabelPrimitive.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
1706
1880
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
1707
1881
|
|
|
1708
1882
|
// src/ui/card.tsx
|
|
1709
|
-
var
|
|
1710
|
-
var
|
|
1711
|
-
var Card =
|
|
1712
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1883
|
+
var React6 = __toESM(require("react"));
|
|
1884
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1885
|
+
var Card = React6.forwardRef(
|
|
1886
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1713
1887
|
"div",
|
|
1714
1888
|
{
|
|
1715
1889
|
ref,
|
|
@@ -1719,12 +1893,12 @@ var Card = React5.forwardRef(
|
|
|
1719
1893
|
)
|
|
1720
1894
|
);
|
|
1721
1895
|
Card.displayName = "Card";
|
|
1722
|
-
var CardHeader =
|
|
1723
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1896
|
+
var CardHeader = React6.forwardRef(
|
|
1897
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })
|
|
1724
1898
|
);
|
|
1725
1899
|
CardHeader.displayName = "CardHeader";
|
|
1726
|
-
var CardTitle =
|
|
1727
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1900
|
+
var CardTitle = React6.forwardRef(
|
|
1901
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1728
1902
|
"h3",
|
|
1729
1903
|
{
|
|
1730
1904
|
ref,
|
|
@@ -1734,19 +1908,19 @@ var CardTitle = React5.forwardRef(
|
|
|
1734
1908
|
)
|
|
1735
1909
|
);
|
|
1736
1910
|
CardTitle.displayName = "CardTitle";
|
|
1737
|
-
var CardDescription =
|
|
1911
|
+
var CardDescription = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
1738
1912
|
CardDescription.displayName = "CardDescription";
|
|
1739
|
-
var CardContent =
|
|
1740
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1913
|
+
var CardContent = React6.forwardRef(
|
|
1914
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref, className: cn("p-6 pt-0", className), ...props })
|
|
1741
1915
|
);
|
|
1742
1916
|
CardContent.displayName = "CardContent";
|
|
1743
|
-
var CardFooter =
|
|
1744
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1917
|
+
var CardFooter = React6.forwardRef(
|
|
1918
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref, className: cn("flex items-center p-6 pt-0", className), ...props })
|
|
1745
1919
|
);
|
|
1746
1920
|
CardFooter.displayName = "CardFooter";
|
|
1747
1921
|
|
|
1748
1922
|
// src/components/MessageSigningForm.tsx
|
|
1749
|
-
var
|
|
1923
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1750
1924
|
function MessageSigningForm({
|
|
1751
1925
|
token: tokenOverride,
|
|
1752
1926
|
selectedWalletId: walletIdOverride,
|
|
@@ -1778,7 +1952,7 @@ function MessageSigningForm({
|
|
|
1778
1952
|
walletAdapterPublicKey
|
|
1779
1953
|
});
|
|
1780
1954
|
if (children) {
|
|
1781
|
-
return /* @__PURE__ */ (0,
|
|
1955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-message-signing-form": true, children: children({
|
|
1782
1956
|
messageText: signing.messageText,
|
|
1783
1957
|
setMessageText: signing.setMessageText,
|
|
1784
1958
|
signResultState: signing.signResultState,
|
|
@@ -1790,17 +1964,17 @@ function MessageSigningForm({
|
|
|
1790
1964
|
const resultStatus = signing.signResultState.status;
|
|
1791
1965
|
const isSuccess = resultStatus === "success";
|
|
1792
1966
|
const isError = resultStatus === "error";
|
|
1793
|
-
return /* @__PURE__ */ (0,
|
|
1794
|
-
/* @__PURE__ */ (0,
|
|
1795
|
-
/* @__PURE__ */ (0,
|
|
1796
|
-
/* @__PURE__ */ (0,
|
|
1797
|
-
showContext && (selectedWalletId || selectedSigner) && /* @__PURE__ */ (0,
|
|
1798
|
-
selectedWalletId && /* @__PURE__ */ (0,
|
|
1967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Card, { className: cn(className, classNames?.root), "data-cilantro-message-signing-form": true, children: [
|
|
1968
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(CardHeader, { className: classNames?.header, children: [
|
|
1969
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CardTitle, { className: cn("text-lg", classNames?.title), children: "Sign message" }),
|
|
1970
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CardDescription, { className: classNames?.description, children: "Sign a message with your selected wallet or signer. The signature proves you control the key." }),
|
|
1971
|
+
showContext && (selectedWalletId || selectedSigner) && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: cn("mt-1 text-xs text-muted-foreground", classNames?.context), children: [
|
|
1972
|
+
selectedWalletId && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
|
|
1799
1973
|
"Wallet: ",
|
|
1800
1974
|
selectedWalletId.slice(0, 8),
|
|
1801
1975
|
"\u2026"
|
|
1802
1976
|
] }),
|
|
1803
|
-
selectedSigner && /* @__PURE__ */ (0,
|
|
1977
|
+
selectedSigner && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: selectedWalletId ? " ml-2" : "", children: [
|
|
1804
1978
|
"Signer: ",
|
|
1805
1979
|
getSignerDisplayName(selectedSigner),
|
|
1806
1980
|
" (",
|
|
@@ -1809,10 +1983,10 @@ function MessageSigningForm({
|
|
|
1809
1983
|
] })
|
|
1810
1984
|
] })
|
|
1811
1985
|
] }),
|
|
1812
|
-
/* @__PURE__ */ (0,
|
|
1813
|
-
/* @__PURE__ */ (0,
|
|
1814
|
-
/* @__PURE__ */ (0,
|
|
1815
|
-
/* @__PURE__ */ (0,
|
|
1986
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(CardContent, { className: "space-y-4", children: [
|
|
1987
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-2", children: [
|
|
1988
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Label, { htmlFor: "cilantro-message-text", className: classNames?.label, children: "Message" }),
|
|
1989
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1816
1990
|
Textarea,
|
|
1817
1991
|
{
|
|
1818
1992
|
id: "cilantro-message-text",
|
|
@@ -1823,24 +1997,25 @@ function MessageSigningForm({
|
|
|
1823
1997
|
rows: 4
|
|
1824
1998
|
}
|
|
1825
1999
|
),
|
|
1826
|
-
showCharCount && /* @__PURE__ */ (0,
|
|
2000
|
+
showCharCount && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: cn("text-right text-xs text-muted-foreground", classNames?.charCount), children: [
|
|
1827
2001
|
signing.messageText.length,
|
|
1828
2002
|
" character",
|
|
1829
2003
|
signing.messageText.length !== 1 ? "s" : ""
|
|
1830
2004
|
] })
|
|
1831
2005
|
] }),
|
|
1832
|
-
/* @__PURE__ */ (0,
|
|
1833
|
-
/* @__PURE__ */ (0,
|
|
2006
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-center", children: [
|
|
2007
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1834
2008
|
Button,
|
|
1835
2009
|
{
|
|
1836
2010
|
type: "button",
|
|
2011
|
+
size: "touch",
|
|
1837
2012
|
className: cn("w-full sm:w-auto", classNames?.button),
|
|
1838
2013
|
onClick: signing.handleSign,
|
|
1839
2014
|
disabled: signing.isSigning || !signing.messageText.trim(),
|
|
1840
2015
|
children: signing.isSigning ? "Signing..." : "Sign message"
|
|
1841
2016
|
}
|
|
1842
2017
|
),
|
|
1843
|
-
/* @__PURE__ */ (0,
|
|
2018
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1844
2019
|
Button,
|
|
1845
2020
|
{
|
|
1846
2021
|
type: "button",
|
|
@@ -1852,9 +2027,12 @@ function MessageSigningForm({
|
|
|
1852
2027
|
}
|
|
1853
2028
|
)
|
|
1854
2029
|
] }),
|
|
1855
|
-
resultStatus !== "idle" && /* @__PURE__ */ (0,
|
|
2030
|
+
resultStatus !== "idle" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1856
2031
|
"div",
|
|
1857
2032
|
{
|
|
2033
|
+
role: "status",
|
|
2034
|
+
"aria-live": isError ? "assertive" : "polite",
|
|
2035
|
+
"aria-busy": resultStatus === "loading",
|
|
1858
2036
|
className: cn(
|
|
1859
2037
|
"rounded-lg border px-3 py-2 text-sm",
|
|
1860
2038
|
isSuccess && cn("border-green-500/50 bg-green-500/10 text-green-700 dark:text-green-400", classNames?.resultSuccess),
|
|
@@ -1865,7 +2043,7 @@ function MessageSigningForm({
|
|
|
1865
2043
|
"data-status": resultStatus,
|
|
1866
2044
|
children: [
|
|
1867
2045
|
signing.signResultState.message,
|
|
1868
|
-
signing.signResultState.detail != null && /* @__PURE__ */ (0,
|
|
2046
|
+
signing.signResultState.detail != null && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("pre", { className: cn("mt-2 overflow-auto rounded-md bg-muted/80 p-2 text-xs", classNames?.resultPre), children: JSON.stringify(signing.signResultState.detail, null, 2) })
|
|
1869
2047
|
]
|
|
1870
2048
|
}
|
|
1871
2049
|
)
|
|
@@ -1874,7 +2052,7 @@ function MessageSigningForm({
|
|
|
1874
2052
|
}
|
|
1875
2053
|
|
|
1876
2054
|
// src/components/TransactionSigningForm.tsx
|
|
1877
|
-
var
|
|
2055
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1878
2056
|
function TransactionSigningForm({
|
|
1879
2057
|
token: tokenOverride,
|
|
1880
2058
|
selectedWalletId: walletIdOverride,
|
|
@@ -1907,7 +2085,7 @@ function TransactionSigningForm({
|
|
|
1907
2085
|
connection
|
|
1908
2086
|
});
|
|
1909
2087
|
if (children) {
|
|
1910
|
-
return /* @__PURE__ */ (0,
|
|
2088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-transaction-signing-form": true, children: children({
|
|
1911
2089
|
transactionResultState: signing.transactionResultState,
|
|
1912
2090
|
isSigningTransaction: signing.isSigningTransaction,
|
|
1913
2091
|
isSendingTransaction: signing.isSendingTransaction,
|
|
@@ -1919,23 +2097,23 @@ function TransactionSigningForm({
|
|
|
1919
2097
|
const resultStatus = signing.transactionResultState.status;
|
|
1920
2098
|
const isSuccess = resultStatus === "success";
|
|
1921
2099
|
const isError = resultStatus === "error";
|
|
1922
|
-
return /* @__PURE__ */ (0,
|
|
1923
|
-
/* @__PURE__ */ (0,
|
|
1924
|
-
/* @__PURE__ */ (0,
|
|
1925
|
-
/* @__PURE__ */ (0,
|
|
2100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Card, { className: cn(className, classNames?.root), "data-cilantro-transaction-signing-form": true, children: [
|
|
2101
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(CardHeader, { className: classNames?.header, children: [
|
|
2102
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CardTitle, { className: cn("text-lg", classNames?.title), children: "Sign transaction" }),
|
|
2103
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(CardDescription, { className: classNames?.description, children: [
|
|
1926
2104
|
"Build a transaction in your app, then pass it to ",
|
|
1927
|
-
/* @__PURE__ */ (0,
|
|
2105
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { className: "text-xs", children: "signTransaction(tx)" }),
|
|
1928
2106
|
" to sign only, or ",
|
|
1929
|
-
/* @__PURE__ */ (0,
|
|
2107
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { className: "text-xs", children: "signAndSendTransaction(tx)" }),
|
|
1930
2108
|
" to sign and send. Use the render props (children) to wire your own UI."
|
|
1931
2109
|
] }),
|
|
1932
|
-
showContext && (selectedWalletId || selectedSigner) && /* @__PURE__ */ (0,
|
|
1933
|
-
selectedWalletId && /* @__PURE__ */ (0,
|
|
2110
|
+
showContext && (selectedWalletId || selectedSigner) && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { className: cn("mt-1 text-xs text-muted-foreground", classNames?.context), children: [
|
|
2111
|
+
selectedWalletId && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { children: [
|
|
1934
2112
|
"Wallet: ",
|
|
1935
2113
|
selectedWalletId.slice(0, 8),
|
|
1936
2114
|
"\u2026"
|
|
1937
2115
|
] }),
|
|
1938
|
-
selectedSigner && /* @__PURE__ */ (0,
|
|
2116
|
+
selectedSigner && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: selectedWalletId ? " ml-2" : "", children: [
|
|
1939
2117
|
"Signer: ",
|
|
1940
2118
|
getSignerDisplayName(selectedSigner),
|
|
1941
2119
|
" (",
|
|
@@ -1944,8 +2122,8 @@ function TransactionSigningForm({
|
|
|
1944
2122
|
] })
|
|
1945
2123
|
] })
|
|
1946
2124
|
] }),
|
|
1947
|
-
/* @__PURE__ */ (0,
|
|
1948
|
-
/* @__PURE__ */ (0,
|
|
2125
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(CardContent, { className: "space-y-4", children: [
|
|
2126
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1949
2127
|
Button,
|
|
1950
2128
|
{
|
|
1951
2129
|
type: "button",
|
|
@@ -1956,9 +2134,12 @@ function TransactionSigningForm({
|
|
|
1956
2134
|
children: "Reset status"
|
|
1957
2135
|
}
|
|
1958
2136
|
),
|
|
1959
|
-
resultStatus !== "idle" && /* @__PURE__ */ (0,
|
|
2137
|
+
resultStatus !== "idle" && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1960
2138
|
"div",
|
|
1961
2139
|
{
|
|
2140
|
+
role: "status",
|
|
2141
|
+
"aria-live": isError ? "assertive" : "polite",
|
|
2142
|
+
"aria-busy": resultStatus === "loading",
|
|
1962
2143
|
className: cn(
|
|
1963
2144
|
"rounded-lg border px-3 py-2 text-sm",
|
|
1964
2145
|
isSuccess && cn("border-green-500/50 bg-green-500/10 text-green-700 dark:text-green-400", classNames?.resultSuccess),
|
|
@@ -1969,7 +2150,7 @@ function TransactionSigningForm({
|
|
|
1969
2150
|
"data-status": resultStatus,
|
|
1970
2151
|
children: [
|
|
1971
2152
|
signing.transactionResultState.message,
|
|
1972
|
-
signing.transactionResultState.detail != null && /* @__PURE__ */ (0,
|
|
2153
|
+
signing.transactionResultState.detail != null && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("pre", { className: cn("mt-2 overflow-auto rounded-md bg-muted/80 p-2 text-xs", classNames?.resultPre), children: JSON.stringify(signing.transactionResultState.detail, null, 2) })
|
|
1973
2154
|
]
|
|
1974
2155
|
}
|
|
1975
2156
|
)
|
|
@@ -1978,14 +2159,14 @@ function TransactionSigningForm({
|
|
|
1978
2159
|
}
|
|
1979
2160
|
|
|
1980
2161
|
// src/components/LoginForm.tsx
|
|
1981
|
-
var
|
|
2162
|
+
var import_react10 = require("react");
|
|
1982
2163
|
|
|
1983
2164
|
// src/ui/input.tsx
|
|
1984
|
-
var
|
|
1985
|
-
var
|
|
1986
|
-
var Input =
|
|
2165
|
+
var React7 = __toESM(require("react"));
|
|
2166
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2167
|
+
var Input = React7.forwardRef(
|
|
1987
2168
|
({ className, type, ...props }, ref) => {
|
|
1988
|
-
return /* @__PURE__ */ (0,
|
|
2169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1989
2170
|
"input",
|
|
1990
2171
|
{
|
|
1991
2172
|
type,
|
|
@@ -2002,7 +2183,7 @@ var Input = React6.forwardRef(
|
|
|
2002
2183
|
Input.displayName = "Input";
|
|
2003
2184
|
|
|
2004
2185
|
// src/components/LoginForm.tsx
|
|
2005
|
-
var
|
|
2186
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2006
2187
|
function LoginForm({
|
|
2007
2188
|
className,
|
|
2008
2189
|
classNames,
|
|
@@ -2014,9 +2195,9 @@ function LoginForm({
|
|
|
2014
2195
|
renderSwitchToRegister
|
|
2015
2196
|
}) {
|
|
2016
2197
|
const { login, isLoading } = useCilantroAuth();
|
|
2017
|
-
const [usernameOrEmail, setUsernameOrEmail] = (0,
|
|
2018
|
-
const [password, setPassword] = (0,
|
|
2019
|
-
const [error, setError] = (0,
|
|
2198
|
+
const [usernameOrEmail, setUsernameOrEmail] = (0, import_react10.useState)("");
|
|
2199
|
+
const [password, setPassword] = (0, import_react10.useState)("");
|
|
2200
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
2020
2201
|
const handleSubmit = async (e) => {
|
|
2021
2202
|
e.preventDefault();
|
|
2022
2203
|
setError(null);
|
|
@@ -2029,15 +2210,15 @@ function LoginForm({
|
|
|
2029
2210
|
onError?.(message);
|
|
2030
2211
|
}
|
|
2031
2212
|
};
|
|
2032
|
-
return /* @__PURE__ */ (0,
|
|
2033
|
-
/* @__PURE__ */ (0,
|
|
2034
|
-
/* @__PURE__ */ (0,
|
|
2035
|
-
description != null && /* @__PURE__ */ (0,
|
|
2213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Card, { className: cn(className, classNames?.root), "data-cilantro-login-form": true, children: [
|
|
2214
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(CardHeader, { className: classNames?.header, children: [
|
|
2215
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CardTitle, { className: classNames?.title, children: title }),
|
|
2216
|
+
description != null && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CardDescription, { className: classNames?.description, children: description })
|
|
2036
2217
|
] }),
|
|
2037
|
-
/* @__PURE__ */ (0,
|
|
2038
|
-
/* @__PURE__ */ (0,
|
|
2039
|
-
/* @__PURE__ */ (0,
|
|
2040
|
-
/* @__PURE__ */ (0,
|
|
2218
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CardContent, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("form", { onSubmit: handleSubmit, className: cn("space-y-4", classNames?.form), children: [
|
|
2219
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-2", children: [
|
|
2220
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label, { htmlFor: "cilantro-login-username", className: classNames?.label, children: "Username or email" }),
|
|
2221
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2041
2222
|
Input,
|
|
2042
2223
|
{
|
|
2043
2224
|
id: "cilantro-login-username",
|
|
@@ -2052,9 +2233,9 @@ function LoginForm({
|
|
|
2052
2233
|
}
|
|
2053
2234
|
)
|
|
2054
2235
|
] }),
|
|
2055
|
-
/* @__PURE__ */ (0,
|
|
2056
|
-
/* @__PURE__ */ (0,
|
|
2057
|
-
/* @__PURE__ */ (0,
|
|
2236
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-2", children: [
|
|
2237
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label, { htmlFor: "cilantro-login-password", className: classNames?.label, children: "Password" }),
|
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2058
2239
|
Input,
|
|
2059
2240
|
{
|
|
2060
2241
|
id: "cilantro-login-password",
|
|
@@ -2069,7 +2250,7 @@ function LoginForm({
|
|
|
2069
2250
|
}
|
|
2070
2251
|
)
|
|
2071
2252
|
] }),
|
|
2072
|
-
error && /* @__PURE__ */ (0,
|
|
2253
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2073
2254
|
"div",
|
|
2074
2255
|
{
|
|
2075
2256
|
className: cn(
|
|
@@ -2080,23 +2261,24 @@ function LoginForm({
|
|
|
2080
2261
|
children: error
|
|
2081
2262
|
}
|
|
2082
2263
|
),
|
|
2083
|
-
/* @__PURE__ */ (0,
|
|
2264
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2084
2265
|
Button,
|
|
2085
2266
|
{
|
|
2086
2267
|
type: "submit",
|
|
2268
|
+
size: "touch",
|
|
2087
2269
|
className: cn("w-full", classNames?.submitButton),
|
|
2088
2270
|
disabled: isLoading || !usernameOrEmail.trim() || !password,
|
|
2089
2271
|
children: isLoading ? "Signing in..." : submitLabel
|
|
2090
2272
|
}
|
|
2091
2273
|
),
|
|
2092
|
-
renderSwitchToRegister && /* @__PURE__ */ (0,
|
|
2274
|
+
renderSwitchToRegister && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "text-center text-sm text-muted-foreground", children: renderSwitchToRegister() })
|
|
2093
2275
|
] }) })
|
|
2094
2276
|
] });
|
|
2095
2277
|
}
|
|
2096
2278
|
|
|
2097
2279
|
// src/components/RegisterForm.tsx
|
|
2098
|
-
var
|
|
2099
|
-
var
|
|
2280
|
+
var import_react11 = require("react");
|
|
2281
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2100
2282
|
function RegisterForm({
|
|
2101
2283
|
className,
|
|
2102
2284
|
classNames,
|
|
@@ -2109,10 +2291,10 @@ function RegisterForm({
|
|
|
2109
2291
|
renderSwitchToLogin
|
|
2110
2292
|
}) {
|
|
2111
2293
|
const { register, isLoading } = useCilantroAuth();
|
|
2112
|
-
const [username, setUsername] = (0,
|
|
2113
|
-
const [email, setEmail] = (0,
|
|
2114
|
-
const [password, setPassword] = (0,
|
|
2115
|
-
const [error, setError] = (0,
|
|
2294
|
+
const [username, setUsername] = (0, import_react11.useState)("");
|
|
2295
|
+
const [email, setEmail] = (0, import_react11.useState)("");
|
|
2296
|
+
const [password, setPassword] = (0, import_react11.useState)("");
|
|
2297
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
2116
2298
|
const handleSubmit = async (e) => {
|
|
2117
2299
|
e.preventDefault();
|
|
2118
2300
|
setError(null);
|
|
@@ -2125,15 +2307,15 @@ function RegisterForm({
|
|
|
2125
2307
|
onError?.(message);
|
|
2126
2308
|
}
|
|
2127
2309
|
};
|
|
2128
|
-
return /* @__PURE__ */ (0,
|
|
2129
|
-
/* @__PURE__ */ (0,
|
|
2130
|
-
/* @__PURE__ */ (0,
|
|
2131
|
-
description != null && /* @__PURE__ */ (0,
|
|
2310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Card, { className: cn(className, classNames?.root), "data-cilantro-register-form": true, children: [
|
|
2311
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(CardHeader, { className: classNames?.header, children: [
|
|
2312
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardTitle, { className: classNames?.title, children: title }),
|
|
2313
|
+
description != null && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardDescription, { className: classNames?.description, children: description })
|
|
2132
2314
|
] }),
|
|
2133
|
-
/* @__PURE__ */ (0,
|
|
2134
|
-
/* @__PURE__ */ (0,
|
|
2135
|
-
/* @__PURE__ */ (0,
|
|
2136
|
-
/* @__PURE__ */ (0,
|
|
2315
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardContent, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("form", { onSubmit: handleSubmit, className: cn("space-y-4", classNames?.form), children: [
|
|
2316
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-2", children: [
|
|
2317
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label, { htmlFor: "cilantro-register-username", className: classNames?.label, children: "Username" }),
|
|
2318
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2137
2319
|
Input,
|
|
2138
2320
|
{
|
|
2139
2321
|
id: "cilantro-register-username",
|
|
@@ -2148,9 +2330,9 @@ function RegisterForm({
|
|
|
2148
2330
|
}
|
|
2149
2331
|
)
|
|
2150
2332
|
] }),
|
|
2151
|
-
/* @__PURE__ */ (0,
|
|
2152
|
-
/* @__PURE__ */ (0,
|
|
2153
|
-
/* @__PURE__ */ (0,
|
|
2333
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-2", children: [
|
|
2334
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label, { htmlFor: "cilantro-register-email", className: classNames?.label, children: "Email" }),
|
|
2335
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2154
2336
|
Input,
|
|
2155
2337
|
{
|
|
2156
2338
|
id: "cilantro-register-email",
|
|
@@ -2165,9 +2347,9 @@ function RegisterForm({
|
|
|
2165
2347
|
}
|
|
2166
2348
|
)
|
|
2167
2349
|
] }),
|
|
2168
|
-
/* @__PURE__ */ (0,
|
|
2169
|
-
/* @__PURE__ */ (0,
|
|
2170
|
-
/* @__PURE__ */ (0,
|
|
2350
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-2", children: [
|
|
2351
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label, { htmlFor: "cilantro-register-password", className: classNames?.label, children: "Password" }),
|
|
2352
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2171
2353
|
Input,
|
|
2172
2354
|
{
|
|
2173
2355
|
id: "cilantro-register-password",
|
|
@@ -2182,7 +2364,7 @@ function RegisterForm({
|
|
|
2182
2364
|
}
|
|
2183
2365
|
)
|
|
2184
2366
|
] }),
|
|
2185
|
-
error && /* @__PURE__ */ (0,
|
|
2367
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2186
2368
|
"div",
|
|
2187
2369
|
{
|
|
2188
2370
|
className: cn(
|
|
@@ -2193,23 +2375,24 @@ function RegisterForm({
|
|
|
2193
2375
|
children: error
|
|
2194
2376
|
}
|
|
2195
2377
|
),
|
|
2196
|
-
/* @__PURE__ */ (0,
|
|
2378
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2197
2379
|
Button,
|
|
2198
2380
|
{
|
|
2199
2381
|
type: "submit",
|
|
2382
|
+
size: "touch",
|
|
2200
2383
|
className: cn("w-full", classNames?.submitButton),
|
|
2201
2384
|
disabled: isLoading || !username.trim() || !email.trim() || !password,
|
|
2202
2385
|
children: isLoading ? "Creating account..." : submitLabel
|
|
2203
2386
|
}
|
|
2204
2387
|
),
|
|
2205
|
-
renderSwitchToLogin && /* @__PURE__ */ (0,
|
|
2388
|
+
renderSwitchToLogin && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "text-center text-sm text-muted-foreground", children: renderSwitchToLogin() })
|
|
2206
2389
|
] }) })
|
|
2207
2390
|
] });
|
|
2208
2391
|
}
|
|
2209
2392
|
|
|
2210
2393
|
// src/components/AuthForm.tsx
|
|
2211
|
-
var
|
|
2212
|
-
var
|
|
2394
|
+
var import_react12 = require("react");
|
|
2395
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2213
2396
|
function AuthForm({
|
|
2214
2397
|
defaultMode = "login",
|
|
2215
2398
|
className,
|
|
@@ -2227,12 +2410,12 @@ function AuthForm({
|
|
|
2227
2410
|
isActive = true
|
|
2228
2411
|
}) {
|
|
2229
2412
|
const { login, register, isLoading } = useCilantroAuth();
|
|
2230
|
-
const [mode, setMode] = (0,
|
|
2231
|
-
const [usernameOrEmail, setUsernameOrEmail] = (0,
|
|
2232
|
-
const [username, setUsername] = (0,
|
|
2233
|
-
const [email, setEmail] = (0,
|
|
2234
|
-
const [password, setPassword] = (0,
|
|
2235
|
-
const [error, setError] = (0,
|
|
2413
|
+
const [mode, setMode] = (0, import_react12.useState)(defaultMode);
|
|
2414
|
+
const [usernameOrEmail, setUsernameOrEmail] = (0, import_react12.useState)("");
|
|
2415
|
+
const [username, setUsername] = (0, import_react12.useState)("");
|
|
2416
|
+
const [email, setEmail] = (0, import_react12.useState)("");
|
|
2417
|
+
const [password, setPassword] = (0, import_react12.useState)("");
|
|
2418
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
2236
2419
|
const isLogin = mode === "login";
|
|
2237
2420
|
const handleSubmit = async (e) => {
|
|
2238
2421
|
e.preventDefault();
|
|
@@ -2255,16 +2438,16 @@ function AuthForm({
|
|
|
2255
2438
|
setError(null);
|
|
2256
2439
|
};
|
|
2257
2440
|
const canSubmit = isLogin ? usernameOrEmail.trim().length > 0 && password.length > 0 : username.trim().length > 0 && email.trim().length > 0 && password.length > 0;
|
|
2258
|
-
return /* @__PURE__ */ (0,
|
|
2259
|
-
/* @__PURE__ */ (0,
|
|
2260
|
-
/* @__PURE__ */ (0,
|
|
2261
|
-
/* @__PURE__ */ (0,
|
|
2441
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Card, { className: cn("w-full max-w-sm", className, classNames?.root), "data-cilantro-auth-form": true, children: [
|
|
2442
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(CardHeader, { className: cn("space-y-1 text-center sm:text-left", classNames?.header), children: [
|
|
2443
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CardTitle, { className: cn("text-xl", classNames?.title), children: isLogin ? loginTitle : registerTitle }),
|
|
2444
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CardDescription, { className: classNames?.description, children: isLogin ? loginDescription : registerDescription })
|
|
2262
2445
|
] }),
|
|
2263
|
-
/* @__PURE__ */ (0,
|
|
2264
|
-
isLogin ? /* @__PURE__ */ (0,
|
|
2265
|
-
/* @__PURE__ */ (0,
|
|
2266
|
-
/* @__PURE__ */ (0,
|
|
2267
|
-
/* @__PURE__ */ (0,
|
|
2446
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CardContent, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("form", { onSubmit: handleSubmit, className: cn("space-y-4", classNames?.form), children: [
|
|
2447
|
+
isLogin ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
2448
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
2449
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: "cilantro-auth-username", className: classNames?.label, children: "Username or email" }),
|
|
2450
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2268
2451
|
Input,
|
|
2269
2452
|
{
|
|
2270
2453
|
id: "cilantro-auth-username",
|
|
@@ -2279,9 +2462,9 @@ function AuthForm({
|
|
|
2279
2462
|
}
|
|
2280
2463
|
)
|
|
2281
2464
|
] }),
|
|
2282
|
-
/* @__PURE__ */ (0,
|
|
2283
|
-
/* @__PURE__ */ (0,
|
|
2284
|
-
/* @__PURE__ */ (0,
|
|
2465
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
2466
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: "cilantro-auth-password", className: classNames?.label, children: "Password" }),
|
|
2467
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2285
2468
|
Input,
|
|
2286
2469
|
{
|
|
2287
2470
|
id: "cilantro-auth-password",
|
|
@@ -2296,10 +2479,10 @@ function AuthForm({
|
|
|
2296
2479
|
}
|
|
2297
2480
|
)
|
|
2298
2481
|
] })
|
|
2299
|
-
] }) : /* @__PURE__ */ (0,
|
|
2300
|
-
/* @__PURE__ */ (0,
|
|
2301
|
-
/* @__PURE__ */ (0,
|
|
2302
|
-
/* @__PURE__ */ (0,
|
|
2482
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
2483
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
2484
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: "cilantro-auth-reg-username", className: classNames?.label, children: "Username" }),
|
|
2485
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2303
2486
|
Input,
|
|
2304
2487
|
{
|
|
2305
2488
|
id: "cilantro-auth-reg-username",
|
|
@@ -2314,9 +2497,9 @@ function AuthForm({
|
|
|
2314
2497
|
}
|
|
2315
2498
|
)
|
|
2316
2499
|
] }),
|
|
2317
|
-
/* @__PURE__ */ (0,
|
|
2318
|
-
/* @__PURE__ */ (0,
|
|
2319
|
-
/* @__PURE__ */ (0,
|
|
2500
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
2501
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: "cilantro-auth-reg-email", className: classNames?.label, children: "Email" }),
|
|
2502
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2320
2503
|
Input,
|
|
2321
2504
|
{
|
|
2322
2505
|
id: "cilantro-auth-reg-email",
|
|
@@ -2331,9 +2514,9 @@ function AuthForm({
|
|
|
2331
2514
|
}
|
|
2332
2515
|
)
|
|
2333
2516
|
] }),
|
|
2334
|
-
/* @__PURE__ */ (0,
|
|
2335
|
-
/* @__PURE__ */ (0,
|
|
2336
|
-
/* @__PURE__ */ (0,
|
|
2517
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
2518
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: "cilantro-auth-reg-password", className: classNames?.label, children: "Password" }),
|
|
2519
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2337
2520
|
Input,
|
|
2338
2521
|
{
|
|
2339
2522
|
id: "cilantro-auth-reg-password",
|
|
@@ -2349,7 +2532,7 @@ function AuthForm({
|
|
|
2349
2532
|
)
|
|
2350
2533
|
] })
|
|
2351
2534
|
] }),
|
|
2352
|
-
error && /* @__PURE__ */ (0,
|
|
2535
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2353
2536
|
"div",
|
|
2354
2537
|
{
|
|
2355
2538
|
className: cn(
|
|
@@ -2360,16 +2543,17 @@ function AuthForm({
|
|
|
2360
2543
|
children: error
|
|
2361
2544
|
}
|
|
2362
2545
|
),
|
|
2363
|
-
/* @__PURE__ */ (0,
|
|
2546
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2364
2547
|
Button,
|
|
2365
2548
|
{
|
|
2366
2549
|
type: "submit",
|
|
2550
|
+
size: "touch",
|
|
2367
2551
|
className: cn("w-full", classNames?.submitButton),
|
|
2368
2552
|
disabled: isLoading || !canSubmit,
|
|
2369
2553
|
children: isLoading ? isLogin ? "Signing in..." : "Creating account..." : isLogin ? loginSubmitLabel : registerSubmitLabel
|
|
2370
2554
|
}
|
|
2371
2555
|
),
|
|
2372
|
-
/* @__PURE__ */ (0,
|
|
2556
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: cn("text-center text-sm text-muted-foreground", classNames?.toggle), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2373
2557
|
"button",
|
|
2374
2558
|
{
|
|
2375
2559
|
type: "button",
|
|
@@ -2384,35 +2568,49 @@ function AuthForm({
|
|
|
2384
2568
|
}
|
|
2385
2569
|
|
|
2386
2570
|
// src/components/AuthGuard.tsx
|
|
2387
|
-
var
|
|
2571
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2388
2572
|
function AuthGuard({
|
|
2389
2573
|
children,
|
|
2390
2574
|
fallback,
|
|
2391
2575
|
className,
|
|
2392
2576
|
classNames,
|
|
2393
|
-
showFallback = true
|
|
2577
|
+
showFallback = true,
|
|
2578
|
+
useSkeleton = false
|
|
2394
2579
|
}) {
|
|
2395
2580
|
const { isAuthenticated, isLoading } = useCilantroAuth();
|
|
2396
2581
|
if (isLoading) {
|
|
2397
|
-
return /* @__PURE__ */ (0,
|
|
2582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2583
|
+
"div",
|
|
2584
|
+
{
|
|
2585
|
+
className: cn(className, classNames?.root, classNames?.loading),
|
|
2586
|
+
"data-cilantro-auth-guard": true,
|
|
2587
|
+
"aria-busy": "true",
|
|
2588
|
+
"aria-live": "polite",
|
|
2589
|
+
children: useSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: cn("rounded-lg border border-input p-4 space-y-3 w-full max-w-sm", classNames?.fallback), children: [
|
|
2590
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Skeleton, { className: cn("h-6 w-2/3 rounded", classNames?.skeleton) }),
|
|
2591
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Skeleton, { className: cn("h-4 w-full rounded", classNames?.skeleton) }),
|
|
2592
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Skeleton, { className: cn("h-4 w-[80%] rounded", classNames?.skeleton) })
|
|
2593
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: cn("text-sm text-muted-foreground", classNames?.fallback), children: "Loading..." })
|
|
2594
|
+
}
|
|
2595
|
+
);
|
|
2398
2596
|
}
|
|
2399
2597
|
if (!isAuthenticated) {
|
|
2400
2598
|
if (!showFallback) return null;
|
|
2401
|
-
return /* @__PURE__ */ (0,
|
|
2599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-auth-guard": true, children: fallback ?? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LoginForm, { className: classNames?.fallback }) });
|
|
2402
2600
|
}
|
|
2403
|
-
return /* @__PURE__ */ (0,
|
|
2601
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2404
2602
|
}
|
|
2405
2603
|
|
|
2406
2604
|
// src/components/AddSignerForm.tsx
|
|
2407
|
-
var
|
|
2605
|
+
var import_react13 = require("react");
|
|
2408
2606
|
|
|
2409
2607
|
// src/ui/dialog.tsx
|
|
2410
|
-
var
|
|
2608
|
+
var React8 = __toESM(require("react"));
|
|
2411
2609
|
var DialogPrimitive = __toESM(require("@radix-ui/react-dialog"));
|
|
2412
|
-
var
|
|
2610
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2413
2611
|
var Dialog = DialogPrimitive.Root;
|
|
2414
2612
|
var DialogPortal = DialogPrimitive.Portal;
|
|
2415
|
-
var DialogOverlay =
|
|
2613
|
+
var DialogOverlay = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2416
2614
|
DialogPrimitive.Overlay,
|
|
2417
2615
|
{
|
|
2418
2616
|
ref,
|
|
@@ -2424,14 +2622,14 @@ var DialogOverlay = React7.forwardRef(({ className, ...props }, ref) => /* @__PU
|
|
|
2424
2622
|
}
|
|
2425
2623
|
));
|
|
2426
2624
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
2427
|
-
var DialogContent =
|
|
2428
|
-
/* @__PURE__ */ (0,
|
|
2429
|
-
/* @__PURE__ */ (0,
|
|
2625
|
+
var DialogContent = React8.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DialogPortal, { children: [
|
|
2626
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DialogOverlay, {}),
|
|
2627
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2430
2628
|
DialogPrimitive.Content,
|
|
2431
2629
|
{
|
|
2432
2630
|
ref,
|
|
2433
2631
|
className: cn(
|
|
2434
|
-
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
2632
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg max-h-[100dvh] sm:max-h-[90vh] translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 overflow-y-auto data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
2435
2633
|
className
|
|
2436
2634
|
),
|
|
2437
2635
|
...props,
|
|
@@ -2440,9 +2638,9 @@ var DialogContent = React7.forwardRef(({ className, children, ...props }, ref) =
|
|
|
2440
2638
|
)
|
|
2441
2639
|
] }));
|
|
2442
2640
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
2443
|
-
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
2641
|
+
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), ...props });
|
|
2444
2642
|
DialogHeader.displayName = "DialogHeader";
|
|
2445
|
-
var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
2643
|
+
var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2446
2644
|
"div",
|
|
2447
2645
|
{
|
|
2448
2646
|
className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className),
|
|
@@ -2450,7 +2648,7 @@ var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_r
|
|
|
2450
2648
|
}
|
|
2451
2649
|
);
|
|
2452
2650
|
DialogFooter.displayName = "DialogFooter";
|
|
2453
|
-
var DialogTitle =
|
|
2651
|
+
var DialogTitle = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2454
2652
|
DialogPrimitive.Title,
|
|
2455
2653
|
{
|
|
2456
2654
|
ref,
|
|
@@ -2459,7 +2657,7 @@ var DialogTitle = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
2459
2657
|
}
|
|
2460
2658
|
));
|
|
2461
2659
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
2462
|
-
var DialogDescription =
|
|
2660
|
+
var DialogDescription = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2463
2661
|
DialogPrimitive.Description,
|
|
2464
2662
|
{
|
|
2465
2663
|
ref,
|
|
@@ -2470,7 +2668,7 @@ var DialogDescription = React7.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
2470
2668
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
2471
2669
|
|
|
2472
2670
|
// src/components/AddSignerForm.tsx
|
|
2473
|
-
var
|
|
2671
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2474
2672
|
function AddSignerForm({
|
|
2475
2673
|
walletId,
|
|
2476
2674
|
open = true,
|
|
@@ -2482,12 +2680,12 @@ function AddSignerForm({
|
|
|
2482
2680
|
classNames,
|
|
2483
2681
|
asDialog = true
|
|
2484
2682
|
}) {
|
|
2485
|
-
const [signerType, setSignerType] = (0,
|
|
2486
|
-
const [email, setEmail] = (0,
|
|
2487
|
-
const [phone, setPhone] = (0,
|
|
2488
|
-
const [address, setAddress] = (0,
|
|
2489
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
2490
|
-
const [error, setError] = (0,
|
|
2683
|
+
const [signerType, setSignerType] = (0, import_react13.useState)(null);
|
|
2684
|
+
const [email, setEmail] = (0, import_react13.useState)("");
|
|
2685
|
+
const [phone, setPhone] = (0, import_react13.useState)("");
|
|
2686
|
+
const [address, setAddress] = (0, import_react13.useState)("");
|
|
2687
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react13.useState)(false);
|
|
2688
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
2491
2689
|
const resetForm = () => {
|
|
2492
2690
|
setSignerType(null);
|
|
2493
2691
|
setEmail("");
|
|
@@ -2542,12 +2740,12 @@ function AddSignerForm({
|
|
|
2542
2740
|
onError?.(message);
|
|
2543
2741
|
}).finally(() => setIsSubmitting(false));
|
|
2544
2742
|
};
|
|
2545
|
-
const formContent = /* @__PURE__ */ (0,
|
|
2546
|
-
!signerType ? /* @__PURE__ */ (0,
|
|
2547
|
-
/* @__PURE__ */ (0,
|
|
2548
|
-
/* @__PURE__ */ (0,
|
|
2549
|
-
/* @__PURE__ */ (0,
|
|
2550
|
-
/* @__PURE__ */ (0,
|
|
2743
|
+
const formContent = /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("form", { onSubmit: handleSubmit, className: cn("space-y-4", classNames?.form), children: [
|
|
2744
|
+
!signerType ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2745
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-2", role: "group", "aria-labelledby": "add-signer-type-label", children: [
|
|
2746
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Label, { id: "add-signer-type-label", className: classNames?.label, children: "Signer type" }),
|
|
2747
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap gap-2", children: [
|
|
2748
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2551
2749
|
Button,
|
|
2552
2750
|
{
|
|
2553
2751
|
type: "button",
|
|
@@ -2558,7 +2756,7 @@ function AddSignerForm({
|
|
|
2558
2756
|
children: "Email"
|
|
2559
2757
|
}
|
|
2560
2758
|
),
|
|
2561
|
-
/* @__PURE__ */ (0,
|
|
2759
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2562
2760
|
Button,
|
|
2563
2761
|
{
|
|
2564
2762
|
type: "button",
|
|
@@ -2569,7 +2767,7 @@ function AddSignerForm({
|
|
|
2569
2767
|
children: "Phone"
|
|
2570
2768
|
}
|
|
2571
2769
|
),
|
|
2572
|
-
/* @__PURE__ */ (0,
|
|
2770
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2573
2771
|
Button,
|
|
2574
2772
|
{
|
|
2575
2773
|
type: "button",
|
|
@@ -2580,7 +2778,7 @@ function AddSignerForm({
|
|
|
2580
2778
|
children: "Passkey"
|
|
2581
2779
|
}
|
|
2582
2780
|
),
|
|
2583
|
-
/* @__PURE__ */ (0,
|
|
2781
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2584
2782
|
Button,
|
|
2585
2783
|
{
|
|
2586
2784
|
type: "button",
|
|
@@ -2593,7 +2791,7 @@ function AddSignerForm({
|
|
|
2593
2791
|
)
|
|
2594
2792
|
] })
|
|
2595
2793
|
] }),
|
|
2596
|
-
asDialog && /* @__PURE__ */ (0,
|
|
2794
|
+
asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DialogFooter, { className: "gap-2 sm:gap-0", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2597
2795
|
Button,
|
|
2598
2796
|
{
|
|
2599
2797
|
type: "button",
|
|
@@ -2604,10 +2802,10 @@ function AddSignerForm({
|
|
|
2604
2802
|
children: "Cancel"
|
|
2605
2803
|
}
|
|
2606
2804
|
) })
|
|
2607
|
-
] }) : signerType === "email" ? /* @__PURE__ */ (0,
|
|
2608
|
-
/* @__PURE__ */ (0,
|
|
2609
|
-
/* @__PURE__ */ (0,
|
|
2610
|
-
/* @__PURE__ */ (0,
|
|
2805
|
+
] }) : signerType === "email" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2806
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-2", children: [
|
|
2807
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Label, { htmlFor: "add-signer-email", className: classNames?.label, children: "Email" }),
|
|
2808
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2611
2809
|
Input,
|
|
2612
2810
|
{
|
|
2613
2811
|
id: "add-signer-email",
|
|
@@ -2622,8 +2820,8 @@ function AddSignerForm({
|
|
|
2622
2820
|
}
|
|
2623
2821
|
)
|
|
2624
2822
|
] }),
|
|
2625
|
-
asDialog && /* @__PURE__ */ (0,
|
|
2626
|
-
/* @__PURE__ */ (0,
|
|
2823
|
+
asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogFooter, { className: "gap-2 sm:gap-0", children: [
|
|
2824
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2627
2825
|
Button,
|
|
2628
2826
|
{
|
|
2629
2827
|
type: "button",
|
|
@@ -2634,10 +2832,10 @@ function AddSignerForm({
|
|
|
2634
2832
|
children: "Back"
|
|
2635
2833
|
}
|
|
2636
2834
|
),
|
|
2637
|
-
/* @__PURE__ */ (0,
|
|
2835
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2638
2836
|
] }),
|
|
2639
|
-
!asDialog && /* @__PURE__ */ (0,
|
|
2640
|
-
/* @__PURE__ */ (0,
|
|
2837
|
+
!asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex gap-2", children: [
|
|
2838
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2641
2839
|
Button,
|
|
2642
2840
|
{
|
|
2643
2841
|
type: "button",
|
|
@@ -2648,12 +2846,12 @@ function AddSignerForm({
|
|
|
2648
2846
|
children: "Back"
|
|
2649
2847
|
}
|
|
2650
2848
|
),
|
|
2651
|
-
/* @__PURE__ */ (0,
|
|
2849
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2652
2850
|
] })
|
|
2653
|
-
] }) : signerType === "phone" ? /* @__PURE__ */ (0,
|
|
2654
|
-
/* @__PURE__ */ (0,
|
|
2655
|
-
/* @__PURE__ */ (0,
|
|
2656
|
-
/* @__PURE__ */ (0,
|
|
2851
|
+
] }) : signerType === "phone" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2852
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-2", children: [
|
|
2853
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Label, { htmlFor: "add-signer-phone", className: classNames?.label, children: "Phone number" }),
|
|
2854
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2657
2855
|
Input,
|
|
2658
2856
|
{
|
|
2659
2857
|
id: "add-signer-phone",
|
|
@@ -2668,8 +2866,8 @@ function AddSignerForm({
|
|
|
2668
2866
|
}
|
|
2669
2867
|
)
|
|
2670
2868
|
] }),
|
|
2671
|
-
asDialog && /* @__PURE__ */ (0,
|
|
2672
|
-
/* @__PURE__ */ (0,
|
|
2869
|
+
asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogFooter, { className: "gap-2 sm:gap-0", children: [
|
|
2870
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2673
2871
|
Button,
|
|
2674
2872
|
{
|
|
2675
2873
|
type: "button",
|
|
@@ -2680,10 +2878,10 @@ function AddSignerForm({
|
|
|
2680
2878
|
children: "Back"
|
|
2681
2879
|
}
|
|
2682
2880
|
),
|
|
2683
|
-
/* @__PURE__ */ (0,
|
|
2881
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2684
2882
|
] }),
|
|
2685
|
-
!asDialog && /* @__PURE__ */ (0,
|
|
2686
|
-
/* @__PURE__ */ (0,
|
|
2883
|
+
!asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex gap-2", children: [
|
|
2884
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2687
2885
|
Button,
|
|
2688
2886
|
{
|
|
2689
2887
|
type: "button",
|
|
@@ -2694,12 +2892,12 @@ function AddSignerForm({
|
|
|
2694
2892
|
children: "Back"
|
|
2695
2893
|
}
|
|
2696
2894
|
),
|
|
2697
|
-
/* @__PURE__ */ (0,
|
|
2895
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2698
2896
|
] })
|
|
2699
|
-
] }) : signerType === "external" ? /* @__PURE__ */ (0,
|
|
2700
|
-
/* @__PURE__ */ (0,
|
|
2701
|
-
/* @__PURE__ */ (0,
|
|
2702
|
-
/* @__PURE__ */ (0,
|
|
2897
|
+
] }) : signerType === "external" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2898
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-2", children: [
|
|
2899
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Label, { htmlFor: "add-signer-address", className: classNames?.label, children: "Wallet address" }),
|
|
2900
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2703
2901
|
Input,
|
|
2704
2902
|
{
|
|
2705
2903
|
id: "add-signer-address",
|
|
@@ -2713,8 +2911,8 @@ function AddSignerForm({
|
|
|
2713
2911
|
}
|
|
2714
2912
|
)
|
|
2715
2913
|
] }),
|
|
2716
|
-
asDialog && /* @__PURE__ */ (0,
|
|
2717
|
-
/* @__PURE__ */ (0,
|
|
2914
|
+
asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogFooter, { className: "gap-2 sm:gap-0", children: [
|
|
2915
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2718
2916
|
Button,
|
|
2719
2917
|
{
|
|
2720
2918
|
type: "button",
|
|
@@ -2725,10 +2923,10 @@ function AddSignerForm({
|
|
|
2725
2923
|
children: "Back"
|
|
2726
2924
|
}
|
|
2727
2925
|
),
|
|
2728
|
-
/* @__PURE__ */ (0,
|
|
2926
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2729
2927
|
] }),
|
|
2730
|
-
!asDialog && /* @__PURE__ */ (0,
|
|
2731
|
-
/* @__PURE__ */ (0,
|
|
2928
|
+
!asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex gap-2", children: [
|
|
2929
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2732
2930
|
Button,
|
|
2733
2931
|
{
|
|
2734
2932
|
type: "button",
|
|
@@ -2739,44 +2937,45 @@ function AddSignerForm({
|
|
|
2739
2937
|
children: "Back"
|
|
2740
2938
|
}
|
|
2741
2939
|
),
|
|
2742
|
-
/* @__PURE__ */ (0,
|
|
2940
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2743
2941
|
] })
|
|
2744
2942
|
] }) : null,
|
|
2745
|
-
error && /* @__PURE__ */ (0,
|
|
2943
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: cn("text-sm text-destructive", classNames?.error), role: "alert", children: error })
|
|
2746
2944
|
] });
|
|
2747
2945
|
if (asDialog) {
|
|
2748
|
-
return /* @__PURE__ */ (0,
|
|
2749
|
-
/* @__PURE__ */ (0,
|
|
2750
|
-
/* @__PURE__ */ (0,
|
|
2751
|
-
/* @__PURE__ */ (0,
|
|
2946
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Dialog, { open, onOpenChange: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogContent, { className: cn(classNames?.dialog), children: [
|
|
2947
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogHeader, { children: [
|
|
2948
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DialogTitle, { children: "Add signer" }),
|
|
2949
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DialogDescription, { children: "Add a new signer to this wallet." })
|
|
2752
2950
|
] }),
|
|
2753
2951
|
formContent
|
|
2754
2952
|
] }) });
|
|
2755
2953
|
}
|
|
2756
|
-
return /* @__PURE__ */ (0,
|
|
2757
|
-
/* @__PURE__ */ (0,
|
|
2954
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: cn(className, classNames?.root), "data-cilantro-add-signer-form": true, children: [
|
|
2955
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h3", { className: "text-sm font-medium mb-2", children: "Add signer" }),
|
|
2758
2956
|
formContent
|
|
2759
2957
|
] });
|
|
2760
2958
|
}
|
|
2761
2959
|
|
|
2762
2960
|
// src/components/SignerList.tsx
|
|
2763
|
-
var
|
|
2764
|
-
var
|
|
2961
|
+
var import_react14 = require("react");
|
|
2962
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2765
2963
|
function SignerList({
|
|
2766
2964
|
walletId,
|
|
2767
2965
|
className,
|
|
2768
2966
|
classNames,
|
|
2769
2967
|
onSignerAdded,
|
|
2968
|
+
useSkeleton = true,
|
|
2770
2969
|
children
|
|
2771
2970
|
}) {
|
|
2772
2971
|
const { signers, isLoading, error, refresh } = useSigners({ walletId });
|
|
2773
|
-
const [addSignerOpen, setAddSignerOpen] = (0,
|
|
2972
|
+
const [addSignerOpen, setAddSignerOpen] = (0, import_react14.useState)(false);
|
|
2774
2973
|
const handleAddSuccess = () => {
|
|
2775
2974
|
refresh();
|
|
2776
2975
|
onSignerAdded?.();
|
|
2777
2976
|
};
|
|
2778
2977
|
if (children) {
|
|
2779
|
-
return /* @__PURE__ */ (0,
|
|
2978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
2780
2979
|
children({
|
|
2781
2980
|
signers,
|
|
2782
2981
|
isLoading,
|
|
@@ -2784,7 +2983,7 @@ function SignerList({
|
|
|
2784
2983
|
refresh,
|
|
2785
2984
|
openAddSigner: () => setAddSignerOpen(true)
|
|
2786
2985
|
}),
|
|
2787
|
-
/* @__PURE__ */ (0,
|
|
2986
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2788
2987
|
AddSignerForm,
|
|
2789
2988
|
{
|
|
2790
2989
|
walletId,
|
|
@@ -2797,31 +2996,46 @@ function SignerList({
|
|
|
2797
2996
|
] });
|
|
2798
2997
|
}
|
|
2799
2998
|
if (!walletId) {
|
|
2800
|
-
return /* @__PURE__ */ (0,
|
|
2999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-signer-list": true, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "Select a wallet first." }) });
|
|
2801
3000
|
}
|
|
2802
|
-
return /* @__PURE__ */ (0,
|
|
2803
|
-
/* @__PURE__ */ (0,
|
|
2804
|
-
/* @__PURE__ */ (0,
|
|
2805
|
-
/* @__PURE__ */ (0,
|
|
3001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cn(className, classNames?.root), "data-cilantro-signer-list": true, "aria-busy": isLoading, "aria-live": "polite", children: [
|
|
3002
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cn("flex items-center justify-between gap-2 mb-2", classNames?.header), children: [
|
|
3003
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-sm font-medium", children: "Signers" }),
|
|
3004
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2806
3005
|
Button,
|
|
2807
3006
|
{
|
|
2808
3007
|
type: "button",
|
|
2809
|
-
size: "
|
|
3008
|
+
size: "touch",
|
|
2810
3009
|
variant: "outline",
|
|
2811
3010
|
className: classNames?.addButton,
|
|
2812
3011
|
onClick: () => setAddSignerOpen(true),
|
|
2813
3012
|
disabled: isLoading,
|
|
3013
|
+
"aria-label": "Add signer",
|
|
2814
3014
|
children: "Add signer"
|
|
2815
3015
|
}
|
|
2816
3016
|
)
|
|
2817
3017
|
] }),
|
|
2818
|
-
isLoading
|
|
3018
|
+
isLoading && useSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3019
|
+
"div",
|
|
3020
|
+
{
|
|
3021
|
+
className: cn("space-y-1", classNames?.loading),
|
|
3022
|
+
"aria-busy": "true",
|
|
3023
|
+
"aria-live": "polite",
|
|
3024
|
+
children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3025
|
+
Skeleton,
|
|
3026
|
+
{
|
|
3027
|
+
className: cn("h-5 w-full rounded-md", classNames?.skeleton)
|
|
3028
|
+
},
|
|
3029
|
+
i
|
|
3030
|
+
))
|
|
3031
|
+
}
|
|
3032
|
+
) : isLoading ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "Loading signers..." }) : error ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: cn("text-sm text-destructive", classNames?.message), role: "alert", children: error }) : signers.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "No signers. Add one to get started." }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("ul", { className: cn("space-y-1", classNames?.list), role: "list", children: signers.map((signer) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("li", { className: cn("text-sm", classNames?.item), children: [
|
|
2819
3033
|
getSignerDisplayName(signer),
|
|
2820
3034
|
" (",
|
|
2821
3035
|
getSignerTypeLabel(signer.type || signer.signerType || ""),
|
|
2822
3036
|
")"
|
|
2823
3037
|
] }, signer.id)) }),
|
|
2824
|
-
/* @__PURE__ */ (0,
|
|
3038
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2825
3039
|
AddSignerForm,
|
|
2826
3040
|
{
|
|
2827
3041
|
walletId,
|
|
@@ -2833,6 +3047,74 @@ function SignerList({
|
|
|
2833
3047
|
)
|
|
2834
3048
|
] });
|
|
2835
3049
|
}
|
|
3050
|
+
|
|
3051
|
+
// src/ui/theme-provider.tsx
|
|
3052
|
+
var React9 = __toESM(require("react"));
|
|
3053
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3054
|
+
var DEFAULT_THEME_CSS = `
|
|
3055
|
+
:root,[data-theme="light"]{--background:0 0% 100%;--foreground:222.2 84% 4.9%;--primary:222.2 47.4% 11.2%;--primary-foreground:210 40% 98%;--muted:210 40% 96.1%;--muted-foreground:215.4 16.3% 46.9%;--border:214.3 31.8% 91.4%;--input:214.3 31.8% 91.4%;--ring:222.2 84% 4.9%;--destructive:0 84.2% 60.2%;--destructive-foreground:210 40% 98%;--accent:210 40% 96.1%;--accent-foreground:222.2 47.4% 11.2%;--popover:0 0% 100%;--popover-foreground:222.2 84% 4.9%;--card:0 0% 100%;--card-foreground:222.2 84% 4.9%}
|
|
3056
|
+
[data-theme="dark"]{--background:222.2 84% 4.9%;--foreground:210 40% 98%;--primary:210 40% 98%;--primary-foreground:222.2 47.4% 11.2%;--muted:217.2 32.6% 17.5%;--muted-foreground:215 20.2% 65.1%;--border:217.2 32.6% 17.5%;--input:217.2 32.6% 17.5%;--ring:212.7 26.8% 83.9%;--destructive:0 62.8% 30.6%;--destructive-foreground:210 40% 98%;--accent:217.2 32.6% 17.5%;--accent-foreground:210 40% 98%;--popover:222.2 84% 4.9%;--popover-foreground:210 40% 98%;--card:222.2 84% 4.9%;--card-foreground:210 40% 98%}
|
|
3057
|
+
`;
|
|
3058
|
+
function getSystemTheme() {
|
|
3059
|
+
if (typeof window === "undefined") return "dark";
|
|
3060
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
3061
|
+
}
|
|
3062
|
+
function ThemeProvider({
|
|
3063
|
+
theme = "system",
|
|
3064
|
+
defaultTheme = "dark",
|
|
3065
|
+
storageKey,
|
|
3066
|
+
className,
|
|
3067
|
+
children,
|
|
3068
|
+
injectStyles = true
|
|
3069
|
+
}) {
|
|
3070
|
+
const [resolved, setResolved] = React9.useState(() => {
|
|
3071
|
+
if (theme === "light") return "light";
|
|
3072
|
+
if (theme === "dark") return "dark";
|
|
3073
|
+
if (typeof window !== "undefined" && storageKey) {
|
|
3074
|
+
const stored = window.localStorage.getItem(storageKey);
|
|
3075
|
+
if (stored === "light" || stored === "dark") return stored;
|
|
3076
|
+
}
|
|
3077
|
+
return defaultTheme;
|
|
3078
|
+
});
|
|
3079
|
+
React9.useEffect(() => {
|
|
3080
|
+
if (theme === "light") {
|
|
3081
|
+
setResolved("light");
|
|
3082
|
+
return;
|
|
3083
|
+
}
|
|
3084
|
+
if (theme === "dark") {
|
|
3085
|
+
setResolved("dark");
|
|
3086
|
+
return;
|
|
3087
|
+
}
|
|
3088
|
+
const system = getSystemTheme();
|
|
3089
|
+
setResolved(system);
|
|
3090
|
+
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
3091
|
+
const listener = () => {
|
|
3092
|
+
const next = mql.matches ? "dark" : "light";
|
|
3093
|
+
setResolved(next);
|
|
3094
|
+
if (storageKey) window.localStorage.setItem(storageKey, next);
|
|
3095
|
+
};
|
|
3096
|
+
mql.addEventListener("change", listener);
|
|
3097
|
+
return () => mql.removeEventListener("change", listener);
|
|
3098
|
+
}, [theme, storageKey]);
|
|
3099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
3100
|
+
injectStyles && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3101
|
+
"style",
|
|
3102
|
+
{
|
|
3103
|
+
dangerouslySetInnerHTML: { __html: DEFAULT_THEME_CSS },
|
|
3104
|
+
"data-cilantro-theme-styles": true
|
|
3105
|
+
}
|
|
3106
|
+
),
|
|
3107
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3108
|
+
"div",
|
|
3109
|
+
{
|
|
3110
|
+
className: cn(className),
|
|
3111
|
+
"data-theme": resolved,
|
|
3112
|
+
"data-cilantro-theme-provider": true,
|
|
3113
|
+
children
|
|
3114
|
+
}
|
|
3115
|
+
)
|
|
3116
|
+
] });
|
|
3117
|
+
}
|
|
2836
3118
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2837
3119
|
0 && (module.exports = {
|
|
2838
3120
|
AddSignerForm,
|
|
@@ -2847,6 +3129,8 @@ function SignerList({
|
|
|
2847
3129
|
SIGNER_TYPES,
|
|
2848
3130
|
SignerList,
|
|
2849
3131
|
SignerSelector,
|
|
3132
|
+
Skeleton,
|
|
3133
|
+
ThemeProvider,
|
|
2850
3134
|
TransactionSigningForm,
|
|
2851
3135
|
WalletProvider,
|
|
2852
3136
|
WalletSelector,
|
|
@@ -2857,11 +3141,16 @@ function SignerList({
|
|
|
2857
3141
|
signAndSendTransactionWithSigner,
|
|
2858
3142
|
signMessageWithSigner,
|
|
2859
3143
|
signTransactionWithSigner,
|
|
3144
|
+
useCanSign,
|
|
2860
3145
|
useCilantroAuth,
|
|
3146
|
+
useDelegatedKeys,
|
|
2861
3147
|
useMessageSigning,
|
|
3148
|
+
useSelectedWallet,
|
|
2862
3149
|
useSignerSelection,
|
|
2863
3150
|
useSigners,
|
|
3151
|
+
useSignersForSelectedWallet,
|
|
2864
3152
|
useTransactionSigning,
|
|
3153
|
+
useWalletAddress,
|
|
2865
3154
|
useWallets
|
|
2866
3155
|
});
|
|
2867
3156
|
//# sourceMappingURL=index.js.map
|