import { useEffect, useRef, useState, type ReactNode } from "react"; import { createPortal } from "react-dom"; import { Check, ChevronDown, ChevronUp, X } from "lucide-react"; import { Button } from "./ui/button"; import { FieldHint } from "./ui/field-hint"; import type { StatusTone } from "../domain/statuses"; export type OpsTone = StatusTone | "brand"; /** 管理页通用右侧抽屉;视觉与工单/每日任务页保持一致。wide=66% 宽(册10 执行记录抽屉契约)。 */ export function OpsDrawer({ title, subtitle, onClose, wide = false, children }: { title: string; subtitle: string; onClose: () => void; wide?: boolean; children: ReactNode }) { const ref = useRef(null); useEffect(() => { const dialog = ref.current; if (!dialog) return; const previous = document.activeElement as HTMLElement | null; const overflow = document.body.style.overflow; document.body.style.overflow = "hidden"; dialog.showModal(); return () => { dialog.close(); document.body.style.overflow = overflow; previous?.focus(); }; }, []); return { if (event.target === event.currentTarget) onClose(); }}>

{subtitle}

{title}

{children}
; } /** 状态徽章:颜色只表达状态,文字始终保留。 */ export function OpsStatus({ tone, children }: { tone: OpsTone; children: ReactNode }) { return {children}; } /** 分类小标签。 */ export function OpsTag({ tone, children }: { tone: OpsTone; children: ReactNode }) { return {children}; } export function OpsTableEmpty({ colSpan, children }: { colSpan: number; children: ReactNode }) { return
{children}
; } /** 保留分配比例,由浏览器按表格的实际宽度处理小数像素。 */ export function OpsTableColumns({ widths }: { widths: readonly number[] }) { const total = widths.reduce((sum, width) => sum + width, 0); return {widths.map((width, index) => )}; } /** * 字段口径问号:与编辑项标题后的问号同一套交互({@link FieldHint})—— * 鼠标移入或点击显示、移出/失焦/Esc 收起;浮层走 body 传送门+fixed,弹窗与台账的 overflow 容器不会裁掉它。 * ⚠️ 放进 `