Ver Fonte

fix(web): 整理工单回填扩展模板布局

sy há 2 dias atrás
pai
commit
42a018d887

+ 112 - 116
web-scaffold/src/components/work-order/TicketExtForm.tsx

@@ -3,7 +3,8 @@
  * 支持顶层混排叶子字段与一层 `array`(可增删卡片)。
  * 值域约束不常驻展示;输入中/失焦/提交前校验并提示。服务端仍全量校验。
  */
-import { forwardRef, useImperativeHandle, useMemo, useState, type CSSProperties } from "react";
+import { forwardRef, useId, useImperativeHandle, useMemo, useState, type CSSProperties } from "react";
+import { ListChecks, Plus, Trash2 } from "lucide-react";
 import { Button } from "../ui/button";
 import { FieldHint } from "../ui/field-hint";
 import {
@@ -51,12 +52,6 @@ function fieldSpan(field: FormFieldSchema, cols: number): number {
   return field.type === "textarea" || field.type === "multiselect" ? cols : 1;
 }
 
-function gridClass(cols: number): string {
-  if (cols === 1) return " cols-1";
-  if (cols === 3) return " cols-3";
-  return "";
-}
-
 function isEmpty(value: unknown): boolean {
   return (
     value == null ||
@@ -321,25 +316,24 @@ export function validateExtValues(
 }
 
 function FieldInput({
+  id,
   field,
   value,
-  invalid,
-  idPrefix,
+  errorId,
   onChange,
   onBlurValidate,
 }: {
+  id: string;
   field: FormFieldSchema;
   value: unknown;
-  invalid?: boolean;
-  idPrefix?: string;
+  errorId?: string;
   onChange: (v: unknown) => void;
   onBlurValidate: () => void;
 }) {
-  const id = `${idPrefix ?? "ext"}-${field.key}`;
   const common = {
     id,
-    "aria-label": field.label,
-    "aria-invalid": invalid || undefined,
+    "aria-invalid": Boolean(errorId) || undefined,
+    "aria-describedby": errorId,
     onBlur: onBlurValidate,
   };
   switch (field.type) {
@@ -379,20 +373,22 @@ function FieldInput({
       );
     case "boolean":
       return (
-        <label className="work-order-repeater-flag">
+        <label className="work-order-ext-choice">
           <input
             {...common}
+            aria-labelledby={`${id}-title`}
             type="checkbox"
             checked={value === true}
             onChange={(e) => onChange(e.target.checked)}
           />
-          <span>{field.help || "是"}</span>
+          <span>是</span>
         </label>
       );
     case "select":
       return (
         <select
           {...common}
+          className={typeof value !== "string" || !value ? "is-placeholder" : undefined}
           value={typeof value === "string" ? value : ""}
           onChange={(e) => onChange(e.target.value)}
         >
@@ -407,15 +403,16 @@ function FieldInput({
     case "multiselect": {
       const picked = Array.isArray(value) ? value.map(String) : [];
       return (
-        <div className="wide work-order-checklist">
+        <div className="work-order-ext-choices" role="group" aria-labelledby={`${id}-title`} aria-describedby={errorId}>
           {(field.options ?? []).map((o) => {
             const on = picked.includes(o.value);
             return (
-              <label key={o.value}>
+              <label key={o.value} className="work-order-ext-choice">
                 <input
                   type="checkbox"
                   checked={on}
-                  aria-invalid={invalid || undefined}
+                  aria-invalid={Boolean(errorId) || undefined}
+                  aria-describedby={errorId}
                   onChange={(e) => {
                     const next = e.target.checked
                       ? [...picked, o.value]
@@ -447,6 +444,32 @@ function FieldInput({
   }
 }
 
+function ExtField({ field, value, error, cols, onChange, onBlurValidate }: {
+  field: FormFieldSchema;
+  value: unknown;
+  error: string | null;
+  cols: number;
+  onChange: (value: unknown) => void;
+  onBlurValidate: () => void;
+}) {
+  const id = useId();
+  const errorId = error ? `${id}-error` : undefined;
+  const titleId = `${id}-title`;
+  const title = <>{field.label}{field.required && <em> *</em>}</>;
+  return (
+    <div className="work-order-ext-field" style={{ "--ext-field-span": fieldSpan(field, cols) } as CSSProperties}>
+      <div className="field-label-title">
+        {field.type === "multiselect" || field.type === "boolean"
+          ? <span id={titleId}>{title}</span>
+          : <label htmlFor={id}>{title}</label>}
+        {field.help && <FieldHint label={`${field.label}说明`}>{field.help}</FieldHint>}
+      </div>
+      <FieldInput id={id} field={field} value={value} errorId={errorId} onChange={onChange} onBlurValidate={onBlurValidate} />
+      {error && <small id={errorId} className="work-order-ext-field-error" role="alert">{error}</small>}
+    </div>
+  );
+}
+
 function ArrayFieldBlock({
   field,
   value,
@@ -488,42 +511,55 @@ function ArrayFieldBlock({
       : null;
 
   return (
-    <div
-      className="wide work-order-repeater work-order-ext-array"
-      style={{ gridColumn: `span ${cols}` }}
-      data-gap-focus={`ext-${field.key}`}
-    >
-      <div className="work-order-repeater-head">
-        <span>
-          {field.label}
-          {(field.required || minItems > 0) && <em> *</em>}
-          {field.help ? (
-            <FieldHint label={`${field.label}说明`}>{field.help}</FieldHint>
-          ) : null}
-        </span>
+    <div className="work-order-ext-array" data-gap-focus={`ext-${field.key}`}>
+      <div className="work-order-ext-array-head">
+        <div>
+          <div className="field-label-title">
+            <strong>{field.label}</strong>
+            {(field.required || minItems > 0) && <em> *</em>}
+            {field.help && <FieldHint label={`${field.label}说明`}>{field.help}</FieldHint>}
+          </div>
+          <small>{cards.length} / {maxItems} 条{minItems > 0 ? ` · 至少 ${minItems} 条` : ""}</small>
+        </div>
+        <Button
+          type="button"
+          variant="ghost"
+          size="sm"
+          className="org-button org-button-compact org-button-scope"
+          disabled={cards.length >= maxItems}
+          onClick={() => {
+            if (cards.length >= maxItems) return;
+            onChangeCards([...cards, {}]);
+            markDirty(groupPath);
+          }}
+        >
+          <Plus size={14} aria-hidden="true" />添加{itemLabel}
+        </Button>
       </div>
 
+      {!cards.length && <p className="work-order-ext-array-empty">尚未添加{itemLabel}</p>}
       {cards.map((card, i) => {
         const cardKey = `${field.key}[${i}]`;
         return (
-          <div key={cardKey} className="work-order-repeater-row work-order-ext-array-card">
+          <div key={cardKey} className="work-order-ext-array-card">
             <div className="work-order-ext-array-card-head">
-              <strong>{itemLabel}{i + 1}</strong>
+              <strong>{itemLabel} {i + 1}</strong>
               <Button
                 type="button"
                 variant="ghost"
                 size="sm"
-                className="work-order-ext-array-remove"
+                className="org-button org-button-compact org-button-danger-soft"
+                aria-label={`删除${itemLabel} ${i + 1}`}
                 onClick={() => {
                   const next = cards.filter((_, j) => j !== i);
                   onChangeCards(next);
                   markDirty(groupPath);
                 }}
               >
-                删除
+                <Trash2 size={14} aria-hidden="true" />删除
               </Button>
             </div>
-            <div className={`work-order-form-grid work-order-ext-array-card-grid${gridClass(cols)}`}>
+            <div className="work-order-ext-grid">
               {children.map((child) => {
                 const path = `${field.key}[${i}].${child.key}`;
                 const active = forceAll || dirty[path] || dirty[groupPath];
@@ -533,35 +569,24 @@ function ArrayFieldBlock({
                   ? validateExtField(child, card[child.key], { phase, enforceRequired })
                   : null;
                 return (
-                  <label
+                  <ExtField
                     key={child.key}
-                    className={err ? "is-ext-invalid" : undefined}
-                    style={{ gridColumn: `span ${fieldSpan(child, cols)}` }}
-                  >
-                    {child.label}
-                    {child.required ? <em> *</em> : null}
-                    {child.help && child.type !== "boolean" ? (
-                      <FieldHint label={`${child.label}说明`}>{child.help}</FieldHint>
-                    ) : null}
-                    <FieldInput
-                      field={child}
-                      value={card[child.key]}
-                      invalid={!!err}
-                      idPrefix={`ext-${field.key}-${i}`}
-                      onChange={(v) => {
-                        markDirty(path);
-                        const next = cards.map((c, j) =>
-                          j === i ? { ...c, [child.key]: v } : c,
-                        );
-                        onChangeCards(next);
-                      }}
-                      onBlurValidate={() => {
-                        markDirty(path);
-                        markCommitted(path);
-                      }}
-                    />
-                    {err ? <small className="work-order-ext-field-error" role="alert">{err}</small> : null}
-                  </label>
+                    field={child}
+                    value={card[child.key]}
+                    error={err}
+                    cols={cols}
+                    onChange={(v) => {
+                      markDirty(path);
+                      const next = cards.map((c, j) =>
+                        j === i ? { ...c, [child.key]: v } : c,
+                      );
+                      onChangeCards(next);
+                    }}
+                    onBlurValidate={() => {
+                      markDirty(path);
+                      markCommitted(path);
+                    }}
+                  />
                 );
               })}
             </div>
@@ -569,26 +594,6 @@ function ArrayFieldBlock({
         );
       })}
 
-      <div className="work-order-repeater-foot">
-        <Button
-          type="button"
-          variant="outline"
-          size="sm"
-          className="work-order-ext-array-add"
-          disabled={cards.length >= maxItems}
-          onClick={() => {
-            if (cards.length >= maxItems) return;
-            onChangeCards([...cards, {}]);
-            markDirty(groupPath);
-          }}
-        >
-          增加{itemLabel}
-        </Button>
-        <small>
-          {cards.length}/{maxItems}
-          {minItems > 0 ? `(至少 ${minItems})` : ""}
-        </small>
-      </div>
       {groupCountErr ? (
         <small className="work-order-ext-field-error" role="alert">{groupCountErr}</small>
       ) : null}
@@ -625,30 +630,20 @@ function LeafFieldBlock({
     ? validateExtField(field, value, { phase, enforceRequired })
     : null;
   return (
-    <label
-      className={err ? "is-ext-invalid" : undefined}
-      style={{ gridColumn: `span ${fieldSpan(field, cols)}` }}
-    >
-      {field.label}
-      {field.required ? <em> *</em> : null}
-      {field.help && field.type !== "boolean" ? (
-        <FieldHint label={`${field.label}说明`}>{field.help}</FieldHint>
-      ) : null}
-      <FieldInput
-        field={field}
-        value={value}
-        invalid={!!err}
-        onChange={(v) => {
-          markDirty(field.key);
-          onChange(v);
-        }}
-        onBlurValidate={() => {
-          markDirty(field.key);
-          markCommitted(field.key);
-        }}
-      />
-      {err ? <small className="work-order-ext-field-error" role="alert">{err}</small> : null}
-    </label>
+    <ExtField
+      field={field}
+      value={value}
+      error={err}
+      cols={cols}
+      onChange={(v) => {
+        markDirty(field.key);
+        onChange(v);
+      }}
+      onBlurValidate={() => {
+        markDirty(field.key);
+        markCommitted(field.key);
+      }}
+    />
   );
 }
 
@@ -706,7 +701,7 @@ export const TicketExtForm = forwardRef<TicketExtFormHandle, Props>(function Tic
   </section>;
 
   const body = (
-    <div className={`work-order-form-grid${gridClass(cols)}`}>
+    <div className="work-order-ext-grid">
       {schema.fields.map((field) => {
         if (field.type === "array") {
           return (
@@ -751,12 +746,13 @@ export const TicketExtForm = forwardRef<TicketExtFormHandle, Props>(function Tic
   );
 
   return (
-    <div className="wide work-order-gap-anchor" data-gap-focus="ext">
-      <h4 className="work-order-subhead">
-        扩展信息
-        {ext?.template_version != null ? `(模板 v${ext.template_version})` : ""}
-      </h4>
+    <section className="wide work-order-ext-editor" aria-label="扩展信息" data-gap-focus="ext"
+      style={{ "--ext-template-cols": cols } as CSSProperties}>
+      <header className="work-order-ext-editor-head">
+        <h3><ListChecks size={16} aria-hidden="true" />扩展信息</h3>
+        {ext?.template_version != null && <small>模板 v{ext.template_version}</small>}
+      </header>
       {body}
-    </div>
+    </section>
   );
 });

+ 36 - 1
web-scaffold/src/pages/__tests__/work-order-backfill-dialog.test.tsx

@@ -55,7 +55,20 @@ it.each([
     close(this: HTMLDialogElement) { this.open = false; },
   });
   try {
-    renderRecord({ ticket: { ...detail.ticket, ticket_type: "open" }, actions: { backfill: true, mark_done: true }, gaps: [gap, "处理记录"] });
+    renderRecord({
+      ticket: { ...detail.ticket, ticket_type: "open" },
+      actions: { backfill: true, mark_done: true },
+      gaps: [gap, "处理记录"],
+      backfill: { ext: { template_version: 2, schema: { layout: { columns: 3 }, fields: [
+        { key: "site", label: "施工地点", type: "text", required: true, help: "填写现场地址" },
+        { key: "connection", label: "接入方式", type: "select", options: [{ value: "fixed", label: "固定" }] },
+        { key: "verified", label: "已核实", type: "boolean" },
+        { key: "tests", label: "检测项", type: "multiselect", options: [{ value: "speed", label: "测速" }] },
+        { key: "ports", label: "端口明细", itemLabel: "端口", type: "array", maxItems: 2, fields: [
+          { key: "vlan", label: "接入 VLAN", type: "text", format: "vlan", required: true },
+        ] },
+      ] } } },
+    });
     const entry = screen.getByRole("button", { name: label });
     expect(entry.classList.contains("org-button-scope")).toBe(true);
     fireEvent.click(entry);
@@ -75,6 +88,28 @@ it.each([
     expect(submit.closest("footer")).toBeTruthy();
 
     if (focus === "conclusion") {
+      const template = within(controls.getByRole("region", { name: "扩展信息" }));
+      expect(template.getByText("模板 v2").closest("header")).toBeTruthy();
+      const site = template.getByRole("textbox", { name: /^施工地点/ });
+      fireEvent.blur(site);
+      expect(site.getAttribute("aria-describedby")).toBe(template.getByRole("alert").id);
+      fireEvent.change(site, { target: { value: "上海" } });
+      expect(template.queryByRole("alert")).toBeNull();
+      fireEvent.click(template.getByRole("checkbox", { name: "已核实" }));
+      expect(template.getByRole<HTMLInputElement>("checkbox", { name: "已核实" }).checked).toBe(true);
+      const tests = within(template.getByRole("group", { name: "检测项" }));
+      fireEvent.click(tests.getByRole("checkbox", { name: "测速" }));
+      expect(tests.getByRole<HTMLInputElement>("checkbox", { name: "测速" }).checked).toBe(true);
+      const addPort = template.getByRole("button", { name: "添加端口" });
+      fireEvent.click(addPort);
+      fireEvent.click(addPort);
+      expect((addPort as HTMLButtonElement).disabled).toBe(true);
+      const ports = template.getAllByRole("textbox", { name: /^接入 VLAN/ });
+      expect(ports[0].id).not.toBe(ports[1].id);
+      fireEvent.change(ports[1], { target: { value: "200" } });
+      fireEvent.click(template.getByRole("button", { name: "删除端口 1" }));
+      expect(template.getByRole<HTMLInputElement>("textbox", { name: /^接入 VLAN/ }).value).toBe("200");
+
       const photo = new File(["photo"], "现场照片.jpg", { type: "image/jpeg" });
       const fileInput = dialog.querySelector('input[type="file"]:not([capture])')!;
       const cameraInput = dialog.querySelector('input[capture="environment"]')!;

+ 0 - 103
web-scaffold/src/styles/work-order-settings.css

@@ -217,97 +217,6 @@
   font-size: var(--type-meta);
 }
 
-.work-order-settings-preview-pane .work-order-gap-anchor {
-  display: block;
-  margin: 0;
-  padding: 0;
-}
-
-.work-order-settings-preview-pane .work-order-subhead {
-  margin: 0 0 8px;
-  font-size: var(--type-support);
-}
-
-.work-order-settings-preview-pane .work-order-form-grid {
-  margin-top: 0;
-  gap: 10px 12px;
-}
-
-.work-order-settings-preview-pane .work-order-form-grid.cols-1 {
-  grid-template-columns: minmax(0, 1fr);
-}
-
-.work-order-settings-preview-pane .work-order-form-grid.cols-3 {
-  grid-template-columns: repeat(3, minmax(0, 1fr));
-}
-
-.work-order-settings-preview-pane .work-order-form-grid > label {
-  display: block;
-  min-width: 0;
-  color: var(--field-label);
-  font-size: var(--type-support);
-  font-weight: 400;
-}
-
-.work-order-settings-preview-pane .work-order-form-grid > label input,
-.work-order-settings-preview-pane .work-order-form-grid > label select,
-.work-order-settings-preview-pane .work-order-form-grid > label textarea {
-  display: block;
-  width: 100%;
-  margin-top: 5px;
-  color: var(--foreground);
-  font: inherit;
-  font-size: var(--type-support);
-}
-
-.work-order-settings-preview-pane .work-order-form-grid > label input:not([type="checkbox"]),
-.work-order-settings-preview-pane .work-order-form-grid > label select {
-  height: 32px;
-  padding: 0 8px;
-  border: 1px solid var(--input, var(--border));
-  border-radius: 6px;
-  background: var(--card);
-}
-
-.work-order-settings-preview-pane .work-order-form-grid > label textarea {
-  min-height: 64px;
-  padding: 6px 8px;
-  border: 1px solid var(--input, var(--border));
-  border-radius: 6px;
-  background: var(--card);
-  resize: vertical;
-}
-
-.work-order-settings-preview-pane .work-order-form-grid > label em {
-  color: var(--destructive);
-  font-style: normal;
-}
-
-.work-order-settings-preview-pane .work-order-form-grid > label small {
-  color: var(--muted-foreground);
-  font-size: var(--type-meta);
-  line-height: 1.4;
-}
-
-.work-order-settings-preview-pane .work-order-repeater-flag {
-  display: inline-flex;
-  align-items: center;
-  gap: 6px;
-  margin-top: 6px;
-}
-
-.work-order-settings-preview-pane .work-order-checklist {
-  display: grid;
-  gap: 4px;
-  margin-top: 6px;
-}
-
-.work-order-settings-preview-pane .work-order-checklist > label {
-  display: inline-flex;
-  align-items: center;
-  gap: 6px;
-}
-
 /* —— 紧凑字段行 —— */
 .work-order-settings-field-head,
 .work-order-settings-field-main {
@@ -382,10 +291,6 @@
   padding-left: 28px;
 }
 
-.work-order-settings-preview-pane .work-order-ext-array {
-  margin-top: 4px;
-}
-
 .work-order-settings-field-row {
   margin-bottom: 6px;
   padding: 6px 8px;
@@ -496,14 +401,6 @@
   width: 132px;
 }
 
-.work-order-settings-preview-pane .work-order-ext-field-error {
-  display: block;
-  margin-top: 4px;
-  color: var(--destructive);
-  font-size: var(--type-meta);
-  line-height: 1.4;
-}
-
 .work-order-settings-field-extra input,
 .work-order-settings-field-extra select,
 .work-order-settings-field-extra textarea {

+ 135 - 20
web-scaffold/src/styles/work-orders.css

@@ -180,16 +180,6 @@
 .work-order-editor section > label { margin-top: 10px; }
 .work-order-form-error { margin-top: 17px; color: var(--destructive); font-size: var(--type-body); }
 .work-order-ext-field-error { display: block; margin-top: 4px; color: var(--destructive); font-size: var(--type-meta); line-height: 1.4; }
-.work-order-form-grid > label.is-ext-invalid input:not([type="checkbox"]),
-.work-order-form-grid > label.is-ext-invalid select,
-.work-order-form-grid > label.is-ext-invalid textarea {
-  border-color: var(--destructive);
-}
-.work-order-settings-preview-pane .work-order-form-grid > label.is-ext-invalid input:not([type="checkbox"]),
-.work-order-settings-preview-pane .work-order-form-grid > label.is-ext-invalid select,
-.work-order-settings-preview-pane .work-order-form-grid > label.is-ext-invalid textarea {
-  border-color: var(--destructive);
-}
 
 /* 可增删明细行(开通准备资料的应用类别、回填网络线路/境外 IP 明细) */
 .work-order-repeater { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--input); border-radius: var(--radius); background: var(--muted); }
@@ -211,29 +201,154 @@
 .work-order-repeater-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
 .work-order-repeater-foot small { color: var(--muted-foreground); font-size: var(--type-support); }
 
-/* 扩展模板 array:可增删卡片组(整组占满栅格行) */
-.work-order-ext-array { margin: 0; }
-.work-order-ext-array-card {
-  display: grid;
-  gap: 8px;
-  align-items: start;
+/* 扩展模板:列数随所在容器调整,明细组始终整行显示。 */
+.work-order-ext-editor {
+  min-width: 0;
+  container: work-order-ext-editor / inline-size;
+  border: 1px solid var(--border-subtle);
+  border-radius: var(--radius-control);
+  background: var(--card);
 }
+.work-order-ext-editor-head,
+.work-order-ext-array-head,
 .work-order-ext-array-card-head {
   display: flex;
+  flex-wrap: wrap;
   align-items: center;
   justify-content: space-between;
+  gap: 8px 12px;
+}
+.work-order-ext-editor-head {
+  padding: 12px 16px;
+  border-bottom: 1px solid var(--border-subtle);
+}
+.work-order-ext-editor-head h3 {
+  display: flex;
+  align-items: center;
+  gap: 8px;
+  margin: 0;
+  color: var(--foreground);
+  font-size: var(--type-comfort);
+  font-weight: 600;
+}
+.work-order-ext-editor-head h3 svg { flex: none; color: var(--primary); }
+.work-order-ext-editor-head small {
+  padding: 2px 8px;
+  border-radius: var(--radius-control);
+  background: var(--surface-subtle);
+  color: var(--muted-foreground);
+  font-size: var(--type-meta);
+}
+.work-order-ext-grid {
+  --ext-cols: var(--ext-template-cols);
+  display: grid;
+  grid-template-columns: repeat(var(--ext-cols), minmax(0, 1fr));
+  align-items: start;
+  gap: 14px 16px;
+  min-width: 0;
+  padding: 14px 16px 16px;
+}
+.work-order-ext-field {
+  grid-column: span min(var(--ext-field-span), var(--ext-cols));
+  display: grid;
+  gap: 5px;
+  min-width: 0;
+  color: var(--field-label);
+  font-size: var(--type-body);
+}
+.work-order-ext-field .field-label-title { gap: 2px 0; overflow-wrap: anywhere; }
+.work-order-ext-editor em { color: var(--destructive); font-style: normal; }
+.work-order-ext-editor .work-order-ext-field > :is(input, select, textarea) {
+  width: 100%;
+  min-width: 0;
+  margin: 0;
+  padding: 7px 10px;
+  border: 1px solid var(--input);
+  border-radius: 6px;
+  background: var(--card);
+  color: var(--foreground);
+  font-size: var(--type-body);
+}
+.work-order-ext-editor .work-order-ext-field > :is(input, select) { height: 36px; }
+.work-order-ext-editor .work-order-ext-field > textarea { min-height: 72px; resize: vertical; }
+.work-order-ext-editor .work-order-ext-field > select { cursor: pointer; }
+.work-order-ext-editor .work-order-ext-field > select.is-placeholder { color: var(--muted-foreground); }
+.work-order-ext-editor .work-order-ext-field > select option:not([value=""]) { color: var(--foreground); }
+.work-order-ext-editor .work-order-ext-field > :is(input, select, textarea):hover { border-color: var(--border-hover); }
+.work-order-ext-editor .work-order-ext-field > :is(input, select, textarea):focus-visible {
+  outline: none;
+  border-color: var(--ring);
+  box-shadow: 0 0 0 3px var(--ring-glow);
+}
+.work-order-ext-editor .work-order-ext-field > :is(input, select, textarea)[aria-invalid="true"] { border-color: var(--destructive); }
+.work-order-ext-field-error { overflow-wrap: anywhere; }
+.work-order-ext-field .work-order-ext-field-error { margin: 0; }
+.work-order-ext-choices { display: flex; flex-wrap: wrap; gap: 6px; }
+.work-order-ext-editor .work-order-ext-choice {
+  display: inline-flex;
+  align-items: center;
+  gap: 7px;
+  min-height: 36px;
+  max-width: 100%;
+  padding: 6px 9px;
+  border: 1px solid var(--input);
+  border-radius: 6px;
+  color: var(--text-secondary);
+  font-size: var(--type-support);
+  overflow-wrap: anywhere;
+  cursor: pointer;
+}
+.work-order-ext-editor .work-order-ext-choice:has(:checked) {
+  border-color: var(--primary-border);
+  background: var(--primary-soft);
+  color: var(--primary-soft-foreground);
+}
+.work-order-ext-editor .work-order-ext-choice input {
+  flex: none;
+  width: 15px;
+  height: 15px;
+  margin: 0;
+  accent-color: var(--primary);
+  cursor: pointer;
+}
+.work-order-ext-array {
+  grid-column: 1 / -1;
+  display: grid;
   gap: 8px;
+  min-width: 0;
+  padding: 12px;
+  border-radius: var(--radius-control);
+  background: var(--surface-subtle);
 }
+.work-order-ext-array-head strong,
 .work-order-ext-array-card-head strong {
   color: var(--foreground);
   font-size: var(--type-support);
   font-weight: 600;
+  overflow-wrap: anywhere;
 }
-.work-order-ext-array-card-grid {
-  margin-top: 0;
+.work-order-ext-array-head small,
+.work-order-ext-array-empty {
+  display: block;
+  margin: 0;
+  color: var(--muted-foreground);
+  font-size: var(--type-meta);
 }
-.work-order-form-grid > .work-order-ext-array {
-  grid-column: 1 / -1;
+.work-order-ext-array-head button { flex: none; }
+.work-order-ext-array-card {
+  min-width: 0;
+  border: 1px solid var(--border-subtle);
+  border-radius: var(--radius-control);
+  background: var(--card);
+}
+.work-order-ext-array-card-head { padding: 7px 12px; border-bottom: 1px solid var(--border-subtle); }
+.work-order-ext-array-card > .work-order-ext-grid { padding: 12px; }
+@container work-order-ext-editor (max-width: 699px) {
+  .work-order-ext-grid { --ext-cols: min(2, var(--ext-template-cols)); }
+}
+@container work-order-ext-editor (max-width: 439px) {
+  .work-order-ext-grid { --ext-cols: 1; gap: 12px; padding: 12px; }
+  .work-order-ext-editor-head { padding-inline: 12px; }
 }
 .work-order-editor footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 26px; padding-top: 19px; border-top: 1px solid var(--border); }
 @media (max-width: 1279px) { .work-order-overview { flex-wrap: wrap; } .work-order-overview-lead { padding-bottom: 10px; } .work-order-overview-stats { width: 100%; margin: 8px 22px 20px; padding-top: 12px; border-left: 0; border-top: 1px solid var(--border); } .work-order-overview-stats > div:first-child { padding-left: 2px; } }