// Adapted from jalcoui (MIT) — github.com/jal-co/ui // // Read-only environment variable table with masked values, click-to-reveal, // and per-row copy. Designed for settings pages, deploy previews, and docs. // // - Semantic tokens only (success / warning / info / destructive / muted). // - No motion library — Tailwind `transition-colors` for hover feedback. // - Requires at the host root; mounts no providers itself. 'use client'; import * as React from 'react'; import { Check, ClipboardList, Copy, Eye, EyeOff } from 'lucide-react'; import { cn } from '@djangocfg/ui-core/lib'; import { ENV_TONE_CLASSES, getEnvTone, type EnvTableProps, type EnvVariable, } from './types'; import { maskValue, useEnvMask } from './hooks/useEnvMask'; interface RowProps { variable: EnvVariable; revealed: boolean; copied: boolean; onToggleReveal: () => void; onCopy: () => void; } function EnvRow({ variable, revealed, copied, onToggleReveal, onCopy }: RowProps) { const tone = getEnvTone(variable.environment); const displayValue = revealed ? variable.value : maskValue(variable.value); return (
{/* Key */}
{variable.key} {variable.required && ( * )} {variable.environment && ( {variable.environment} )}
{/* Value */}
{displayValue} {variable.description && (

{variable.description}

)}
{/* Actions */}
); } export function EnvTable({ variables, title, defaultRevealed = false, emptyLabel = 'No environment variables.', className, ...props }: EnvTableProps) { const { revealed, allRevealed, toggleIndex, toggleAll, copiedTarget, copyValue, copyAllAsEnv, } = useEnvMask({ variables, defaultRevealed }); if (variables.length === 0) { return (
{emptyLabel}
); } const copiedAll = copiedTarget === 'all'; return (
{/* Header */}
{title && (

{title}

)} {variables.length}
{/* Rows */}
{variables.map((variable, i) => ( toggleIndex(i)} onCopy={() => copyValue(i, variable.value)} /> ))}
); }