// HomePrimitives.jsx — primitives for the CVE Dashboard Home page kit.
// Lifted directly from frontend/src/App.js (the home view), normalized to
// match the same vocabulary the Reporting + Knowledge Base kits use.
//
// Exported on window.HOME for the assembly + docs files to consume.
const { useState: useHomeState } = React;
/* ── Tokens ──────────────────────────────────────────────────────
Identical palette to Reporting + KB. Home adds purple (Archer)
and teal (Ivanti) — both used as left-rail / title-glow colors
on the right-side panel stack. */
const H_COLORS = {
sky: '#0EA5E9',
skySoft: '#7DD3FC',
green: '#10B981',
amber: '#F59E0B',
amberSoft: '#FCD34D',
red: '#EF4444',
redSoft: '#FCA5A5',
purple: '#8B5CF6',
teal: '#0D9488',
};
/* Card chrome shared with the rest of the system. One chrome, every panel. */
const CARD_BG = 'linear-gradient(135deg, rgba(30,41,59,0.95) 0%, rgba(15,23,42,0.98) 100%)';
const CARD_BORDER = '1.5px solid rgba(14,165,233,0.12)';
const CARD_BORDER_HOVER = '1.5px solid rgba(14,165,233,0.35)';
/* ── StatCard ────────────────────────────────────────────────────
Top-of-page metric tile. Color-coded by tone — sky for neutral
counts, amber for "needs attention", red for critical. Top edge
has a soft horizontal glow line in the same color. */
function StatCard({ label, value, tone = 'sky', mono = true }) {
const c = H_COLORS[tone] || H_COLORS.sky;
const isAccent = tone !== 'neutral';
return (
{label}
{value}
);
}
/* ── HomeCard ────────────────────────────────────────────────────
Same chrome as Reporting's KbCard but without a label slot —
the home cards put their title inline above the body. Used as
the wrapper for Quick Lookup, the filter row, and CVE rows. */
function HomeCard({ children, padding = 24, hover = true, leftRail, style }) {
const [h, setH] = useHomeState(false);
return (
);
}
/* ── CardTitle ───────────────────────────────────────────────────
Mono uppercase, glow color matches the card's identity (sky for
neutral, amber for tickets, purple for Archer, teal for Ivanti). */
function CardTitle({ color = H_COLORS.sky, icon, children, action }) {
return (
);
}
function HomeSelect({ value, onChange, options }) {
return (
);
}
function FieldLabel({ icon, children }) {
return (
);
}
/* ── ResultBanner ────────────────────────────────────────────────
Sub-card used in Quick Lookup to surface scan results.
Tones: success (CVE addressed), warning (not found), error. */
function ResultBanner({ tone = 'success', icon, title, children }) {
const map = {
success: { c: H_COLORS.green, bg: 'rgba(16,185,129,0.10)', bd: 'rgba(16,185,129,0.30)' },
warning: { c: H_COLORS.amber, bg: 'rgba(245,158,11,0.10)', bd: 'rgba(245,158,11,0.30)' },
error: { c: H_COLORS.red, bg: 'rgba(239,68,68,0.10)', bd: 'rgba(239,68,68,0.30)' },
}[tone];
return (
{title}
{children}
);
}
/* ── BigStat ─────────────────────────────────────────────────────
The centered "active count + label" shown at the top of each
right-rail panel (Open Tickets · Archer · Ivanti). */
function BigStat({ value, label, color = H_COLORS.sky }) {
return (
{value}
{label}
);
}
/* ── MiniTicket ──────────────────────────────────────────────────
Compact card shown inside the right-rail scrollable lists.
Color-coded by category via the `tone` prop (amber/purple/teal). */
function MiniTicket({ keyText, cveId, vendor, status, tone = 'amber', summary, onEdit, onDelete }) {
const c = H_COLORS[tone] || H_COLORS.amber;
return (
{keyText}
{(onEdit || onDelete) && (
{onEdit && }
{onDelete && }
)}
{cveId}
{vendor}
{summary && (
{summary}
)}
{status && (
{status}
)}
);
}
const iconBtn = (color) => ({
background: 'transparent', border: 'none', color: 'var(--fg-2)',
cursor: 'pointer', padding: 2, display: 'inline-flex', alignItems: 'center',
transition: 'color 120ms ease',
});
/* ── CVERow ──────────────────────────────────────────────────────
The main "row" in the home feed. Collapsed = chevron · CVE-ID ·
description · meta row (severity badge, vendor count, doc count,
statuses). Expanded = full description + admin actions slot. */
function CVERow({ cveId, severity, description, vendorCount, docCount, statuses, expanded, onToggle, children }) {
return (
{expanded && children && (
{children}
)}
);
}
const metaText = {
fontFamily: 'var(--font-mono)', fontSize: 11, color: 'var(--fg-2)',
};
/* ── VendorEntry ─────────────────────────────────────────────────
Sub-card inside an expanded CVE row, one per vendor that filed
the CVE. Holds vendor name, severity, status, doc count, and
inline action buttons. */
function VendorEntry({ vendor, severity, status, docCount, children, onView, onEdit, onDelete }) {
return (
);
}
/* ── HomeIcon ────────────────────────────────────────────────────
Inline SVGs covering every icon used on the home page so the kit
has no external icon-font dependency. Keys mirror lucide-react names. */
function HomeIcon({ name, size = 16, color = 'currentColor' }) {
const p = {
width: size, height: size, viewBox: '0 0 24 24', fill: 'none',
stroke: color, strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round',
style: { display: 'inline-block', verticalAlign: 'middle' },
};
switch (name) {
case 'search': return ;
case 'filter': return ;
case 'alert': return ;
case 'check':
case 'success': return ;
case 'warning': return ;
case 'error':
case 'x': return ;
case 'shield': return ;
case 'activity': return ;
case 'doc': return ;
case 'eye': return ;
case 'edit': return ;
case 'trash': return ;
case 'plus': return ;
case 'refresh': return ;
case 'chevron': return ;
case 'upload': return ;
case 'download': return ;
case 'calendar': return ;
default: return ;
}
}
/* ── CalendarMini ────────────────────────────────────────────────
Minimal calendar surface for the right rail. Static — accepts a
`today` index and an optional `markedDays` map for severity dots. */
function CalendarMini({ month = 'April 2026', today = 26, markedDays = {} }) {
const dows = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
// April 2026 starts on Wednesday — empty cells for S/M/T
const startOffset = 3;
const daysInMonth = 30;
const cells = [...Array(startOffset).fill(null), ...Array.from({ length: daysInMonth }, (_, i) => i + 1)];
return (
{month}
{dows.map((d, i) => (
{d}
))}
{cells.map((day, i) => {
if (day === null) return ;
const mark = markedDays[day];
const isToday = day === today;
return (
);
})}
);
}
const navBtn = {
background: 'transparent', border: '1px solid rgba(14,165,233,0.25)',
color: H_COLORS.sky, borderRadius: 4, width: 22, height: 22,
fontFamily: 'var(--font-mono)', fontSize: 12, cursor: 'pointer',
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
};
/* ── ArchiveSummary ──────────────────────────────────────────────
The bar of state pills that lives at the top of the Ivanti card.
Each pill shows an Ivanti workflow state + count, color-coded. */
function ArchiveSummary({ items, activeFilter, onSelect }) {
return (
{items.map(it => {
const c = H_COLORS[it.tone] || H_COLORS.teal;
const active = activeFilter === it.label;
return (
);
})}
);
}
/* ── ScrollList ──────────────────────────────────────────────────
Generic max-height scroll wrapper for the right-rail panels. */
function ScrollList({ maxHeight = 300, children }) {
return (
{children}
);
}
/* ── EmptyState ──────────────────────────────────────────────────
Center-aligned check-circle + caption, used inside ScrollList
when a panel has no items. */
function EmptyState({ icon = 'check', tone = 'green', children }) {
const c = H_COLORS[tone] || H_COLORS.green;
return (