import React, { useEffect, useRef } from 'react'; import Modal from '../../core/Modal'; import { Cross, LoaderIcon, TrashCan } from '../../icons'; /** * Small UI pieces shared by the MCP tab, styled like the rest of FlexTable. */ type NoticeType = 'info' | 'warn' | 'error'; const ICON_COLOR: Record< NoticeType, string > = { info: '#FC7E2A', warn: '#FC7E2A', error: '#D63638', }; /** * Notice box in FlexTable's style (grey card with an info icon, like the * "Themes cannot be used…" notice in Theme settings). */ export const Notice = ( { type = 'info', children, className = '', }: { type?: NoticeType; children: React.ReactNode; className?: string; } ) => (
{ children }
); /** * Inline spinner for buttons and short waits. */ export const Spinner = ( { label = '' }: { label?: string } ) => ( { LoaderIcon } ); /** * Skeleton lines (shimmer) while a section loads. */ export const Skeleton = ( { lines = 3, title = true }: { lines?: number; title?: boolean } ) => ( ); /** * A whole card in its loading state. */ export const SkeletonCard = ( { lines = 3, label = '' }: { lines?: number; label?: string } ) => (
); type ModalAction = { label: string; onClick: () => void; kind?: 'cancel' | 'confirm'; disabled?: boolean; }; /** * Confirmation modal with FlexTable's delete-modal design (cross, icon, * centred title and text, Cancel / confirm buttons). Closes on Esc and on a * click outside. */ export const ConfirmModal = ( { title, description, actions, onClose, busy = false, }: { title: string; description: React.ReactNode; actions: ModalAction[]; onClose: () => void; busy?: boolean; } ) => { const ref = useRef< HTMLDivElement >( null ); useEffect( () => { const onKey = ( e: KeyboardEvent ) => { if ( 'Escape' === e.key && ! busy ) { onClose(); } }; const onDown = ( e: MouseEvent ) => { if ( ! busy && ref.current && ! ref.current.contains( e.target as Node ) ) { onClose(); } }; document.addEventListener( 'keydown', onKey ); document.addEventListener( 'mousedown', onDown ); return () => { document.removeEventListener( 'keydown', onKey ); document.removeEventListener( 'mousedown', onDown ); }; }, [ onClose, busy ] ); return (
{ TrashCan }

{ title }

{ description }

{ actions.map( ( action ) => ( ) ) }
); };