// Primitives — reusable building blocks for the Swivy console
const { useState, useEffect, useRef, useCallback, useMemo } = React;
// --- Status pill
const Status = ({ kind, children }) => {
const labels = {
active: "Active", pending: "Pending", revoked: "Revoked",
verified: "Verified", failed: "Failed", action: "Requires action", neutral: children,
};
return (
{children || labels[kind]}
);
};
// --- Truncated id / address with copy
const MonoId = ({ children, full }) => {
const [copied, setCopied] = useState(false);
const onCopy = (e) => {
e.stopPropagation();
navigator.clipboard?.writeText(full || children);
setCopied(true);
setTimeout(() => setCopied(false), 1200);
};
return (
{children}
{copied ? : }
);
};
// --- Chain badge
const Chain = ({ chain }) => {
const c = CHAINS.find(x => x.key === chain) || { key: chain, label: chain, glyph: chain[0] };
return (
{c.glyph}
{c.label}
);
};
// --- Button
const Btn = (props) => {
const { variant = "secondary", size, children, icon, iconRight, ...rest } = props;
return (
);
};
// --- Card
const Card = ({ title, sub, actions, children, bodyClass = "" }) => (
{(title || actions) && (
{title &&
{title}
}
{sub &&
{sub}
}
{actions}
)}
{children}
);
// --- Field
const Field = ({ label, hint, error, required, children }) => (
{label && (
)}
{children}
{hint && !error &&
{hint}
}
{error &&
{error}
}
);
// --- Segmented
const Segmented = ({ value, onChange, options }) => (
{options.map(o => (
))}
);
// --- Toggle
const Toggle = ({ on, onChange }) => (