import { useEffect, useRef, useId, cloneElement, isValidElement, type ReactElement, type ReactNode } from 'react';
export function Icon({ name }: {
name: string;
}) { return ; }
export function Button({ children, onClick, disabled = false, primary = false, small = true }: {
children: ReactNode;
onClick?: () => void;
disabled?: boolean;
primary?: boolean;
small?: boolean;
}) { return ; }
export function Status({ text, error = false }: {
text: string;
error?: boolean;
}) { return text ?
{text}
: null; }
export function Field({ label, children, hint }: {
label: string;
children: ReactNode;
hint?: string;
}) { const id = useId(); return ; }
export function Modal({ title, children, onClose, onConfirm, confirm = '确认', danger = false, disabled = false }: {
title: string;
children: ReactNode;
onClose: () => void;
onConfirm: () => void;
confirm?: string;
danger?: boolean;
disabled?: boolean;
}) {
const root = useRef(null);
const close = useRef(onClose);
close.current = onClose;
useEffect(() => { const prev = document.activeElement as HTMLElement | null; (root.current?.querySelector('input,button:not(:disabled)') || root.current)?.focus(); const key = (e: KeyboardEvent) => { if (e.key === 'Escape') {
e.stopImmediatePropagation();
close.current();
} if (e.key === 'Tab') {
const nodes = root.current?.querySelectorAll('button:not(:disabled),input');
if (nodes?.length) {
const first = nodes[0], last = nodes[nodes.length - 1];
if (e.shiftKey && document.activeElement === first) {
e.preventDefault();
last.focus();
}
else if (!e.shiftKey && document.activeElement === last) {
e.preventDefault();
first.focus();
}
}
} }; document.addEventListener('keydown', key, true); return () => { document.removeEventListener('keydown', key, true); prev?.focus(); }; }, []);
return <>
{title}
{children}
>;
}
export function BaseColor() { return <>
出生底色 · 演示预览
{['年柱', '月柱', '日柱', '时柱'].map(p =>
{p}待接
)}
细腻慢热有自己的节奏
这些是演示倾向,不是固定台词。真实排盘待接 Python 八字编译器,不以示例代替计算。
确认创建后,生辰与底色只读,成长另存。
>; }