Explorar o código

feat(web): 统一详情页行内编辑并常驻显示铅笔

sy hai 1 día
pai
achega
0608bd3c08

+ 89 - 0
web-scaffold/src/components/RecordInlineField.tsx

@@ -0,0 +1,89 @@
+import type { KeyboardEvent, ReactNode } from "react";
+import { Check, LoaderCircle, Lock, PencilLine, X } from "lucide-react";
+import { isImeComposing } from "../lib/ime";
+import { WORD_UNCONFIGURED } from "../lib/api/lockedCopy";
+import { Input } from "./ui/input";
+import { Tri } from "./triState";
+import "../styles/record-inline-field.css";
+
+export function InlineEditButton({ label, text, onClick, disabled }: {
+  label: string;
+  text?: string;
+  onClick: () => void;
+  disabled?: boolean;
+}) {
+  return <button type="button" className="record-inline-action is-primary" aria-label={label} title={label} disabled={disabled} onClick={onClick}>
+    <PencilLine size={14} aria-hidden="true" />
+    {text}
+  </button>;
+}
+
+export type RecordInlineFieldProps = {
+  id: string;
+  label: string;
+  value: string;
+  editing: boolean;
+  writable: boolean;
+  busy?: boolean;
+  onStart: () => void;
+  onChange: (value: string) => void;
+  onDone: () => void;
+  onCancel: () => void;
+  type?: "text" | "date" | "number";
+  inputMode?: "decimal" | "numeric" | "text";
+  min?: number;
+  max?: number;
+  step?: number | string;
+  placeholder?: string;
+  display?: ReactNode;
+  emptyText?: string;
+  invalid?: boolean;
+  error?: ReactNode;
+  selectOptions?: readonly { value: string; label: string }[];
+  editor?: ReactNode;
+  lockedReason?: string;
+  doneLabel?: string;
+};
+
+export function RecordInlineField({
+  id, label, value, editing, writable, busy = false, onStart, onChange, onDone, onCancel,
+  type = "text", inputMode, min, max, step, placeholder, display, emptyText = WORD_UNCONFIGURED,
+  invalid, error, selectOptions, editor, lockedReason, doneLabel = "完成编辑",
+}: RecordInlineFieldProps) {
+  const shown = display ?? (value || <Tri tone="missing" text={emptyText} />);
+  if (!writable && !lockedReason) return <span className="record-inline-value">{shown}</span>;
+  if (!writable || !editing) {
+    return <span className={writable ? "record-inline-field" : "record-inline-field is-locked"}>
+      <span className="record-inline-value">{shown}</span>
+      {writable
+        ? <InlineEditButton label={`编辑${label}`} disabled={busy} onClick={onStart} />
+        : <span className="record-inline-lock" role="img" aria-label={lockedReason} title={lockedReason}><Lock size={13} aria-hidden="true" /></span>}
+    </span>;
+  }
+
+  function handleKeyDown(event: KeyboardEvent<HTMLInputElement | HTMLSelectElement>) {
+    if (busy || isImeComposing(event)) return;
+    if (event.key === "Enter" || event.key === "Escape") {
+      event.preventDefault();
+      if (event.key === "Enter") onDone();
+      else onCancel();
+    }
+  }
+
+  return <span className="record-inline-editor">
+    {editor ?? (selectOptions ? (
+      <select id={id} aria-label={label} aria-invalid={invalid || undefined} autoFocus disabled={busy} value={value} onChange={(event) => onChange(event.target.value)} onKeyDown={handleKeyDown}>
+        {selectOptions.map((option) => <option key={option.value} value={option.value}>{option.label}</option>)}
+      </select>
+    ) : (
+      <Input id={id} aria-label={label} aria-invalid={invalid || undefined} autoFocus disabled={busy} type={type} inputMode={inputMode} min={min} max={max} step={step} placeholder={placeholder} value={value} onChange={(event) => onChange(event.target.value)} onKeyDown={handleKeyDown} />
+    ))}
+    <span className="record-inline-editor-actions">
+      <button type="button" className="record-inline-action is-primary" aria-label={busy ? "正在保存" : doneLabel} title={busy ? "正在保存…" : `${doneLabel}(Enter)`} disabled={busy} onClick={onDone}>
+        {busy ? <LoaderCircle aria-hidden="true" className="animate-spin" size={14} /> : <Check size={14} aria-hidden="true" />}
+      </button>
+      <button type="button" className="record-inline-action" aria-label="取消编辑" title="取消编辑(Escape)" disabled={busy} onClick={onCancel}><X size={14} aria-hidden="true" /></button>
+    </span>
+    {error}
+  </span>;
+}

+ 52 - 0
web-scaffold/src/components/__tests__/record-inline-field.test.tsx

@@ -0,0 +1,52 @@
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, expect, it, vi } from "vitest";
+import { RecordInlineField, type RecordInlineFieldProps } from "../RecordInlineField";
+
+afterEach(cleanup);
+
+function fieldProps() {
+  return {
+    id: "contact",
+    label: "联系人",
+    value: "李明",
+    editing: false,
+    writable: true,
+    onStart: vi.fn(),
+    onChange: vi.fn(),
+    onDone: vi.fn(),
+    onCancel: vi.fn(),
+  } satisfies RecordInlineFieldProps;
+}
+
+it("字段旁可直接点击编辑,只读字段显示锁定原因", () => {
+  const props = fieldProps();
+  const { rerender } = render(<RecordInlineField {...props} />);
+
+  fireEvent.click(screen.getByRole("button", { name: "编辑联系人" }));
+  expect(props.onStart).toHaveBeenCalledOnce();
+
+  rerender(<RecordInlineField {...props} writable={false} lockedReason="已经锁定" />);
+  expect(screen.queryByRole("button", { name: "编辑联系人" })).toBeNull();
+  expect(screen.getByRole("img", { name: "已经锁定" })).toBeTruthy();
+  expect(screen.getByText("李明")).toBeTruthy();
+});
+
+it("输入法合成期间不提交,退出合成后仍可用键盘完成或取消", () => {
+  const props = fieldProps();
+  const { rerender } = render(<RecordInlineField {...props} editing />);
+  const editor = screen.getByRole("textbox", { name: "联系人" });
+
+  fireEvent.keyDown(editor, { key: "Enter", isComposing: true });
+  fireEvent.keyDown(editor, { key: "Escape", keyCode: 229 });
+  expect(props.onDone).not.toHaveBeenCalled();
+  expect(props.onCancel).not.toHaveBeenCalled();
+
+  fireEvent.keyDown(editor, { key: "Enter" });
+  fireEvent.keyDown(editor, { key: "Escape" });
+  expect(props.onDone).toHaveBeenCalledOnce();
+  expect(props.onCancel).toHaveBeenCalledOnce();
+
+  rerender(<RecordInlineField {...props} editing busy />);
+  expect(screen.getByRole<HTMLButtonElement>("button", { name: "正在保存" }).disabled).toBe(true);
+  expect(screen.getByRole<HTMLButtonElement>("button", { name: "取消编辑" }).disabled).toBe(true);
+});

+ 7 - 22
web-scaffold/src/pages/AccountPages.tsx

@@ -1,7 +1,8 @@
 import { useCallback, useEffect, useRef, useState, type FormEvent, type ReactNode } from "react";
-import { BellRing, KeyRound, Mail, Pencil, Smartphone, UserRound, X } from "lucide-react";
+import { BellRing, KeyRound, Mail, Smartphone, UserRound, X } from "lucide-react";
 import { Button } from "../components/ui/button";
 import { Input } from "../components/ui/input";
+import { InlineEditButton } from "../components/RecordInlineField";
 import { Tri } from "../components/triState";
 import { useDemoAccount, useDemoIdentity } from "../lib/demo-session";
 import { useSession } from "../auth/session";
@@ -161,17 +162,9 @@ export function ProfilePage({ titleId }: { titleId?: string } = {}) {
                 {nameError && <p className="text-xs text-destructive" role="alert">{nameError}</p>}
               </div>
             ) : (
-              <span className="group/name flex items-start gap-1">
+              <span className="flex items-start gap-1">
                 <span className="break-words font-medium">{field(ctx?.display_name)}</span>
-                <button
-                  aria-label="修改姓名"
-                  className="cursor-pointer rounded p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/name:opacity-100"
-                  onClick={startEditName}
-                  title="修改姓名"
-                  type="button"
-                >
-                  <Pencil aria-hidden="true" size={13} />
-                </button>
+                <InlineEditButton label="修改姓名" onClick={startEditName} />
               </span>
             )}
           </dd>
@@ -375,7 +368,7 @@ function ChannelRow({
   const showAddressLine = editing || Boolean(addressHint) || Boolean(addressEdit);
   return (
     // `group/addr` 挂整行:悬停这张卡任意位置就露出地址编辑图标(⛔ 必须精准悬停到文字上)。
-    <div className="group/addr flex items-start gap-4 border-t border-border px-6 py-4 first:border-t-0">
+    <div className="flex items-start gap-4 border-t border-border px-6 py-4 first:border-t-0">
       <span className="mt-0.5 grid size-9 shrink-0 place-items-center rounded-md bg-primary-soft text-primary">{icon}</span>
       <div className="min-w-0 flex-1">
         <div className="flex items-center gap-2">
@@ -431,15 +424,7 @@ function ChannelRow({
               </span>
             </span>
             {addressEdit && !editing && (
-              <button
-                aria-label={`修改${title}投递地址`}
-                className="cursor-pointer rounded p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/addr:opacity-100"
-                onClick={addressEdit.onStart}
-                title={`修改${title}投递地址`}
-                type="button"
-              >
-                <Pencil aria-hidden="true" size={13} />
-              </button>
+              <InlineEditButton label={`修改${title}投递地址`} onClick={addressEdit.onStart} />
             )}
           </p>
         ) : null}
@@ -466,7 +451,7 @@ function ChannelRow({
  *
  * 三个开关是**本人账号**的投递偏好(⛔ 不动主体档案、⛔ 不影响通知是否产生):
  * 站内恒开不可关;邮箱默认开、需有生效收件地址;短信默认关、需已绑定手机号。
- * 邮箱地址在「邮箱」这一行内就地登记/清空(悬停行内地址出铅笔图标),为空时
+ * 邮箱地址在「邮箱」这一行内就地登记/清空(点击行内铅笔图标),为空时
  * 运营商/合伙人回落档案邮箱(页面如实标出来源)。⛔ 再单开一张「通知投递邮箱」卡片。
  */
 function NotifyPrefPanel() {

+ 7 - 63
web-scaffold/src/pages/ContractRecordPage.tsx

@@ -1,5 +1,5 @@
-import { useEffect, useMemo, useState, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from "react";
-import { AlertTriangle, ArrowLeft, ArrowRight, Building2, CalendarClock, Check, CircleDollarSign, FileSignature, FileText, Lock, Network, PencilLine, Plus, Receipt, RefreshCcw, ScrollText, Trash2, UsersRound, X } from "lucide-react";
+import { useEffect, useMemo, useState, type ReactNode } from "react";
+import { AlertTriangle, ArrowLeft, ArrowRight, Building2, CalendarClock, Check, CircleDollarSign, FileSignature, FileText, Lock, Network, Plus, Receipt, RefreshCcw, ScrollText, Trash2, UsersRound, X } from "lucide-react";
 import { FetchError } from "../components/fetchError";
 import { Link, useLocation, useMatch, useNavigate, useParams } from "react-router";
 import { Button } from "../components/ui/button";
@@ -8,13 +8,13 @@ import { FieldHint } from "../components/ui/field-hint";
 import { OpsNotice, OpsStatus, OpsTag, OpsTableEmpty } from "../components/OperationsKit";
 import { ListPager } from "../components/ListPager";
 import { ReferenceDrawer, type RefTarget } from "../components/ReferenceDrawer";
+import { InlineEditButton, RecordInlineField as InlineField } from "../components/RecordInlineField";
 import { RecordTabs } from "../components/RecordTabs";
 import { Tri } from "../components/triState";
 import { contractFromDetail, contractRawByParam, contractSourceTone, contractStatusOf, contractStatusTone, useContracts } from "../lib/contract-demo";
 import { contractUpdate, contractChangeLog, rowsOf } from "../lib/api/bos";
 import { ticketList, statusLabel, typeLabel } from "../lib/api/ticket";
 import { fmtDate } from "../lib/ticket";
-import { isImeComposing } from "../lib/ime";
 import { ApiError } from "../lib/api/http";
 import { ITEM_FAMILY, label, SUBJECT_TYPE, ORDER_MODE, ORDER_STATUS } from "../lib/api/labels";
 import { WORD_NOT_PROVIDED, WORD_FETCH_FAILED, WORD_UNCONFIGURED } from "../lib/api/lockedCopy";
@@ -46,62 +46,6 @@ const orderEffective = (status?: string | null) =>
 
 type ContractTab = "profile" | "business" | "services" | "subscriptions" | "tickets" | "billing" | "history";
 
-type InlineFieldProps = {
-  id: string;
-  label: string;
-  value: string;
-  editing: boolean;
-  writable: boolean;
-  onStart: () => void;
-  onChange: (value: string) => void;
-  onDone: () => void;
-  onCancel: () => void;
-  type?: "text" | "date" | "number";
-  inputMode?: "decimal" | "numeric" | "text";
-  min?: number;
-  max?: number;
-  step?: number | string;
-  placeholder?: string;
-  display?: ReactNode;
-  emptyText?: string;
-  invalid?: boolean;
-  error?: ReactNode;
-  selectOptions?: readonly { value: string; label: string }[];
-  /** 只读原因:给了就在值后面挂一把锁并带悬停说明,避免"看不到铅笔"被当成页面坏了。 */
-  lockedReason?: string;
-};
-
-/**
- * 详情里的单个可编辑项:非编辑态只渲染值,鼠标移入才显出铅笔;点铅笔切到输入态。
- * 改动先进页面草稿,由底部「保存修改」一次性整段提交(契约 §3.2 全量替换)。
- */
-function InlineField({ id, label, value, editing, writable, onStart, onChange, onDone, onCancel, type = "text", inputMode, min, max, step, placeholder, display, emptyText = WORD_UNCONFIGURED, invalid, error, selectOptions, lockedReason }: InlineFieldProps) {
-  const shown = display ?? (value || missingValue(emptyText));
-  if (!writable) return <span className={lockedReason ? "contract-inline-field is-locked" : "contract-inline-readonly"}>{shown}{lockedReason && <span className="contract-inline-lock" role="img" aria-label={lockedReason} title={lockedReason}><Lock size={12} /></span>}</span>;
-  if (!editing) return <span className="contract-inline-field">
-    <span className="contract-inline-value">{shown}</span>
-    <button type="button" className="contract-inline-edit" aria-label={`编辑${label}`} title={`编辑${label}`} onClick={onStart}><PencilLine size={14} /></button>
-  </span>;
-  const onKeyDown = (event: ReactKeyboardEvent) => {
-    // 输入法上屏用的 Enter/Esc ⛔ 当成「保存/取消」,否则拼音选字就被提交了。
-    if (isImeComposing(event)) return;
-    if (event.key === "Enter") { event.preventDefault(); onDone(); }
-    if (event.key === "Escape") { event.preventDefault(); onCancel(); }
-  };
-  return <span className="contract-inline-editor">
-    {selectOptions ? (
-      <select id={id} aria-label={label} autoFocus value={value} onChange={(event) => onChange(event.target.value)} onKeyDown={onKeyDown}>
-        {selectOptions.map((option) => <option key={option.value} value={option.value}>{option.label}</option>)}
-      </select>
-    ) : (
-      <Input id={id} aria-label={label} autoFocus type={type} inputMode={inputMode} min={min} max={max} step={step} placeholder={placeholder} aria-invalid={invalid || undefined} value={value} onChange={(event) => onChange(event.target.value)} onKeyDown={onKeyDown} />
-    )}
-    <button type="button" className="contract-inline-ok" aria-label="完成编辑" title="完成" onClick={onDone}><Check size={14} /></button>
-    <button type="button" className="contract-inline-cancel" aria-label="取消编辑" title="取消" onClick={onCancel}><X size={14} /></button>
-    {error}
-  </span>;
-}
-
 export function ContractRecordPage() {
   const { no } = useParams();
   const param = decodeURIComponent(no ?? "");
@@ -774,11 +718,11 @@ export function ContractRecordPage() {
                   <td className="table-number">{item.quantity}</td>
                   <td>{accounts === null ? <Tri tone="missing" text={WORD_UNCONFIGURED} title="目录档位额度未下发" /> : <span className="table-number">{accounts}</span>}</td>
                   <td>{item.exits.join("、") || "—"}</td>
-                  {billingWritable && <td className="contract-item-actions-col">
-                    <button type="button" className="contract-row-edit" aria-label={`编辑条目 ${index + 1}`} title={`编辑条目 ${index + 1}`} onClick={() => { setEditingField(null); setEditingItem(index); }}><PencilLine size={15} />编辑</button>
+                  {billingWritable && <td className="contract-item-actions-col"><div className="contract-item-row-actions">
+                    <InlineEditButton label={`编辑条目 ${index + 1}`} text="编辑" onClick={() => { setEditingField(null); setEditingItem(index); }} />
                     {/* D-7:叠加服务只从链路节点下新增,页面上⛔ 平级「新增叠加服务」入口。 */}
-                    {!child && (item.planFamily === "link" || item.itemMode === "increment") && <button type="button" className="contract-row-edit" aria-label={`在条目 ${index + 1} 下添加叠加服务`} title="在该链路下添加叠加服务(出口只能从父行已选出口里取)" onClick={() => { if (item.itemMode === "increment") addIncrementChild(item); else addChildItem(item.key); }}><Plus size={14} />叠加服务</button>}
-                  </td>}
+                    {!child && (item.planFamily === "link" || item.itemMode === "increment") && <button type="button" className="record-inline-action" aria-label={`在条目 ${index + 1} 下添加叠加服务`} title="在该链路下添加叠加服务(出口只能从父行已选出口里取)" onClick={() => { if (item.itemMode === "increment") addIncrementChild(item); else addChildItem(item.key); }}><Plus size={14} />叠加服务</button>}
+                  </div></td>}
                 </tr>;
               })}
               {!draft.items.length && <OpsTableEmpty colSpan={billingWritable ? 6 : 5}>本合同暂无服务条目。</OpsTableEmpty>}

+ 5 - 55
web-scaffold/src/pages/CustomerWorkspacePage.tsx

@@ -16,8 +16,8 @@
  *  补传/替换由浏览器直传平台 `unified-oss` 后调 `POST /customer/update@v1` 回报对象键(⛔ 经本系统传字节);
  * * ⛔ 合同文档上传路由 ⇒ 合同文档区只给应备项说明。
  */
-import { useEffect, useMemo, useRef, useState, type FormEvent, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from "react";
-import { ArrowLeft, Building2, CalendarPlus, Check, FileSignature, FileText, Gauge, LoaderCircle, MapPin, PencilLine, RefreshCcw, RefreshCw, ScrollText, Upload, UsersRound, Wrench, X } from "lucide-react";
+import { useEffect, useMemo, useRef, useState, type FormEvent, type ReactNode } from "react";
+import { ArrowLeft, Building2, CalendarPlus, FileSignature, FileText, Gauge, MapPin, RefreshCcw, RefreshCw, ScrollText, Upload, UsersRound, Wrench } from "lucide-react";
 import { Link, useLocation, useParams } from "react-router";
 import { Button } from "../components/ui/button";
 import { Input } from "../components/ui/input";
@@ -25,6 +25,7 @@ import { OpsMore, OpsNotice, OpsStatus, OpsTableColumns, OpsTableEmpty, OpsTag,
 import { OrderEditor } from "../components/OrderChangeDialogs";
 import { CustomerServiceStopAction } from "../components/CustomerServiceStopAction";
 import { DeliveryStatusTable } from "../components/DeliveryStatusTable";
+import { RecordInlineField, type RecordInlineFieldProps } from "../components/RecordInlineField";
 import { RecordTabs } from "../components/RecordTabs";
 import { ListPager } from "../components/ListPager";
 import { orderView, type OrderView } from "../lib/order-demo";
@@ -119,59 +120,8 @@ function CustomerMaterialCard({ children }: { children: ReactNode }) {
   </div>;
 }
 
-/**
- * 详情里的单个可编辑项(与合同详情同一交互):非编辑态只渲染值,鼠标移入才显出铅笔;点铅笔切到输入态。
- * 改完点对号(或按 Enter)即提交**该项**:客户写口按字段可选,⛔ 攒到底部统一保存。
- */
-type InlineFieldProps = {
-  id: string;
-  label: string;
-  value: string;
-  editing: boolean;
-  writable: boolean;
-  /** 该项正在提交:锁住对号/取消,避免重复提交。 */
-  busy?: boolean;
-  onStart: () => void;
-  onChange: (value: string) => void;
-  onDone: () => void;
-  onCancel: () => void;
-  type?: "text" | "date" | "number";
-  inputMode?: "decimal" | "numeric" | "text";
-  placeholder?: string;
-  display?: ReactNode;
-  emptyText?: string;
-  invalid?: boolean;
-  error?: ReactNode;
-  selectOptions?: readonly { value: string; label: string }[];
-  /** 自定义编辑控件(区域树、运维团队下拉):给定时替代默认输入/下拉。 */
-  editor?: ReactNode;
-};
-
-function InlineField({ id, label, value, editing, writable, busy = false, onStart, onChange, onDone, onCancel, type = "text", inputMode, placeholder, display, emptyText = MISSING, invalid, error, selectOptions, editor }: InlineFieldProps) {
-  const shown = display ?? (value || missingValue(emptyText));
-  if (!writable) return <span className="customer-inline-readonly">{shown}</span>;
-  if (!editing) return <span className="customer-inline-field">
-    <span className="customer-inline-value">{shown}</span>
-    <button type="button" className="customer-inline-edit" aria-label={`编辑${label}`} title={`编辑${label}`} onClick={onStart}><PencilLine size={14} /></button>
-  </span>;
-  const onKeyDown = (event: ReactKeyboardEvent) => {
-    // 输入法上屏用的 Enter/Esc ⛔ 当成「保存/取消」,否则拼音选字就被提交了。
-    if (isImeComposing(event)) return;
-    if (event.key === "Enter") { event.preventDefault(); onDone(); }
-    if (event.key === "Escape") { event.preventDefault(); onCancel(); }
-  };
-  return <span className="customer-inline-editor">
-    {editor ?? (selectOptions ? (
-      <select id={id} aria-label={label} autoFocus disabled={busy} value={value} onChange={(event) => onChange(event.target.value)} onKeyDown={onKeyDown}>
-        {selectOptions.map((option) => <option key={option.value} value={option.value}>{option.label}</option>)}
-      </select>
-    ) : (
-      <Input id={id} aria-label={label} autoFocus disabled={busy} type={type} inputMode={inputMode} placeholder={placeholder} aria-invalid={invalid || undefined} value={value} onChange={(event) => onChange(event.target.value)} onKeyDown={onKeyDown} />
-    ))}
-    <button type="button" className="customer-inline-ok" aria-label={busy ? "正在保存" : "保存该项"} title={busy ? "正在保存…" : "保存该项(Enter)"} disabled={busy} onClick={onDone}>{busy ? <LoaderCircle aria-hidden="true" className="animate-spin" size={14} /> : <Check size={14} />}</button>
-    <button type="button" className="customer-inline-cancel" aria-label="取消编辑" title="取消(Escape)" disabled={busy} onClick={onCancel}><X size={14} /></button>
-    {error}
-  </span>;
+function InlineField(props: RecordInlineFieldProps) {
+  return <RecordInlineField emptyText={MISSING} doneLabel="保存该项" {...props} />;
 }
 
 /** 客户档案的草稿:身份号只存「本次新填」的明文(读口只下脱敏值)。 */

+ 2 - 44
web-scaffold/src/styles/operations.css

@@ -1008,52 +1008,14 @@ body:has(.ops-content-dialog[open]) { overflow: hidden; }
 .customer-team-field > .contract-region-gate { gap:7px; }
 .contract-region-gate > select, .contract-region-gate > .customer-team-multi { pointer-events:none; }
 .contract-region-gate-tip { position:absolute; top:calc(100% + 6px); left:0; z-index:40; padding:6px 10px; border:1px solid var(--warning-border); border-radius:6px; background:var(--warning-soft); color:var(--text-secondary); font-size:var(--type-meta); line-height:1.4; white-space:nowrap; box-shadow:0 6px 16px rgba(0,0,0,.14); }
-.contract-inline-field.is-locked { color:var(--text-secondary); }
-.contract-inline-field .contract-inline-lock { display:inline-flex; align-items:center; flex:none; color:var(--warning); }
 .contract-lock-note { display:flex; align-items:center; gap:8px; margin:0 0 14px; padding:10px 14px; border:1px solid var(--warning-border); border-radius:8px; background:var(--warning-soft); color:var(--text-secondary); font-size:var(--type-support); line-height:1.55; }
 .contract-lock-note > svg { flex:none; color:var(--warning); }
-.contract-inline-field, .customer-inline-field { display:inline-flex; align-items:center; gap:5px; max-width:100%; vertical-align:middle; }
-.contract-inline-value, .customer-inline-value { overflow-wrap:anywhere; }
-.contract-inline-edit, .customer-inline-edit { display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; padding:0; border:1px solid transparent; border-radius:5px; background:transparent; color:var(--muted-foreground); cursor:pointer; opacity:0; transition:opacity .15s ease, color .15s ease, background .15s ease, border-color .15s ease; }
-.contract-inline-field:hover .contract-inline-edit,
-.customer-inline-field:hover .customer-inline-edit,
-.contract-inline-edit:focus-visible,
-.customer-inline-edit:focus-visible { opacity:1; }
-.contract-inline-edit:focus-visible,
-.customer-inline-edit:focus-visible,
-.contract-row-edit:focus-visible { outline:2px solid var(--ring); outline-offset:1px; }
-.contract-inline-edit:hover, .customer-inline-edit:hover { border-color:var(--border); background:var(--accent); color:var(--primary); }
-.contract-inline-editor, .customer-inline-editor { display:inline-flex; align-items:center; flex-wrap:wrap; gap:5px; max-width:min(100%, 460px); }
-.contract-inline-editor > input,
-.contract-inline-editor > select,
-.customer-inline-editor > input,
-.customer-inline-editor > select { height:32px; min-width:120px; padding:0 9px; border:1px solid var(--input); border-radius:6px; background:var(--card); color:var(--foreground); font:inherit; font-size:var(--type-body); }
-.contract-inline-editor > input:focus-visible,
-.contract-inline-editor > select:focus-visible,
-.customer-inline-editor > input:focus-visible,
-.customer-inline-editor > select:focus-visible { outline:2px solid var(--ring); outline-offset:0; }
-.contract-inline-editor > .contract-inline-ok,
-.contract-inline-editor > .contract-inline-cancel,
-.customer-inline-editor > .customer-inline-ok,
-.customer-inline-editor > .customer-inline-cancel { display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; padding:0; border:1px solid var(--border); border-radius:5px; background:var(--card); color:var(--text-secondary); cursor:pointer; }
-.contract-inline-editor > .contract-inline-ok,
-.customer-inline-editor > .customer-inline-ok { color:var(--primary); }
-.contract-inline-editor > .contract-inline-ok:hover,
-.customer-inline-editor > .customer-inline-ok:hover { border-color:var(--primary-border); background:var(--primary-soft); }
-.contract-inline-editor > .contract-inline-cancel:hover,
-.customer-inline-editor > .customer-inline-cancel:hover { background:var(--surface-subtle); }
-.contract-inline-editor > .ops-field-error,
-.customer-inline-editor > .ops-field-error { flex-basis:100%; }
-
 .contract-ref-link { display:inline-flex; align-items:center; gap:4px; padding:0; border:0; background:transparent; color:var(--primary); font:inherit; font-weight:600; cursor:pointer; text-align:left; }
 .contract-ref-link:hover { text-decoration:underline; }
 
 .contract-items-table { margin-top:2px; }
-.contract-item-actions-col { width:88px; text-align:right; }
-.contract-row-edit { display:inline-flex; align-items:center; gap:4px; padding:3px 7px; border:1px solid transparent; border-radius:5px; background:transparent; color:var(--text-secondary); font-size:var(--type-support); cursor:pointer; opacity:0; transition:opacity .15s ease, background .15s ease, border-color .15s ease; }
-.ops-table tbody tr:hover .contract-row-edit,
-.contract-row-edit:focus-visible { opacity:1; }
-.contract-row-edit:hover { border-color:var(--border); background:var(--accent); color:var(--primary); }
+.contract-item-actions-col { width:1%; text-align:right; }
+.contract-item-row-actions { display:flex; justify-content:flex-end; gap:6px; }
 .contract-item-edit-row > td { padding:0; background:var(--surface-subtle); }
 .contract-item-editor { display:grid; gap:14px; padding:16px 18px; }
 .contract-item-editor > header { display:flex; align-items:center; gap:9px; }
@@ -1089,11 +1051,7 @@ body:has(.ops-content-dialog[open]) { overflow: hidden; }
 .contract-customer-combobox-options > li > small { color:var(--muted-foreground); font-size:var(--type-meta); }
 .contract-customer-combobox-options > li.contract-customer-combobox-status { color:var(--muted-foreground); font-size:var(--type-support); cursor:default; }
 
-@media (hover: none) {
-  .contract-inline-edit, .contract-row-edit, .customer-inline-edit { opacity:1; }
-}
 @media (max-width: 750px) {
-  .contract-inline-editor, .customer-inline-editor { max-width:100%; }
   .contract-savebar { position:static; }
 }
 

+ 68 - 0
web-scaffold/src/styles/record-inline-field.css

@@ -0,0 +1,68 @@
+.record-inline-field {
+  display: inline-flex;
+  align-items: center;
+  gap: 6px;
+  max-width: 100%;
+  vertical-align: middle;
+}
+
+.record-inline-value { min-width: 0; overflow-wrap: anywhere; }
+.record-inline-field.is-locked { color: var(--text-secondary); }
+.record-inline-lock { display: inline-flex; flex: none; color: var(--warning); }
+
+.record-inline-action {
+  display: inline-flex;
+  flex: none;
+  align-items: center;
+  justify-content: center;
+  gap: 5px;
+  min-width: 28px;
+  min-height: 28px;
+  padding: 0 6px;
+  border: 1px solid var(--border);
+  border-radius: var(--radius-control);
+  background: var(--card);
+  color: var(--text-secondary);
+  font-size: var(--type-support);
+  font-weight: 550;
+  white-space: nowrap;
+  cursor: pointer;
+  transition: background-color .15s, border-color .15s;
+}
+.record-inline-action:hover:not(:disabled) { background: var(--surface-subtle); border-color: var(--border-hover); }
+.record-inline-action.is-primary { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-soft-foreground); }
+.record-inline-action.is-primary:hover:not(:disabled) { background: var(--primary-border); border-color: var(--primary); }
+.record-inline-action:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
+.record-inline-action:disabled { opacity: .5; cursor: not-allowed; }
+
+.record-inline-editor {
+  display: inline-flex;
+  flex-wrap: wrap;
+  align-items: center;
+  gap: 6px;
+  width: 100%;
+  min-width: 0;
+  max-width: 460px;
+}
+.record-inline-editor > :is(input, select) {
+  flex: 1 1 120px;
+  min-width: 0;
+  max-width: 100%;
+  width: auto;
+  height: 32px;
+  padding: 0 9px;
+  border: 1px solid var(--input);
+  border-radius: var(--radius-control);
+  background: var(--card);
+  color: var(--foreground);
+  font: inherit;
+  font-size: var(--type-body);
+}
+.record-inline-editor > :is(input, select):focus-visible { outline: 2px solid var(--ring); outline-offset: 0; }
+.record-inline-editor > :is(input, select)[aria-invalid="true"] { border-color: var(--destructive); }
+.record-inline-editor-actions { display: inline-flex; flex: none; gap: 5px; }
+.record-inline-editor > .ops-field-error { flex-basis: 100%; }
+
+@media (prefers-reduced-motion: reduce) {
+  .record-inline-action { transition: none; }
+}