import type { Color } from '../adapters/real'; 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({ color }: { color?: Color } = {}) { if (color) return <>

出生底色 · 真实排盘

{color.calendar &&
公历
{color.calendar.solar}
农历
{color.calendar.lunar}{color.calendar.leap_month && 闰月}
出生时辰
{color.calendar.hour} · {color.calendar.hour_range}
排盘时间
北京时间 {color.calendar.calculation_time}
}
{[['year','年柱'], ['month','月柱'], ['day','日柱'], ['time','时柱']].map(([key, label]) =>
{label}{color.pillars[key]}
)}
四柱、日主和农历,分别是什么?

四柱是出生年、月、日、时的四组干支,合起来为八个字。日柱的第一个字叫日主,是解释组合的参照。五行描述组合的侧重,十神描述各天干与日主的关系,不是十种好坏标签。

{color.calendar?.rule || '月柱按节气划分,与农历月份不是同一回事。'}

{color.interpretation || '当前档案尚未提供分层说明,请更新服务后重试。原底色保留。'}

{color.sections?.map(section =>

{section.title}

{section.text}

这段说明的依据

{section.basis}

)}

确认创建后,生辰与底色只读;后来的成长另存。

; return <>

出生底色 · 演示预览

{['年柱', '月柱', '日柱', '时柱'].map(p =>
{p}待接
)}

演示不执行排盘,不用固定八字或性格代替计算。普通入口会显示真实公历、农历、四柱和六层底色说明。

确认创建后,生辰与底色只读,成长另存。

; }