/* Powermieter — shared UI primitives. Exports to window. */
const { useState, useRef, useEffect, useId } = React;
/* ---------- Brand ---------- */
function Brandmark({ size = 34 }) {
return (
);
}
function Logo({ size = 34, light }) {
return (
POWERHOUSE{' '}
360
);
}
/* ---------- Button ---------- */
function Button({ variant = 'primary', size, block, icon, iconRight, className, children, onClick, type, disabled, style, title, id }) {
const cls = ['btn', `btn-${variant}`, size && `btn-${size}`, block && 'btn-block', className].filter(Boolean).join(' ');
return (
);
}
/* ---------- Chip ---------- */
function Chip({ tone, icon, children }) {
return {icon}{children};
}
/* ---------- Process navigation (the 4-step stepper) ---------- */
const STEPS = [
{ n: 1, label: 'Interesse', short: 'Interesse', icon: I.spark },
{ n: 2, label: 'Registrierung', short: 'Daten', icon: I.user },
{ n: 3, label: 'Vertragsabschluss',short: 'Vertrag', icon: I.signature },
{ n: 4, label: 'Aktivierung', short: 'Aktiv', icon: I.checkBold },
];
function ProcessNav({ current, maxReached = current, onJump, compact }) {
return (
);
}
/* ---------- Form field wrapper ---------- */
function Field({ label, required, optional, hint, error, htmlFor, tip, children }) {
return (
{label && (
)}
{children}
{error ? {error}
: hint ? {hint} : null}
);
}
function TextInput({ error, affix, ...rest }) {
const cls = 'input' + (error ? ' input-err' : '');
if (affix) return (
{affix}
);
return ;
}
function TextArea({ error, ...rest }) {
return ;
}
function Select({ error, children, ...rest }) {
return (
);
}
/* ---------- Checkbox ---------- */
function Checkbox({ checked, onChange, children }) {
return (
);
}
/* ---------- Segmented ---------- */
function Segmented({ value, onChange, options }) {
return (
{options.map(o => (
))}
);
}
/* ---------- Tooltip ---------- */
function Tooltip({ text, children }) {
return (
{children}
{text}
);
}
/* ---------- Alert ---------- */
function Alert({ tone = 'info', icon, children }) {
const def = { info: I.info, positive: I.shield, warn: I.alert }[tone];
const Ic = icon ? () => icon : def;
return ;
}
/* ---------- Accordion ---------- */
function AccordionItem({ q, defaultOpen, children }) {
const [open, setOpen] = useState(!!defaultOpen);
const ref = useRef(null);
const [h, setH] = useState(defaultOpen ? 'auto' : 0);
useEffect(() => {
if (!ref.current) return;
setH(open ? ref.current.scrollHeight : 0);
}, [open]);
return (
);
}
function Accordion({ children }) { return {children}
; }
/* ---------- Stat ---------- */
function Stat({ value, label, tone, sub }) {
return (
{value}
{label}
{sub &&
{sub}
}
);
}
/* ---------- Benefit card ---------- */
function BenefitCard({ icon, title, children }) {
return (
{icon}
{title}
{children}
);
}
/* ---------- Section header ---------- */
function FormSection({ step, title, desc, children }) {
return (
);
}
Object.assign(window, {
Brandmark, Logo, Button, Chip, ProcessNav, STEPS, Field, TextInput, TextArea,
Select, Checkbox, Segmented, Tooltip, Alert, Accordion, AccordionItem, Stat,
BenefitCard, FormSection,
});