polish(admin): 抽出后台控件包并统一各页布局与交互

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-16 19:03:21 +08:00
parent cfc6c1403b
commit f73d2a89e8
23 changed files with 1720 additions and 1412 deletions

View File

@@ -0,0 +1,61 @@
"use client";
import { Search, X } from "lucide-react";
import type { FormEvent } from "react";
/** 左图标、可清除、Enter 提交;不要再并排「搜索」按钮 */
export default function AdminSearchField({
value,
onChange,
onSubmit,
onClear,
placeholder,
ariaLabel,
}: {
value: string;
onChange: (v: string) => void;
onSubmit?: () => void;
onClear?: () => void;
placeholder?: string;
ariaLabel: string;
}) {
const handleSubmit = (e: FormEvent) => {
e.preventDefault();
onSubmit?.();
};
const clear = () => {
onChange("");
onClear?.();
};
return (
<form onSubmit={handleSubmit} className="relative flex-1 min-w-0" role="search">
<Search
size={15}
className="absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none"
style={{ color: "var(--ink-3)" }}
aria-hidden
/>
<input
type="text"
value={value}
onChange={(e) => onChange(e.target.value)}
placeholder={placeholder}
aria-label={ariaLabel}
className="field pl-10 pr-9 py-2.5"
/>
{value ? (
<button
type="button"
onClick={clear}
aria-label="清除搜索"
className="absolute right-2.5 top-1/2 -translate-y-1/2 w-6 h-6 inline-flex items-center justify-center rounded-full transition-colors hover:bg-[var(--panel-2)]"
style={{ color: "var(--ink-3)" }}
>
<X size={14} />
</button>
) : null}
</form>
);
}