/* global React, window */ // Ruticomidas — modal system. // Components listen for window 'rc:modal' CustomEvent with detail = { name, props } // Dispatching with name: null closes the modal. const { useState, useEffect, useMemo, useRef } = React; const D = window.RC_DATA; // ========================================================= // Shell // ========================================================= function ModalShell({ kicker, title, size, children, foot, onClose }) { useEffect(() => { const onKey = (e) => { if (e.key === 'Escape') onClose(); }; document.addEventListener('keydown', onKey); document.body.style.overflow = 'hidden'; return () => { document.removeEventListener('keydown', onKey); document.body.style.overflow = ''; }; }, [onClose]); const onBackdrop = (e) => { if (e.target === e.currentTarget) onClose(); }; return (