@bettercms-ai/kit 3.1.7 → 3.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"location.js","names":[],"sources":["../../src/controls/location.tsx"],"sourcesContent":["/**\n * LOCATION — the geopoint field (DESIGN 8.21), V2 GeoControl fitted to what prod stores.\n *\n * Value (backend reference-validation `location`, the classic LocationField): `{ lat, lng, label? }`, lat −90…90 and\n * lng −180…180, finite numbers; null when empty. Keys the stored object carries beyond those are kept.\n *\n * A coordinate is written only when it is whole: both numbers, in range. Until then the field says what is missing\n * (\"Add the longitude too\") and keeps the stored value, because the backend refuses half a coordinate. Emptying all\n * three boxes clears the value. Pasting \"44.0582, -121.3153\" into either box fills both.\n *\n * The card above the inputs shows the pin and the coordinates, with a link that opens them on OpenStreetMap; it\n * draws no map tiles (no vendor, key or bundle).\n */\nimport * as React from \"react\";\nimport { IconMapPin } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport type { ControlProps } from \"../types\";\nimport { Input } from \"../ui/input\";\nimport { TEXT_FOCUS } from \"./text\";\n\ninterface Draft {\n lat: string;\n lng: string;\n label: string;\n}\nconst num = (v: unknown) => (typeof v === \"number\" && Number.isFinite(v) ? String(v) : \"\");\nconst draftOf = (v: unknown): Draft => (isObj(v) ? { lat: num(v.lat), lng: num(v.lng), label: typeof v.label === \"string\" ? v.label : \"\" } : { lat: \"\", lng: \"\", label: \"\" });\nconst PAIR = /^\\s*(-?\\d+(?:\\.\\d+)?)\\s*[,;\\s]\\s*(-?\\d+(?:\\.\\d+)?)\\s*$/;\n\n/** The value a draft writes, or the reason it can't be written yet. */\nexport function locationFromDraft(d: Draft, prev: unknown): { ok: true; value: Record<string, unknown> | null } | { ok: false; reason: string } {\n const lat = d.lat.trim();\n const lng = d.lng.trim();\n const label = d.label.trim();\n if (!lat && !lng && !label) return { ok: true, value: null };\n if (!lat || !lng) return { ok: false, reason: !lat && !lng ? \"Add a latitude and a longitude to save this location.\" : !lat ? \"Add the latitude too: a location needs both.\" : \"Add the longitude too: a location needs both.\" };\n const la = Number(lat);\n const lo = Number(lng);\n if (!Number.isFinite(la) || Math.abs(la) > 90) return { ok: false, reason: \"Latitude must be a number from −90 to 90.\" };\n if (!Number.isFinite(lo) || Math.abs(lo) > 180) return { ok: false, reason: \"Longitude must be a number from −180 to 180.\" };\n const out: Record<string, unknown> = { ...(isObj(prev) ? prev : {}), lat: la, lng: lo };\n if (label) out.label = label;\n else delete out.label;\n return { ok: true, value: out };\n}\n\nexport function LocationControl({ field, value, onChange, readOnly, id, invalid }: ControlProps) {\n const [draft, setDraft] = React.useState<Draft>(() => draftOf(value));\n const [seen, setSeen] = React.useState(value);\n const [mine, setMine] = React.useState<unknown>(undefined);\n // a value set from elsewhere (undo, another editor) replaces the draft; our own writes keep what the author typed\n if (value !== seen) {\n setSeen(value);\n if (value !== mine) setDraft(draftOf(value));\n }\n const result = locationFromDraft(draft, value);\n const reasonId = `${id}-reason`;\n\n const update = (patch: Partial<Draft>) => {\n const next = { ...draft, ...patch };\n setDraft(next);\n const r = locationFromDraft(next, value);\n if (!r.ok) return;\n const same = JSON.stringify(r.value) === JSON.stringify(value ?? null);\n if (same) return;\n setMine(r.value);\n onChange(r.value);\n };\n const coordinate = (key: \"lat\" | \"lng\") => (e: React.ChangeEvent<HTMLInputElement>) => {\n const pair = PAIR.exec(e.target.value);\n update(pair ? { lat: pair[1], lng: pair[2] } : ({ [key]: e.target.value } as Partial<Draft>));\n };\n\n const shown = isObj(value) && typeof value.lat === \"number\" && typeof value.lng === \"number\" ? { lat: value.lat, lng: value.lng } : null;\n return (\n <div className={cn(\"overflow-hidden rounded-kit-lg border border-kit-field-border\", invalid && \"border-[var(--kit-field-invalid)]\")}>\n <div className=\"relative h-28 overflow-hidden bg-kit-subtle\">\n {/* V2 `.grid-lines` (styles/index.css:1026), inlined: the dash has no such utility */}\n <div\n className=\"absolute inset-0 opacity-80\"\n style={{ backgroundImage: \"linear-gradient(var(--kit-line-subtle) 1px, transparent 1px), linear-gradient(90deg, var(--kit-line-subtle) 1px, transparent 1px)\", backgroundSize: \"24px 24px\" }}\n />\n <svg className=\"absolute inset-0 size-full text-kit-line-strong\" viewBox=\"0 0 400 112\" preserveAspectRatio=\"none\" aria-hidden>\n <path d=\"M0 76 C80 60 120 100 200 78 S320 40 400 60\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"6\" />\n <path d=\"M140 0 L170 112\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" />\n </svg>\n {shown ? (\n <>\n <div className=\"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-full flex-col items-center\" aria-hidden>\n <span className=\"flex size-7 items-center justify-center rounded-full bg-kit-inverse text-kit-fg-inverse shadow-kit-md\">\n <IconMapPin className=\"size-4\" stroke={1.5} />\n </span>\n <span className=\"size-2 -translate-y-0.5 rotate-45 bg-kit-inverse\" />\n </div>\n <a\n href={`https://www.openstreetmap.org/?mlat=${shown.lat}&mlon=${shown.lng}#map=15/${shown.lat}/${shown.lng}`}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n // D4: V2 (misc.tsx:195) draws the coordinates as a plain chip, no icon; the kit keeps the map link (its\n // accessible name says where it goes) and draws exactly V2's chip\n className=\"tabular-nums absolute bottom-2 right-2 rounded-kit-md bg-kit-surface/90 px-1.5 py-0.5 font-kit-mono text-kit-2xs text-kit-fg-2 shadow-kit-xs hover:text-kit-fg\"\n aria-label={`Open ${shown.lat.toFixed(4)}, ${shown.lng.toFixed(4)} on OpenStreetMap (new tab)`}\n >\n {shown.lat.toFixed(4)}, {shown.lng.toFixed(4)}\n </a>\n </>\n ) : (\n <p className=\"absolute inset-0 flex items-center justify-center text-kit-xs text-kit-fg-3\">No coordinates yet</p>\n )}\n </div>\n <div className=\"flex flex-col gap-2 p-2\">\n <Input\n id={id}\n value={draft.label}\n readOnly={readOnly}\n placeholder=\"Label, e.g. Head office\"\n aria-label={`${field.title} label`}\n leading={<IconMapPin stroke={1.5} />}\n onChange={(e) => update({ label: e.target.value })}\n className={TEXT_FOCUS}\n />\n <div className=\"grid grid-cols-2 gap-2\">\n <Input\n id={`${id}-lat`}\n size=\"sm\"\n inputMode=\"decimal\"\n value={draft.lat}\n readOnly={readOnly}\n aria-label={`${field.title} latitude`}\n aria-invalid={(!result.ok && /latitude/i.test(result.reason)) || undefined}\n aria-describedby={!result.ok ? reasonId : undefined}\n placeholder=\"−90 to 90\"\n onChange={coordinate(\"lat\")}\n leading={<span className=\"text-kit-2xs\">Lat</span>}\n />\n <Input\n id={`${id}-lng`}\n size=\"sm\"\n inputMode=\"decimal\"\n value={draft.lng}\n readOnly={readOnly}\n aria-label={`${field.title} longitude`}\n aria-invalid={(!result.ok && /longitude/i.test(result.reason)) || undefined}\n aria-describedby={!result.ok ? reasonId : undefined}\n placeholder=\"−180 to 180\"\n onChange={coordinate(\"lng\")}\n leading={<span className=\"text-kit-2xs\">Long</span>}\n />\n </div>\n {!result.ok ? (\n <p id={reasonId} role=\"status\" className=\"text-kit-xs text-kit-warning-fg\">\n {result.reason}\n </p>\n ) : null}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,IAAM,OAAO,MAAgB,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAAI,OAAO,CAAC,IAAI;AACvF,IAAM,WAAW,MAAuB,MAAM,CAAC,IAAI;CAAE,KAAK,IAAI,EAAE,GAAG;CAAG,KAAK,IAAI,EAAE,GAAG;CAAG,OAAO,OAAO,EAAE,UAAU,WAAW,EAAE,QAAQ;AAAG,IAAI;CAAE,KAAK;CAAI,KAAK;CAAI,OAAO;AAAG;AAC3K,IAAM,OAAO;;AAGb,SAAgB,kBAAkB,GAAU,MAAoG;CAC9I,MAAM,MAAM,EAAE,IAAI,KAAK;CACvB,MAAM,MAAM,EAAE,IAAI,KAAK;CACvB,MAAM,QAA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kB,CAAC,OAAO,KAAK,WAAW,KAAA;MAC1C,aAAY;MACZ,UAAU,WAAW,KAAK;MAC1B,SAAS,oBAAC,QAAD;OAAM,WAAU;OAAe,UAAA;MAAU,CAAA;KACnD,CAAA,CACE;;IACJ,CAAC,OAAO,KACP,oBAAC,KAAD;KAAG,IAAI;KAAU,MAAK;KAAS,WAAU;KACtC,UAAA,OAAO;IACP,CAAA,IACD;GACD;EACF,CAAA,CAAA;;AAET"}
1
+ {"version":3,"file":"location.js","names":[],"sources":["../../src/controls/location.tsx"],"sourcesContent":["/**\n * LOCATION — the geopoint field (DESIGN 8.21), V2 GeoControl fitted to what prod stores.\n *\n * Value (backend reference-validation `location`, the classic LocationField): `{ lat, lng, label? }`, lat −90…90 and\n * lng −180…180, finite numbers; null when empty. Keys the stored object carries beyond those are kept.\n *\n * A coordinate is written only when it is whole: both numbers, in range. Until then the field says what is missing\n * (\"Add the longitude too\") and keeps the stored value, because the backend refuses half a coordinate. Emptying all\n * three boxes clears the value. Pasting \"44.0582, -121.3153\" into either box fills both.\n *\n * The card above the inputs shows the pin and the coordinates, with a link that opens them on OpenStreetMap; it\n * draws no map tiles (no vendor, key or bundle).\n */\nimport * as React from \"react\";\nimport { IconMapPin } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport type { ControlProps } from \"../types\";\nimport { Input } from \"../ui/input\";\nimport { TEXT_FOCUS } from \"./text\";\n\ninterface Draft {\n lat: string;\n lng: string;\n label: string;\n}\nconst num = (v: unknown) => (typeof v === \"number\" && Number.isFinite(v) ? String(v) : \"\");\nconst draftOf = (v: unknown): Draft => (isObj(v) ? { lat: num(v.lat), lng: num(v.lng), label: typeof v.label === \"string\" ? v.label : \"\" } : { lat: \"\", lng: \"\", label: \"\" });\nconst PAIR = /^\\s*(-?\\d+(?:\\.\\d+)?)\\s*[,;\\s]\\s*(-?\\d+(?:\\.\\d+)?)\\s*$/;\n\n/** The value a draft writes, or the reason it can't be written yet. */\nexport function locationFromDraft(d: Draft, prev: unknown): { ok: true; value: Record<string, unknown> | null } | { ok: false; reason: string } {\n const lat = d.lat.trim();\n const lng = d.lng.trim();\n const label = d.label.trim();\n if (!lat && !lng && !label) return { ok: true, value: null };\n if (!lat || !lng) return { ok: false, reason: !lat && !lng ? \"Add a latitude and a longitude to save this location.\" : !lat ? \"Add the latitude too: a location needs both.\" : \"Add the longitude too: a location needs both.\" };\n const la = Number(lat);\n const lo = Number(lng);\n if (!Number.isFinite(la) || Math.abs(la) > 90) return { ok: false, reason: \"Latitude must be a number from −90 to 90.\" };\n if (!Number.isFinite(lo) || Math.abs(lo) > 180) return { ok: false, reason: \"Longitude must be a number from −180 to 180.\" };\n const out: Record<string, unknown> = { ...(isObj(prev) ? prev : {}), lat: la, lng: lo };\n if (label) out.label = label;\n else delete out.label;\n return { ok: true, value: out };\n}\n\nexport function LocationControl({ field, value, onChange, readOnly, id, invalid }: ControlProps) {\n const [draft, setDraft] = React.useState<Draft>(() => draftOf(value));\n const [seen, setSeen] = React.useState(value);\n const [mine, setMine] = React.useState<unknown>(undefined);\n // a value set from elsewhere (undo, another editor) replaces the draft; our own writes keep what the author typed\n if (value !== seen) {\n setSeen(value);\n if (value !== mine) setDraft(draftOf(value));\n }\n const result = locationFromDraft(draft, value);\n const reasonId = `${id}-reason`;\n\n const update = (patch: Partial<Draft>) => {\n const next = { ...draft, ...patch };\n setDraft(next);\n const r = locationFromDraft(next, value);\n if (!r.ok) return;\n const same = JSON.stringify(r.value) === JSON.stringify(value ?? null);\n if (same) return;\n setMine(r.value);\n onChange(r.value);\n };\n const coordinate = (key: \"lat\" | \"lng\") => (e: React.ChangeEvent<HTMLInputElement>) => {\n const pair = PAIR.exec(e.target.value);\n update(pair ? { lat: pair[1], lng: pair[2] } : ({ [key]: e.target.value } as Partial<Draft>));\n };\n\n const shown = isObj(value) && typeof value.lat === \"number\" && typeof value.lng === \"number\" ? { lat: value.lat, lng: value.lng } : null;\n return (\n <div className={cn(\"overflow-hidden rounded-kit-lg border border-kit-line\", invalid && \"border-[var(--kit-field-invalid)]\")}>\n <div className=\"relative h-28 overflow-hidden bg-kit-subtle\">\n {/* V2 `.grid-lines` (styles/index.css:1026), inlined: the dash has no such utility */}\n <div\n className=\"absolute inset-0 opacity-80\"\n style={{ backgroundImage: \"linear-gradient(var(--kit-line-subtle) 1px, transparent 1px), linear-gradient(90deg, var(--kit-line-subtle) 1px, transparent 1px)\", backgroundSize: \"24px 24px\" }}\n />\n <svg className=\"absolute inset-0 size-full text-kit-line-strong\" viewBox=\"0 0 400 112\" preserveAspectRatio=\"none\" aria-hidden>\n <path d=\"M0 76 C80 60 120 100 200 78 S320 40 400 60\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"6\" />\n <path d=\"M140 0 L170 112\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" />\n </svg>\n {shown ? (\n <>\n <div className=\"absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-full flex-col items-center\" aria-hidden>\n <span className=\"flex size-7 items-center justify-center rounded-full bg-kit-inverse text-kit-fg-inverse shadow-kit-md\">\n <IconMapPin className=\"size-4\" stroke={1.5} />\n </span>\n <span className=\"size-2 -translate-y-0.5 rotate-45 bg-kit-inverse\" />\n </div>\n <a\n href={`https://www.openstreetmap.org/?mlat=${shown.lat}&mlon=${shown.lng}#map=15/${shown.lat}/${shown.lng}`}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n // D4: V2 (misc.tsx:195) draws the coordinates as a plain chip, no icon; the kit keeps the map link (its\n // accessible name says where it goes) and draws exactly V2's chip\n className=\"tabular-nums absolute bottom-2 right-2 rounded-kit-md bg-kit-surface/90 px-1.5 py-0.5 font-kit-mono text-kit-2xs text-kit-fg-2 shadow-kit-xs hover:text-kit-fg\"\n aria-label={`Open ${shown.lat.toFixed(4)}, ${shown.lng.toFixed(4)} on OpenStreetMap (new tab)`}\n >\n {shown.lat.toFixed(4)}, {shown.lng.toFixed(4)}\n </a>\n </>\n ) : (\n <p className=\"absolute inset-0 flex items-center justify-center text-kit-xs text-kit-fg-3\">No coordinates yet</p>\n )}\n </div>\n <div className=\"flex flex-col gap-2 p-2\">\n <Input\n id={id}\n value={draft.label}\n readOnly={readOnly}\n placeholder=\"Label, e.g. Head office\"\n aria-label={`${field.title} label`}\n leading={<IconMapPin stroke={1.5} />}\n onChange={(e) => update({ label: e.target.value })}\n className={TEXT_FOCUS}\n />\n <div className=\"grid grid-cols-2 gap-2\">\n <Input\n id={`${id}-lat`}\n size=\"sm\"\n inputMode=\"decimal\"\n value={draft.lat}\n readOnly={readOnly}\n aria-label={`${field.title} latitude`}\n aria-invalid={(!result.ok && /latitude/i.test(result.reason)) || undefined}\n aria-describedby={!result.ok ? reasonId : undefined}\n placeholder=\"−90 to 90\"\n onChange={coordinate(\"lat\")}\n leading={<span className=\"text-kit-2xs\">Lat</span>}\n />\n <Input\n id={`${id}-lng`}\n size=\"sm\"\n inputMode=\"decimal\"\n value={draft.lng}\n readOnly={readOnly}\n aria-label={`${field.title} longitude`}\n aria-invalid={(!result.ok && /longitude/i.test(result.reason)) || undefined}\n aria-describedby={!result.ok ? reasonId : undefined}\n placeholder=\"−180 to 180\"\n onChange={coordinate(\"lng\")}\n leading={<span className=\"text-kit-2xs\">Long</span>}\n />\n </div>\n {!result.ok ? (\n <p id={reasonId} role=\"status\" className=\"text-kit-xs text-kit-warning-fg\">\n {result.reason}\n </p>\n ) : null}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,IAAM,OAAO,MAAgB,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAAI,OAAO,CAAC,IAAI;AACvF,IAAM,WAAW,MAAuB,MAAM,CAAC,IAAI;CAAE,KAAK,IAAI,EAAE,GAAG;CAAG,KAAK,IAAI,EAAE,GAAG;CAAG,OAAO,OAAO,EAAE,UAAU,WAAW,EAAE,QAAQ;AAAG,IAAI;CAAE,KAAK;CAAI,KAAK;CAAI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GAAG;MACV,MAAK;MACL,WAAU;MACV,OAAO,MAAM;MACH;MACV,cAAY,GAAG,MAAM,MAAM;MAC3B,gBAAe,CAAC,OAAO,MAAM,aAAa,KAAK,OAAO,MAAM,KAAM,KAAA;MAClE,oBAAkB,CAAC,OAAO,KAAK,WAAW,KAAA;MAC1C,aAAY;MACZ,UAAU,WAAW,KAAK;MAC1B,SAAS,oBAAC,QAAD;OAAM,WAAU;OAAe,UAAA;MAAU,CAAA;KACnD,CAAA,CACE;;IACJ,CAAC,OAAO,KACP,oBAAC,KAAD;KAAG,IAAI;KAAU,MAAK;KAAS,WAAU;KACtC,UAAA,OAAO;IACP,CAAA,IACD;GACD;EACF,CAAA,CAAA;;AAET"}
@@ -55,7 +55,7 @@ function PlainNumber({ field, value, onChange, readOnly, id, invalid, onBlur })
55
55
  };
56
56
  return /* @__PURE__ */ jsxs("div", {
57
57
  "data-slot": "kit-number",
58
- className: cn("flex w-full max-w-40 items-center rounded-kit-md border border-kit-field-border bg-kit-field-bg transition-colors hover:border-kit-field-border-hover focus-within:border-kit-field-border-focus focus-within:bg-kit-field-bg", variant === "document" ? "h-9" : "h-8", invalid && "border-[var(--kit-field-invalid)]", readOnly && "opacity-80"),
58
+ className: cn("flex w-full max-w-40 items-center rounded-kit-md border border-kit-line-strong bg-kit-field-bg transition-colors hover:border-kit-line-strong focus-within:border-kit-line-strong focus-within:bg-kit-field-bg", variant === "document" ? "h-9" : "h-8", invalid && "border-[var(--kit-field-invalid)]", readOnly && "opacity-80"),
59
59
  children: [/* @__PURE__ */ jsx("input", {
60
60
  id,
61
61
  inputMode: "decimal",
@@ -171,10 +171,10 @@ function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }
171
171
  onMouseEnter: () => setHover(i),
172
172
  onClick: () => onChange(pick),
173
173
  className: "relative flex size-7 items-center justify-center transition-transform hover:scale-110",
174
- children: [/* @__PURE__ */ jsx(IconStarFilled, { className: "size-[18px] text-kit-field-border" }), /* @__PURE__ */ jsx("span", {
174
+ children: [/* @__PURE__ */ jsx(IconStarFilled, { className: "size-[18px] text-kit-line-strong" }), /* @__PURE__ */ jsx("span", {
175
175
  className: "absolute inset-0 flex items-center justify-center overflow-hidden",
176
176
  style: { clipPath: `inset(0 ${100 - fill * 100}% 0 0)` },
177
- children: /* @__PURE__ */ jsx(IconStarFilled, { className: "size-[18px] text-kit-rating-on" })
177
+ children: /* @__PURE__ */ jsx(IconStarFilled, { className: "size-[18px] text-kit-warning" })
178
178
  })]
179
179
  }, i);
180
180
  })
@@ -193,7 +193,7 @@ function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }
193
193
  onBlur?.();
194
194
  },
195
195
  onKeyDown: (e) => e.key === "Enter" && e.currentTarget.blur(),
196
- className: "tabular-nums h-7 w-12 rounded-kit-md border border-kit-field-border bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none hover:border-kit-field-border-hover focus:border-kit-field-border-focus focus:bg-kit-field-bg"
196
+ className: "tabular-nums h-7 w-12 rounded-kit-md border border-kit-line-strong bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none hover:border-kit-line-strong focus:border-kit-line-strong focus:bg-kit-field-bg"
197
197
  }),
198
198
  /* @__PURE__ */ jsxs("span", {
199
199
  className: "text-kit-xs text-kit-fg-3",
@@ -1 +1 @@
1
- {"version":3,"file":"number.js","names":[],"sources":["../../src/controls/number.tsx"],"sourcesContent":["/**\n * NUMBER — a plain input, NO stepper (prod CPO-068), V2 HEAD 9829bf1 kit/controls/number.tsx, DESIGN §8.4.\n * ↑/↓ step (Shift ×10), the value commits on blur or Enter, clamped to min/max and rounded to the step's precision only when the schema sets a step (V2 rounds to a default step of 1; prod never rounds, so a typed 2.5 stays 2.5);\n * the unit suffix scrubs on drag (Shift ×10); the wheel never changes a value (it blurs).\n * A number with a scale (`field.scale`, or `layout: \"slider\"` + min/max) is the scale control, which the choice lane\n * registers in NUMBER_SCALE; a host that never registered it edits the raw value (FallbackControl), never a plain box.\n * RATING — stars across the prod scale (config.min 0 · max 5 · step 1 unset) plus a number box for half steps.\n *\n * Stored shapes (prod `number`, `typeof === \"number\"`): a number, or null when cleared. A rating stays on its scale\n * (ratingToProd refuses anything off it), so the control only ever writes a step of the scale or null.\n */\nimport * as React from \"react\";\nimport type { ComponentType } from \"react\";\nimport { IconStarFilled } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitEnv } from \"../context\";\nimport { fieldScale } from \"../schema/scale\";\nimport { FallbackControl } from \"../engine/kit-field\";\nimport { Tooltip } from \"../ui/overlay\";\nimport type { ControlProps } from \"../types\";\nimport { TEXT_FOCUS } from \"./text\";\n\n/** Registered by the choice / scale lane: the control for a number with a scale. */\nexport const NUMBER_SCALE: { control?: ComponentType<ControlProps> } = {};\n\nexport const toNum = (v: unknown): number | null =>\n typeof v === \"number\" && Number.isFinite(v) ? v : typeof v === \"string\" && v.trim() !== \"\" && Number.isFinite(Number(v)) ? Number(v) : null;\n/** What a keystroke may leave in a number box: an optional minus, digits, one decimal point. */\nconst NUMBER_TYPING = /^-?\\d*\\.?\\d*$/;\nconst decimals = (n: number) => (String(n).split(\".\")[1] ?? \"\").length;\n\nexport function NumberControl(p: ControlProps) {\n if (!fieldScale(p.field)) return <PlainNumber {...p} />;\n const Scale = NUMBER_SCALE.control ?? FallbackControl;\n return <Scale {...p} />;\n}\n\nexport function PlainNumber({ field, value, onChange, readOnly, id, invalid, onBlur }: ControlProps) {\n const { variant } = useKitEnv();\n const n = toNum(value);\n const step = field.numeric?.step && field.numeric.step > 0 ? field.numeric.step : 1;\n const lo = field.numeric?.min ?? -Infinity;\n const hi = field.numeric?.max ?? Infinity;\n /* Round to the step only when the schema sets one: with no step a typed 2.5 stays 2.5 (prod NumberField never rounds).\n The rounding then only trims float noise from ↑/↓ (2.5 + 1 → 3.5, 0.1 + 0.2 → 0.3). */\n const setStep = !!field.numeric?.step && field.numeric.step > 0;\n const clamp = (x: number, from?: number) => {\n const precision = setStep ? decimals(step) : from == null ? null : Math.max(decimals(step), decimals(from));\n return Math.min(hi, Math.max(lo, precision == null ? x : Number(x.toFixed(precision))));\n };\n const [draft, setDraft] = React.useState<string | null>(null);\n const start = React.useRef<{ x: number; v: number } | null>(null);\n const unit = field.numeric?.unit;\n const commit = () => {\n if (draft !== null) {\n const t = draft.trim();\n const x = Number(t);\n if (t === \"\") onChange(null);\n else if (t !== \"-\" && t !== \".\" && Number.isFinite(x)) onChange(clamp(x));\n }\n setDraft(null);\n };\n return (\n <div\n data-slot=\"kit-number\"\n className={cn(\n \"flex w-full max-w-40 items-center rounded-kit-md border border-kit-field-border bg-kit-field-bg transition-colors hover:border-kit-field-border-hover focus-within:border-kit-field-border-focus focus-within:bg-kit-field-bg\",\n variant === \"document\" ? \"h-9\" : \"h-8\",\n invalid && \"border-[var(--kit-field-invalid)]\",\n readOnly && \"opacity-80\",\n )}\n >\n <input\n id={id}\n inputMode=\"decimal\"\n value={draft ?? (n == null ? \"\" : String(n))}\n readOnly={readOnly}\n aria-invalid={invalid}\n placeholder={field.placeholder ?? \"0\"}\n onWheel={(e) => e.currentTarget.blur()}\n onChange={(e) => NUMBER_TYPING.test(e.target.value) && setDraft(e.target.value)}\n onBlur={() => {\n commit();\n onBlur?.();\n }}\n onKeyDown={(e) => {\n if (readOnly) return;\n if (e.key === \"Enter\") e.currentTarget.blur();\n if (e.key === \"Escape\" && draft !== null) {\n e.stopPropagation();\n setDraft(null);\n }\n if (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") {\n e.preventDefault();\n const base = draft !== null && Number.isFinite(Number(draft)) && draft.trim() !== \"\" ? Number(draft) : (n ?? 0);\n const d = (e.key === \"ArrowUp\" ? 1 : -1) * step * (e.shiftKey ? 10 : 1);\n setDraft(null);\n onChange(clamp(base + d, base));\n }\n }}\n className={cn(TEXT_FOCUS, \"tabular-nums h-full min-w-0 flex-1 bg-transparent px-2.5 text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\")}\n />\n {unit ? (\n <Tooltip content={readOnly ? undefined : \"Drag to adjust · Shift for ×10\"}>\n <span\n data-slot=\"kit-number-unit\"\n onPointerDown={(e) => {\n if (readOnly) return;\n e.currentTarget.setPointerCapture?.(e.pointerId);\n start.current = { x: e.clientX, v: n ?? 0 };\n }}\n onPointerMove={(e) => {\n if (!start.current) return;\n const dx = e.clientX - start.current.x;\n const next = clamp(start.current.v + Math.round(dx / 4) * step * (e.shiftKey ? 10 : 1), start.current.v);\n if (next !== n) onChange(next);\n }}\n onPointerUp={() => (start.current = null)}\n onPointerCancel={() => (start.current = null)}\n className=\"flex h-full cursor-ew-resize select-none items-center pl-1 pr-2.5 text-kit-xs text-kit-fg-3 hover:text-kit-fg\"\n >\n {unit}\n </span>\n </Tooltip>\n ) : null}\n </div>\n );\n}\n\n/** Prod's rating scale, from the field's numeric bounds (0 · 5 · 1 unset). */\nexport function ratingScale(field: ControlProps[\"field\"]) {\n const min = field.numeric?.min ?? 0;\n const max = field.numeric?.max ?? 5;\n const step = field.numeric?.step && field.numeric.step > 0 ? field.numeric.step : 1;\n return { min, max, step };\n}\n/** A typed rating snapped onto its scale; null when it cannot be (empty, not a number). */\nexport function snapRating(x: number, { min, max, step }: { min: number; max: number; step: number }): number {\n const snapped = min + Math.round((x - min) / step) * step;\n return Number(Math.min(max, Math.max(min, snapped)).toFixed(decimals(step)));\n}\n\nexport function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }: ControlProps) {\n const scale = ratingScale(field);\n const stars = Math.max(1, Math.min(10, Math.ceil(scale.max)));\n const n = toNum(value);\n const [hover, setHover] = React.useState<number | null>(null);\n const [draft, setDraft] = React.useState<string | null>(null);\n const shown = hover ?? n ?? 0;\n // DK-024: one Tab stop (the checked star, else the first); arrows step it, Home / End jump, focus follows the pick\n const group = React.useRef<HTMLDivElement>(null);\n const current = n != null ? Math.min(stars, Math.max(1, Math.ceil(n))) : 0;\n const tabStop = current || 1;\n const step = (e: React.KeyboardEvent, i: number) => {\n const to =\n e.key === \"ArrowRight\" || e.key === \"ArrowUp\" ? Math.min(stars, i + 1)\n : e.key === \"ArrowLeft\" || e.key === \"ArrowDown\" ? Math.max(1, i - 1)\n : e.key === \"Home\" ? 1\n : e.key === \"End\" ? stars\n : null;\n if (to === null || readOnly) return;\n e.preventDefault();\n onChange(snapRating(to, scale));\n group.current?.querySelectorAll<HTMLButtonElement>('[role=\"radio\"]')[to - 1]?.focus();\n };\n const commit = () => {\n if (draft !== null) {\n const t = draft.trim();\n if (t === \"\") onChange(null);\n else if (Number.isFinite(Number(t)) && t !== \".\") onChange(snapRating(Number(t), scale));\n }\n setDraft(null);\n };\n return (\n <div className=\"flex items-center gap-3\">\n <div ref={group} role=\"radiogroup\" aria-label={`${field.title} rating`} className=\"flex items-center\" onMouseLeave={() => setHover(null)}>\n {Array.from({ length: stars }, (_, k) => k + 1).map((i) => {\n const fill = Math.max(0, Math.min(1, shown - (i - 1)));\n const pick = snapRating(i, scale);\n return (\n <button\n key={i}\n type=\"button\"\n role=\"radio\"\n aria-checked={n != null && Math.ceil(n) === i}\n aria-label={`${i} star${i > 1 ? \"s\" : \"\"}`}\n tabIndex={i === tabStop ? 0 : -1}\n onKeyDown={(e) => step(e, i)}\n disabled={readOnly}\n onMouseEnter={() => setHover(i)}\n onClick={() => onChange(pick)}\n className=\"relative flex size-7 items-center justify-center transition-transform hover:scale-110\"\n >\n <IconStarFilled className=\"size-[18px] text-kit-field-border\" />\n <span className=\"absolute inset-0 flex items-center justify-center overflow-hidden\" style={{ clipPath: `inset(0 ${100 - fill * 100}% 0 0)` }}>\n <IconStarFilled className=\"size-[18px] text-kit-rating-on\" />\n </span>\n </button>\n );\n })}\n </div>\n <input\n id={id}\n inputMode=\"decimal\"\n value={draft ?? (n == null ? \"\" : String(n))}\n readOnly={readOnly}\n aria-invalid={invalid}\n placeholder=\"–\"\n onWheel={(e) => e.currentTarget.blur()}\n onChange={(e) => /^\\d*\\.?\\d*$/.test(e.target.value) && setDraft(e.target.value)}\n onBlur={() => {\n commit();\n onBlur?.();\n }}\n onKeyDown={(e) => e.key === \"Enter\" && e.currentTarget.blur()}\n className=\"tabular-nums h-7 w-12 rounded-kit-md border border-kit-field-border bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none hover:border-kit-field-border-hover focus:border-kit-field-border-focus focus:bg-kit-field-bg\"\n />\n <span className=\"text-kit-xs text-kit-fg-3\">out of {scale.max}</span>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,eAA0D,CAAC;AAExE,IAAa,SAAS,MACpB,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAAI,IAAI,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI;;AAEzI,IAAM,gBAAgB;AACtB,IAAM,YAAY,OAAe,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,GAAA,CAAI;AAEhE,SAAgB,cAAc,GAAiB;CAC7C,IAAI,CAAC,WAAW,EAAE,KAAK,GAAG,OAAO,oBAAC,aAAD,EAAa,GAAI,EAAI,CAAA;CACtD,MAAM,QAAQ,aAAa,WAAW;CACtC,OAAO,oBAAC,OAAD,EAAO,GAAI,EAAI,CAAA;AACxB;AAEA,SAAgB,YAAY,EAAE,OAAO,OAAO,UAAU,UAAU,IAAI,SAAS,UAAwB;CACnG,MAAM,EAAE,YAAY,UAAU;CAC9B,MAAM,IAAI,MAAM,KAAK;CACrB,MAAM,OAAO,MAAM,SAAS,QAAQ,MAAM,QAAQ,OAAO,IAAI,MAAM,QAAQ,OAAO;CAClF,MAAM,KAAK,MAAM,SAAS,OAAO;CACjC,MAAM,KAAK,MAAM,SAAS,OAAO;CAGjC,MAAM,UAAU,CAAC,CAAC,MAAM,SAAS,QAAQ,MAAM,QAAQ,OAAO;CAC9D,MAAM,SAAS,GAAW,SAAkB;EAC1C,MAAM,YAAY,UAAU,SAAS,IAAI,IAAI,QAAQ,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AU;GACX,CAAA;GACD,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CAA4C,WAAQ,MAAM,GAAU;;EACjE;;AAET"}
1
+ {"version":3,"file":"number.js","names":[],"sources":["../../src/controls/number.tsx"],"sourcesContent":["/**\n * NUMBER — a plain input, NO stepper (prod CPO-068), V2 HEAD 9829bf1 kit/controls/number.tsx, DESIGN §8.4.\n * ↑/↓ step (Shift ×10), the value commits on blur or Enter, clamped to min/max and rounded to the step's precision only when the schema sets a step (V2 rounds to a default step of 1; prod never rounds, so a typed 2.5 stays 2.5);\n * the unit suffix scrubs on drag (Shift ×10); the wheel never changes a value (it blurs).\n * A number with a scale (`field.scale`, or `layout: \"slider\"` + min/max) is the scale control, which the choice lane\n * registers in NUMBER_SCALE; a host that never registered it edits the raw value (FallbackControl), never a plain box.\n * RATING — stars across the prod scale (config.min 0 · max 5 · step 1 unset) plus a number box for half steps.\n *\n * Stored shapes (prod `number`, `typeof === \"number\"`): a number, or null when cleared. A rating stays on its scale\n * (ratingToProd refuses anything off it), so the control only ever writes a step of the scale or null.\n */\nimport * as React from \"react\";\nimport type { ComponentType } from \"react\";\nimport { IconStarFilled } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitEnv } from \"../context\";\nimport { fieldScale } from \"../schema/scale\";\nimport { FallbackControl } from \"../engine/kit-field\";\nimport { Tooltip } from \"../ui/overlay\";\nimport type { ControlProps } from \"../types\";\nimport { TEXT_FOCUS } from \"./text\";\n\n/** Registered by the choice / scale lane: the control for a number with a scale. */\nexport const NUMBER_SCALE: { control?: ComponentType<ControlProps> } = {};\n\nexport const toNum = (v: unknown): number | null =>\n typeof v === \"number\" && Number.isFinite(v) ? v : typeof v === \"string\" && v.trim() !== \"\" && Number.isFinite(Number(v)) ? Number(v) : null;\n/** What a keystroke may leave in a number box: an optional minus, digits, one decimal point. */\nconst NUMBER_TYPING = /^-?\\d*\\.?\\d*$/;\nconst decimals = (n: number) => (String(n).split(\".\")[1] ?? \"\").length;\n\nexport function NumberControl(p: ControlProps) {\n if (!fieldScale(p.field)) return <PlainNumber {...p} />;\n const Scale = NUMBER_SCALE.control ?? FallbackControl;\n return <Scale {...p} />;\n}\n\nexport function PlainNumber({ field, value, onChange, readOnly, id, invalid, onBlur }: ControlProps) {\n const { variant } = useKitEnv();\n const n = toNum(value);\n const step = field.numeric?.step && field.numeric.step > 0 ? field.numeric.step : 1;\n const lo = field.numeric?.min ?? -Infinity;\n const hi = field.numeric?.max ?? Infinity;\n /* Round to the step only when the schema sets one: with no step a typed 2.5 stays 2.5 (prod NumberField never rounds).\n The rounding then only trims float noise from ↑/↓ (2.5 + 1 → 3.5, 0.1 + 0.2 → 0.3). */\n const setStep = !!field.numeric?.step && field.numeric.step > 0;\n const clamp = (x: number, from?: number) => {\n const precision = setStep ? decimals(step) : from == null ? null : Math.max(decimals(step), decimals(from));\n return Math.min(hi, Math.max(lo, precision == null ? x : Number(x.toFixed(precision))));\n };\n const [draft, setDraft] = React.useState<string | null>(null);\n const start = React.useRef<{ x: number; v: number } | null>(null);\n const unit = field.numeric?.unit;\n const commit = () => {\n if (draft !== null) {\n const t = draft.trim();\n const x = Number(t);\n if (t === \"\") onChange(null);\n else if (t !== \"-\" && t !== \".\" && Number.isFinite(x)) onChange(clamp(x));\n }\n setDraft(null);\n };\n return (\n <div\n data-slot=\"kit-number\"\n className={cn(\n \"flex w-full max-w-40 items-center rounded-kit-md border border-kit-line-strong bg-kit-field-bg transition-colors hover:border-kit-line-strong focus-within:border-kit-line-strong focus-within:bg-kit-field-bg\",\n variant === \"document\" ? \"h-9\" : \"h-8\",\n invalid && \"border-[var(--kit-field-invalid)]\",\n readOnly && \"opacity-80\",\n )}\n >\n <input\n id={id}\n inputMode=\"decimal\"\n value={draft ?? (n == null ? \"\" : String(n))}\n readOnly={readOnly}\n aria-invalid={invalid}\n placeholder={field.placeholder ?? \"0\"}\n onWheel={(e) => e.currentTarget.blur()}\n onChange={(e) => NUMBER_TYPING.test(e.target.value) && setDraft(e.target.value)}\n onBlur={() => {\n commit();\n onBlur?.();\n }}\n onKeyDown={(e) => {\n if (readOnly) return;\n if (e.key === \"Enter\") e.currentTarget.blur();\n if (e.key === \"Escape\" && draft !== null) {\n e.stopPropagation();\n setDraft(null);\n }\n if (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") {\n e.preventDefault();\n const base = draft !== null && Number.isFinite(Number(draft)) && draft.trim() !== \"\" ? Number(draft) : (n ?? 0);\n const d = (e.key === \"ArrowUp\" ? 1 : -1) * step * (e.shiftKey ? 10 : 1);\n setDraft(null);\n onChange(clamp(base + d, base));\n }\n }}\n className={cn(TEXT_FOCUS, \"tabular-nums h-full min-w-0 flex-1 bg-transparent px-2.5 text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\")}\n />\n {unit ? (\n <Tooltip content={readOnly ? undefined : \"Drag to adjust · Shift for ×10\"}>\n <span\n data-slot=\"kit-number-unit\"\n onPointerDown={(e) => {\n if (readOnly) return;\n e.currentTarget.setPointerCapture?.(e.pointerId);\n start.current = { x: e.clientX, v: n ?? 0 };\n }}\n onPointerMove={(e) => {\n if (!start.current) return;\n const dx = e.clientX - start.current.x;\n const next = clamp(start.current.v + Math.round(dx / 4) * step * (e.shiftKey ? 10 : 1), start.current.v);\n if (next !== n) onChange(next);\n }}\n onPointerUp={() => (start.current = null)}\n onPointerCancel={() => (start.current = null)}\n className=\"flex h-full cursor-ew-resize select-none items-center pl-1 pr-2.5 text-kit-xs text-kit-fg-3 hover:text-kit-fg\"\n >\n {unit}\n </span>\n </Tooltip>\n ) : null}\n </div>\n );\n}\n\n/** Prod's rating scale, from the field's numeric bounds (0 · 5 · 1 unset). */\nexport function ratingScale(field: ControlProps[\"field\"]) {\n const min = field.numeric?.min ?? 0;\n const max = field.numeric?.max ?? 5;\n const step = field.numeric?.step && field.numeric.step > 0 ? field.numeric.step : 1;\n return { min, max, step };\n}\n/** A typed rating snapped onto its scale; null when it cannot be (empty, not a number). */\nexport function snapRating(x: number, { min, max, step }: { min: number; max: number; step: number }): number {\n const snapped = min + Math.round((x - min) / step) * step;\n return Number(Math.min(max, Math.max(min, snapped)).toFixed(decimals(step)));\n}\n\nexport function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }: ControlProps) {\n const scale = ratingScale(field);\n const stars = Math.max(1, Math.min(10, Math.ceil(scale.max)));\n const n = toNum(value);\n const [hover, setHover] = React.useState<number | null>(null);\n const [draft, setDraft] = React.useState<string | null>(null);\n const shown = hover ?? n ?? 0;\n // DK-024: one Tab stop (the checked star, else the first); arrows step it, Home / End jump, focus follows the pick\n const group = React.useRef<HTMLDivElement>(null);\n const current = n != null ? Math.min(stars, Math.max(1, Math.ceil(n))) : 0;\n const tabStop = current || 1;\n const step = (e: React.KeyboardEvent, i: number) => {\n const to =\n e.key === \"ArrowRight\" || e.key === \"ArrowUp\" ? Math.min(stars, i + 1)\n : e.key === \"ArrowLeft\" || e.key === \"ArrowDown\" ? Math.max(1, i - 1)\n : e.key === \"Home\" ? 1\n : e.key === \"End\" ? stars\n : null;\n if (to === null || readOnly) return;\n e.preventDefault();\n onChange(snapRating(to, scale));\n group.current?.querySelectorAll<HTMLButtonElement>('[role=\"radio\"]')[to - 1]?.focus();\n };\n const commit = () => {\n if (draft !== null) {\n const t = draft.trim();\n if (t === \"\") onChange(null);\n else if (Number.isFinite(Number(t)) && t !== \".\") onChange(snapRating(Number(t), scale));\n }\n setDraft(null);\n };\n return (\n <div className=\"flex items-center gap-3\">\n <div ref={group} role=\"radiogroup\" aria-label={`${field.title} rating`} className=\"flex items-center\" onMouseLeave={() => setHover(null)}>\n {Array.from({ length: stars }, (_, k) => k + 1).map((i) => {\n const fill = Math.max(0, Math.min(1, shown - (i - 1)));\n const pick = snapRating(i, scale);\n return (\n <button\n key={i}\n type=\"button\"\n role=\"radio\"\n aria-checked={n != null && Math.ceil(n) === i}\n aria-label={`${i} star${i > 1 ? \"s\" : \"\"}`}\n tabIndex={i === tabStop ? 0 : -1}\n onKeyDown={(e) => step(e, i)}\n disabled={readOnly}\n onMouseEnter={() => setHover(i)}\n onClick={() => onChange(pick)}\n className=\"relative flex size-7 items-center justify-center transition-transform hover:scale-110\"\n >\n <IconStarFilled className=\"size-[18px] text-kit-line-strong\" />\n <span className=\"absolute inset-0 flex items-center justify-center overflow-hidden\" style={{ clipPath: `inset(0 ${100 - fill * 100}% 0 0)` }}>\n <IconStarFilled className=\"size-[18px] text-kit-warning\" />\n </span>\n </button>\n );\n })}\n </div>\n <input\n id={id}\n inputMode=\"decimal\"\n value={draft ?? (n == null ? \"\" : String(n))}\n readOnly={readOnly}\n aria-invalid={invalid}\n placeholder=\"–\"\n onWheel={(e) => e.currentTarget.blur()}\n onChange={(e) => /^\\d*\\.?\\d*$/.test(e.target.value) && setDraft(e.target.value)}\n onBlur={() => {\n commit();\n onBlur?.();\n }}\n onKeyDown={(e) => e.key === \"Enter\" && e.currentTarget.blur()}\n className=\"tabular-nums h-7 w-12 rounded-kit-md border border-kit-line-strong bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none hover:border-kit-line-strong focus:border-kit-line-strong focus:bg-kit-field-bg\"\n />\n <span className=\"text-kit-xs text-kit-fg-3\">out of {scale.max}</span>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,eAA0D,CAAC;AAExE,IAAa,SAAS,MACpB,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAAI,IAAI,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI;;AAEzI,IAAM,gBAAgB;AACtB,IAAM,YAAY,OAAe,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,GAAA,CAAI;AAEhE,SAAgB,cAAc,GAAiB;CAC7C,IAAI,CAAC,WAAW,EAAE,KAAK,GAAG,OAAO,oBAAC,aAAD,EAAa,GAAI,EAAI,CAAA;CACtD,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AD;OAAM,WAAU;OAAoE,OAAO,EAAE,UAAU,WAAW,MAAM,OAAO,IAAI,QAAQ;OACzI,UAAA,oBAAC,gBAAD,EAAgB,WAAU,+BAAgC,CAAA;MACtD,CAAA,CACA;KAhBD,GAAA,CAgBC;IAEZ,CAAC;GACE,CAAA;GACL,oBAAC,SAAD;IACM;IACJ,WAAU;IACV,OAAO,UAAU,KAAK,OAAO,KAAK,OAAO,CAAC;IAChC;IACV,gBAAc;IACd,aAAY;IACZ,UAAU,MAAM,EAAE,cAAc,KAAK;IACrC,WAAW,MAAM,cAAc,KAAK,EAAE,OAAO,KAAK,KAAK,SAAS,EAAE,OAAO,KAAK;IAC9E,cAAc;KACZ,OAAO;KACP,SAAS;IACX;IACA,YAAY,MAAM,EAAE,QAAQ,WAAW,EAAE,cAAc,KAAK;IAC5D,WAAU;GACX,CAAA;GACD,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CAA4C,WAAQ,MAAM,GAAU;;EACjE;;AAET"}
@@ -405,7 +405,7 @@ function PickerBody({ to, filter, selected, multi, max, noun, onPick, onNone, ca
405
405
  defaultValue: q,
406
406
  "aria-label": `New ${noun} name`,
407
407
  placeholder: `New ${noun} name`,
408
- className: "h-8 min-w-0 flex-1 rounded-kit-md border border-kit-field-border bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none focus:bg-kit-field-bg focus:ring-1 focus:ring-kit-field-border-focus"
408
+ className: "h-8 min-w-0 flex-1 rounded-kit-md border border-kit-line-strong bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none focus:bg-kit-field-bg focus:ring-1 focus:ring-kit-line-strong"
409
409
  }), /* @__PURE__ */ jsx(Button, {
410
410
  size: "sm",
411
411
  type: "submit",
@@ -687,7 +687,7 @@ function ReferenceControl({ field, value, onChange, readOnly, id, path }) {
687
687
  "data-slot": missing ? "kit-reference-card" : void 0,
688
688
  "data-missing": missing || void 0,
689
689
  "aria-label": missing ? `${field.title}: Missing ${noun}.${editable ? " Change" : ""}` : `${field.title}: select ${withArticle(noun)}`,
690
- className: cn("flex h-8 w-full items-center gap-2 rounded-kit-md border border-kit-field-border bg-kit-field-bg px-2.5 text-left text-kit-sm text-kit-fg-3 transition-colors hover:border-kit-field-border-hover data-[popup-open]:border-kit-field-border-focus data-[popup-open]:bg-kit-field-bg", missing && "border-kit-warning-line text-kit-warning-fg hover:border-kit-warning-line data-[popup-open]:border-kit-warning-line"),
690
+ className: cn("flex h-8 w-full items-center gap-2 rounded-kit-md border border-kit-line-strong bg-kit-field-bg px-2.5 text-left text-kit-sm text-kit-fg-3 transition-colors hover:border-kit-line-strong data-[popup-open]:border-kit-line-strong data-[popup-open]:bg-kit-field-bg", missing && "border-kit-warning-line text-kit-warning-fg hover:border-kit-warning-line data-[popup-open]:border-kit-warning-line"),
691
691
  children: [
692
692
  /* @__PURE__ */ jsx(IconFileDatabase, {
693
693
  className: "size-4",
@@ -809,7 +809,7 @@ function ReferencesControl({ field, value, onChange, readOnly, id, path }) {
809
809
  id: readOnly ? id : void 0,
810
810
  role: readOnly ? "group" : void 0,
811
811
  "aria-label": readOnly ? field.title : void 0,
812
- className: "flex min-h-8 flex-wrap items-center gap-1 rounded-kit-md border border-kit-field-border bg-kit-field-bg p-1 transition-colors hover:border-kit-field-border-hover",
812
+ className: "flex min-h-8 flex-wrap items-center gap-1 rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-1 transition-colors hover:border-kit-line-strong",
813
813
  children: [
814
814
  shown.map((x) => /* @__PURE__ */ jsx(RefChip, {
815
815
  id: x,
@@ -1 +1 @@
1
- {"version":3,"file":"reference.js","names":[],"sources":["../../src/controls/reference.tsx"],"sourcesContent":["/**\n * REFERENCE — single: a select-like trigger (\"Select a CMS item\") → a 300px search popover with \"None\", result rows,\n * drafts labelled, and \"Create new\" inline when the host can create. Never lists the document being edited. No one-click\n * clear (⋯ → Remove). MULTI-REFERENCE — reorderable chips + \"+ Add\", \"n / max\"; at the limit the picker swaps in place.\n * (V2 HEAD 9829bf1 kit/controls/reference.tsx, DESIGN.md 6.8, 8.16, 9.6.)\n *\n * The rows come from the host (reference-services.ts): `searchReferences` is POST /content/reference-options, which\n * already applies the field's `reference.filter` and scope; `truncated` says its filter scan stopped early, and the\n * picker says so. The stored value is the target id (\"en_12\"; a list for many), exactly V2's shape.\n *\n * Kit deviations from V2: no seed rows (every row is a real record from the service); matching is the server's title /\n * slug search, so rows keep the server's order; a stored id the lookup cannot find shows as a \"Missing\" card, or in a\n * multi list one compact \"n missing\" chip with Remove (DESIGN 9.6's production rule), instead of disappearing; chips sort with the engine's `useDragReorder`\n * (@dnd-kit is not on the kit allow-list).\n */\nimport * as React from \"react\";\nimport { IconArrowUpRight, IconCheck, IconChevronDown, IconDatabase, IconDots, IconFileDatabase, IconFileText, IconForms, IconPlus, IconReplace, IconSearch, IconShoppingBag, IconTrash, IconX } from \"@tabler/icons-react\";\nimport type { KitReferenceConnect, KitReferenceCreateCapability, KitReferenceKind, KitReferenceOption } from \"./reference-services\";\nimport { Button } from \"../ui/button\";\nimport { Avatar } from \"../ui/display\";\nimport { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Popover, PopoverContent, PopoverTrigger } from \"../ui/overlay\";\nimport { cn } from \"../lib/cn\";\nimport { refFilterText } from \"../lib/schema\";\nimport { useDragReorder } from \"../engine/item-list\";\nimport { useKitEnv, useKitServices } from \"../context\";\nimport type { ControlProps } from \"../types\";\nimport type { FieldPath } from \"../schema/types\";\n\nconst NON_ENTRY = new Set([\"page\", \"form\", \"collection\", \"shopify\"]);\nconst isEntryTarget = (t: string) => !NON_ENTRY.has(t);\nconst targetsOf = (field: ControlProps[\"field\"]) => field.reference?.to ?? [];\n\n/** The noun the picker uses: the field's own (`reference.noun`), else D48's (\"CMS item\" where V2 says \"entry\"). */\nexport function referenceNoun(to: string[], noun?: string): string {\n if (noun) return noun;\n if (to.length === 1) return to[0] === \"page\" ? \"page\" : to[0] === \"form\" ? \"form\" : to[0] === \"collection\" ? \"collection\" : to[0] === \"shopify\" ? \"product\" : \"CMS item\";\n return to.length && to.every(isEntryTarget) ? \"CMS item\" : \"item\";\n}\nconst plural = (noun: string) => (noun === \"CMS item\" ? \"CMS items\" : `${noun}s`);\nconst withArticle = (noun: string) => `${/^[aeiou]/i.test(noun) ? \"an\" : \"a\"} ${noun}`;\nconst reasonOf = (e: unknown) => (e instanceof Error ? e.message : String(e));\nconst PAGE = 25;\n/** V2 (Radix) slides a picker that would overflow along the edge, keeping it over the panel; Base UI would flip it to\n * end-aligned, which hangs it left over the preview */\nconst SHIFT = { align: \"shift\" } as const;\n\nconst KIND_ICON: Record<KitReferenceKind, React.ComponentType<{ className?: string; stroke?: number }>> = {\n entry: IconFileDatabase,\n page: IconFileText,\n form: IconForms,\n collection: IconDatabase,\n shopify: IconShoppingBag,\n};\n\nexport function RefThumb({ o, size = 28 }: { o: Pick<KitReferenceOption, \"kind\" | \"title\" | \"photo\" | \"avatar\" | \"cover\"> | null; size?: number }) {\n // V2 reference.tsx:152-156: a person is their round avatar (initials without a photo), a record with a cover its image\n if (o?.avatar || o?.photo) return <Avatar name={o.title} src={o.photo ?? undefined} size={size} decorative />;\n if (o?.cover) return <img src={o.cover} alt=\"\" style={{ width: size, height: size }} className=\"shrink-0 rounded-kit-md border border-kit-line object-cover\" />;\n const Icon = o ? KIND_ICON[o.kind] : IconFileDatabase;\n return (\n <span aria-hidden style={{ width: size, height: size }} className=\"flex shrink-0 items-center justify-center rounded-kit-md border border-kit-line bg-kit-subtle text-kit-fg-3\">\n <Icon className={size > 24 ? \"size-4\" : \"size-3.5\"} stroke={1.5} />\n </span>\n );\n}\n\nfunction DraftChip({ status, missingRequired }: { status?: string | null; missingRequired?: number }) {\n if (status !== \"draft\") return null;\n const n = missingRequired ?? 0;\n return (\n <span className=\"shrink-0 rounded-kit-md bg-kit-muted px-1 text-kit-2xs text-kit-fg-3\">\n Draft{n > 0 ? ` · ${n} required field${n === 1 ? \"\" : \"s\"} empty` : \"\"}\n </span>\n );\n}\n\n/* ── Lookup: stored ids → their records ────────────────────────────── */\n/**\n * The records behind `ids`, read once per id through `lookupReferences`. An id the service does not hand back is\n * `missing`; a failed read is `error` (in words). A row picked in the picker is `remember`ed, so it shows at once.\n */\nexport function useReferenceRecords(ids: string[], to: string[]) {\n const { lookupReferences } = useKitServices();\n const [known, setKnown] = React.useState<Record<string, KitReferenceOption>>({});\n const [missing, setMissing] = React.useState<ReadonlySet<string>>(new Set());\n const [error, setError] = React.useState<string | null>(null);\n const inflight = React.useRef(new Set<string>());\n const alive = React.useRef(true);\n // set on every mount: StrictMode mounts, unmounts and mounts again, and a flag only cleared would drop every read\n React.useEffect(() => {\n alive.current = true;\n return () => {\n alive.current = false;\n };\n }, []);\n const idsKey = ids.join(\"|\");\n const toKey = to.join(\"|\");\n React.useEffect(() => {\n if (!lookupReferences) return;\n const asked = ids.filter((x) => !known[x] && !missing.has(x) && !inflight.current.has(x));\n if (!asked.length) return;\n for (const x of asked) inflight.current.add(x);\n lookupReferences(asked, to)\n .then((rows) => {\n if (!alive.current) return;\n const found = new Set(rows.map((r) => r.id));\n setKnown((k) => ({ ...k, ...Object.fromEntries(rows.map((r) => [r.id, r])) }));\n setMissing((m) => new Set([...m, ...asked.filter((x) => !found.has(x))]));\n setError(null);\n })\n .catch((e: unknown) => alive.current && setError(`The saved ${plural(referenceNoun(to))} could not be read: ${reasonOf(e)}`))\n .finally(() => {\n for (const x of asked) inflight.current.delete(x);\n });\n }, [idsKey, toKey, lookupReferences, known, missing]); // eslint-disable-line react-hooks/exhaustive-deps\n const remember = React.useCallback((o: KitReferenceOption) => {\n setKnown((k) => ({ ...k, [o.id]: o }));\n setMissing((m) => (m.has(o.id) ? new Set([...m].filter((x) => x !== o.id)) : m));\n }, []);\n return { known, missing, loading: !!lookupReferences && ids.some((x) => !known[x] && !missing.has(x)) && !error, error, remember, canLookup: !!lookupReferences };\n}\n\n/* ── The search popover body, shared by single and multi ───────────── */\nfunction PickerBody({\n to,\n filter,\n selected,\n multi,\n max,\n noun,\n onPick,\n onNone,\n canCreate,\n noCreateWhy,\n onCreated,\n excludeId,\n}: {\n to: string[];\n filter?: string;\n /** a record never listed besides the document being edited (the field's `reference.excludeId`) */\n excludeId?: string;\n selected: string[];\n multi?: boolean;\n max?: number;\n noun: string;\n onPick: (o: KitReferenceOption) => void;\n onNone?: () => void;\n canCreate: boolean;\n /** why \"Create new\" isn't offered here, for the empty state (useCreate) */\n noCreateWhy?: string;\n onCreated: (o: KitReferenceOption) => void;\n}) {\n const { searchReferences, createReference, toast } = useKitServices();\n const env = useKitEnv();\n const [q, setQ] = React.useState(\"\");\n const [query, setQuery] = React.useState(\"\");\n const [rows, setRows] = React.useState<KitReferenceOption[]>([]);\n const [truncated, setTruncated] = React.useState(false);\n const [loading, setLoading] = React.useState(true);\n const [error, setError] = React.useState<string | null>(null);\n const [active, setActive] = React.useState(0);\n const [creating, setCreating] = React.useState(false);\n const [createBusy, setCreateBusy] = React.useState(false);\n const [createError, setCreateError] = React.useState<string | null>(null);\n const listId = React.useId();\n\n React.useEffect(() => {\n const t = window.setTimeout(() => setQuery(q.trim()), q.trim() ? 180 : 0);\n return () => window.clearTimeout(t);\n }, [q]);\n const toKey = to.join(\"|\");\n React.useEffect(() => {\n if (!searchReferences) return;\n const ctrl = new AbortController();\n setLoading(true);\n searchReferences({ to, filter, q: query, limit: PAGE, excludeId: excludeId ?? env.docId, signal: ctrl.signal })\n .then((r) => {\n if (ctrl.signal.aborted) return;\n setRows(r.options.filter((o) => o.id !== env.docId && o.id !== excludeId));\n setTruncated(r.truncated);\n setError(null);\n setActive(0);\n })\n .catch((e: unknown) => !ctrl.signal.aborted && setError(reasonOf(e)))\n .finally(() => !ctrl.signal.aborted && setLoading(false));\n return () => ctrl.abort();\n }, [query, toKey, filter, env.docId, excludeId, searchReferences]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const none = onNone && !q;\n const total = rows.length + (none ? 1 : 0);\n const at = (i: number) => (none ? (i === 0 ? null : rows[i - 1]) : rows[i]);\n const full = multi && max != null && selected.length >= max;\n const choose = (i: number) => {\n const o = at(i);\n if (o) onPick(o);\n else if (none) onNone!();\n };\n const optionId = (i: number) => `${listId}-${i}`;\n // one create at a time: a second Enter or click while the first is out is the same request, not another draft\n const createOut = React.useRef(false);\n const create = async (title: string) => {\n if (!createReference || createOut.current) return;\n createOut.current = true;\n setCreateBusy(true);\n setCreateError(null);\n try {\n const o = await createReference({ to: to[0], title });\n setCreating(false);\n onCreated(o);\n const open =\n o.kind === \"entry\" && o.modelSlug && env.onOpenReference\n ? { label: \"Open\", onClick: () => env.onOpenReference!({ collectionId: o.modelSlug!, entryId: o.id, title: o.title }) }\n : undefined;\n toast?.success(o.created === false ? `Using existing ‘${o.title}’` : `Created ‘${o.title}’ as a draft`, open ? { action: open } : undefined);\n } catch (e) {\n setCreateError(`Not created: ${reasonOf(e)}`);\n } finally {\n createOut.current = false;\n setCreateBusy(false);\n }\n };\n // V2's search copy: \"pages\" for a page picker, \"entries\" for every other one\n const searchLabel = `Search ${noun === \"page\" ? \"pages\" : \"entries\"}`;\n return (\n <div className=\"flex flex-col\">\n <label className=\"flex h-10 items-center gap-2 border-b border-kit-line px-3 text-kit-fg-3\">\n <IconSearch className=\"size-4 shrink-0\" stroke={1.5} aria-hidden />\n <input\n autoFocus\n value={q}\n onChange={(e) => {\n setQ(e.target.value);\n setActive(0);\n }}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setActive((a) => Math.min(total - 1, a + 1));\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setActive((a) => Math.max(0, a - 1));\n } else if (e.key === \"Home\") {\n e.preventDefault();\n setActive(0);\n } else if (e.key === \"End\") {\n e.preventDefault();\n setActive(Math.max(0, total - 1));\n } else if (e.key === \"Enter\" && total) {\n e.preventDefault();\n choose(Math.min(active, total - 1));\n }\n }}\n placeholder={`${searchLabel}…`}\n role=\"combobox\"\n aria-expanded\n aria-autocomplete=\"list\"\n aria-controls={listId}\n aria-activedescendant={total ? optionId(Math.min(active, total - 1)) : undefined}\n aria-label={searchLabel}\n className=\"h-full min-w-0 flex-1 bg-transparent text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\"\n />\n </label>\n <div id={listId} className=\"max-h-72 overflow-y-auto p-1\" role=\"listbox\" aria-label={`${noun} results`} aria-multiselectable={multi || undefined} aria-busy={loading || undefined}>\n {none ? (\n <button\n type=\"button\"\n id={optionId(0)}\n role=\"option\"\n aria-selected={false}\n tabIndex={-1}\n onMouseEnter={() => setActive(0)}\n onMouseDown={(e) => e.preventDefault()}\n onClick={onNone}\n className={cn(\"flex h-8 w-full items-center gap-2 rounded-kit-md px-2 text-left text-kit-sm text-kit-fg-3 hover:bg-kit-hover\", active === 0 && \"bg-kit-hover\")}\n >\n None\n </button>\n ) : null}\n {rows.map((o, j) => {\n const i = j + (none ? 1 : 0);\n const on = selected.includes(o.id);\n return (\n <button\n type=\"button\"\n key={`${o.kind}:${o.id}`}\n id={optionId(i)}\n role=\"option\"\n aria-selected={on}\n tabIndex={-1}\n onMouseEnter={() => setActive(i)}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => onPick(o)}\n className={cn(\"flex w-full items-center gap-2.5 rounded-kit-md p-1.5 text-left\", i === active && \"bg-kit-hover\")}\n >\n {multi ? (\n <span aria-hidden className={cn(\"flex size-4 shrink-0 items-center justify-center rounded-kit-md border\", on ? \"border-kit-accent bg-kit-accent text-kit-accent-on\" : \"border-kit-line-strong\", !on && full && \"opacity-40\")}>\n {on ? <IconCheck className=\"size-3\" stroke={3} /> : null}\n </span>\n ) : null}\n <RefThumb o={o} size={28} />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-kit-sm text-kit-fg\">{o.title}</span>\n {o.subtitle ? <span className=\"block truncate text-kit-xs text-kit-fg-3\">{o.subtitle}</span> : null}\n </span>\n <DraftChip status={o.status} missingRequired={o.missingRequired} />\n {!multi && on ? <IconCheck className=\"size-4 shrink-0 text-kit-fg\" stroke={2} aria-hidden /> : null}\n </button>\n );\n })}\n {!loading && !error && rows.length === 0 ? (\n <div className=\"px-3 py-6 text-center text-kit-sm text-kit-fg-3\">\n No matches\n {noCreateWhy ? (\n <p role=\"note\" className=\"mt-1 text-kit-xs\">\n {noCreateWhy}\n </p>\n ) : null}\n </div>\n ) : null}\n {loading && rows.length === 0 ? (\n <div role=\"status\" className=\"px-3 py-6 text-center text-kit-sm text-kit-fg-3\">\n Searching…\n </div>\n ) : null}\n {error ? (\n <p role=\"alert\" className=\"px-3 py-3 text-kit-xs text-kit-danger-fg\">\n {plural(noun).replace(/^./, (c) => c.toUpperCase())} could not be listed: {error}\n </p>\n ) : null}\n </div>\n {truncated && !error ? (\n <p role=\"note\" className=\"border-t border-kit-line px-3 py-2 text-kit-xs text-kit-warning-fg\">\n Some {plural(noun)} were not checked against this field's filter, so the list may be incomplete. Search by name to narrow it.\n </p>\n ) : null}\n {multi ? (\n <div className={cn(\"border-t border-kit-line px-3 py-2 text-kit-xs\", full ? \"text-kit-warning-fg\" : \"text-kit-fg-3\")}>\n {selected.length}\n {max != null ? ` of ${max}` : \"\"} selected{full ? ` · Limit is ${max}. Picking another swaps out the last one.` : \"\"}\n </div>\n ) : null}\n {canCreate ? (\n <div className=\"border-t border-kit-line p-1.5\">\n {creating ? (\n <>\n <form\n className=\"flex items-center gap-1.5\"\n onSubmit={(e) => {\n e.preventDefault();\n e.stopPropagation();\n const t = String(new FormData(e.currentTarget).get(\"t\") ?? \"\").trim();\n if (t) void create(t);\n }}\n >\n <input\n name=\"t\"\n autoFocus\n defaultValue={q}\n aria-label={`New ${noun} name`}\n placeholder={`New ${noun} name`}\n className=\"h-8 min-w-0 flex-1 rounded-kit-md border border-kit-field-border bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none focus:bg-kit-field-bg focus:ring-1 focus:ring-kit-field-border-focus\"\n />\n <Button size=\"sm\" type=\"submit\" variant=\"primary\" loading={createBusy} disabled={createBusy}>\n Create\n </Button>\n </form>\n {createError ? (\n <p role=\"alert\" className=\"mt-1.5 px-1 text-kit-xs text-kit-danger-fg\">\n {createError}\n </p>\n ) : null}\n </>\n ) : (\n <button\n type=\"button\"\n onClick={() => setCreating(true)}\n className=\"flex h-8 w-full items-center gap-2 rounded-kit-md px-2 text-left text-kit-sm text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg\"\n >\n <IconPlus className=\"size-4\" stroke={1.5} aria-hidden />\n Create new {noun}\n {q ? <span className=\"truncate text-kit-fg-3\">“{q}”</span> : null}\n </button>\n )}\n </div>\n ) : null}\n </div>\n );\n}\n\nconst noCapability = (_to: string | null): KitReferenceCreateCapability | undefined => undefined;\nconst noConnect = (_req: { path: FieldPath; to: string[] }): KitReferenceConnect | null => null;\n\n/** A8 (c): the host's answer for a field that points at no collection, else null. */\nfunction useConnect(path: FieldPath, to: string[], readOnly?: boolean): KitReferenceConnect | null {\n const { useReferenceConnect } = useKitServices();\n const c = (useReferenceConnect ?? noConnect)({ path, to });\n return readOnly ? null : c;\n}\n\n/**\n * A8 (c): in place of a search that can only say \"No matches\", the field's own fix: the project's collections, one\n * press each. The host points the field at the one chosen; the picker then lists that collection.\n */\nfunction ConnectPanel({ connect, noun }: { connect: KitReferenceConnect; noun: string }) {\n const [busy, setBusy] = React.useState<string | null>(null);\n const [error, setError] = React.useState<string | null>(null);\n const choose = async (id: string) => {\n if (busy) return;\n setBusy(id);\n setError(null);\n try {\n await connect.connect(id);\n } catch (e) {\n setError(`Not connected: ${reasonOf(e)}`);\n } finally {\n setBusy(null);\n }\n };\n return (\n <div className=\"flex flex-col\">\n <p role=\"note\" className=\"border-b border-kit-line px-3 py-2.5 text-kit-xs text-kit-fg-2\">\n {connect.reason}\n </p>\n {connect.collections.length ? (\n <div role=\"group\" aria-label={`Collections to take ${plural(noun)} from`} className=\"max-h-64 overflow-y-auto py-1\">\n {connect.collections.map((c) => (\n <button\n key={c.id}\n type=\"button\"\n disabled={!!busy}\n onClick={() => void choose(c.id)}\n className=\"flex w-full items-center gap-2 px-3 py-1.5 text-left text-kit-sm text-kit-fg hover:bg-kit-hover disabled:opacity-60\"\n >\n <IconDatabase className=\"size-4 shrink-0 text-kit-fg-3\" stroke={1.5} aria-hidden />\n <span className=\"min-w-0 flex-1 truncate\">Use {c.label}</span>\n {busy === c.id ? <span className=\"text-kit-xs text-kit-fg-3\">Connecting…</span> : null}\n </button>\n ))}\n </div>\n ) : (\n <p className=\"px-3 py-3 text-kit-xs text-kit-fg-3\">This project has no collections yet. Add one in Content, then connect it here.</p>\n )}\n {error ? (\n <p role=\"alert\" className=\"border-t border-kit-line px-3 py-2 text-kit-xs text-kit-danger-fg\">\n {error}\n </p>\n ) : null}\n </div>\n );\n}\n\n/**\n * \"Create new\" only where the host can create a draft in the ONE entry model the field targets, and, when the host\n * answers per target (useReferenceCreate), only where that model takes one. Otherwise `why`, for the empty state:\n * the target's own refusal, else the host's createDisabledReason. A capability not known yet shows neither.\n */\nfunction useCreate(to: string[]): { can: boolean; why?: string } {\n const { createReference, createDisabledReason, useReferenceCreate } = useKitServices();\n const one = to.length === 1 && isEntryTarget(to[0]) ? to[0] : null;\n const useCapability = useReferenceCreate ?? noCapability;\n const cap = useCapability(one);\n if (!one) return { can: false };\n if (useReferenceCreate) {\n if (!cap) return { can: false };\n if (!cap.ok) return { can: false, why: cap.reason };\n }\n return createReference ? { can: true } : { can: false, why: createDisabledReason };\n}\n\n/** Why the field cannot change its value here (no search service), in words. */\nfunction NoSearch({ title }: { title: string }) {\n return (\n <p role=\"note\" className=\"text-kit-xs text-kit-fg-3\">\n No reference search is connected to this editor, so {title} can't be changed here.\n </p>\n );\n}\n\n/* ── Single reference ──────────────────────────────────────────────── */\nexport function ReferenceControl({ field, value, onChange, readOnly, id, path }: ControlProps) {\n const env = useKitEnv();\n const { searchReferences } = useKitServices();\n const to = targetsOf(field);\n const connect = useConnect(path, to, readOnly);\n const noun = referenceNoun(to, field.reference?.noun);\n const current = typeof value === \"string\" && value ? value : null;\n const ids = React.useMemo(() => (current ? [current] : []), [current]);\n const rec = useReferenceRecords(ids, to);\n const createState = useCreate(to);\n const canCreate = createState.can && !readOnly;\n const [open, setOpen] = React.useState(false);\n const pick = (o: KitReferenceOption) => {\n rec.remember(o);\n onChange(o.id);\n setOpen(false);\n };\n /* the trigger opens like V2's even with no search service; the popover then says why nothing can be picked */\n const editable = !readOnly;\n const body = !editable ? null : !searchReferences ? (\n <PopoverContent className=\"w-[300px] p-3\" align=\"start\" collisionAvoidance={SHIFT}>\n <NoSearch title={field.title} />\n </PopoverContent>\n ) : connect ? (\n <PopoverContent className=\"w-[300px] p-0\" align=\"start\" collisionAvoidance={SHIFT}>\n <ConnectPanel connect={connect} noun={noun} />\n </PopoverContent>\n ) : (\n <PopoverContent className=\"w-[300px] p-0\" align=\"start\" collisionAvoidance={SHIFT}>\n <PickerBody\n to={to}\n filter={refFilterText(field.reference?.filter)}\n excludeId={field.reference?.excludeId}\n selected={current ? [current] : []}\n noun={noun}\n onPick={pick}\n onNone={\n current\n ? () => {\n onChange(null);\n setOpen(false);\n }\n : undefined\n }\n canCreate={canCreate}\n noCreateWhy={createState.why}\n onCreated={pick}\n />\n </PopoverContent>\n );\n\n const missing = !!current && rec.missing.has(current);\n if (current && !missing) {\n const o = rec.known[current];\n const title = o?.title ?? (rec.loading ? \"Loading…\" : current);\n const subtitle = o ? o.subtitle : rec.error ?? (!rec.canLookup ? `Saved ${noun} id` : null);\n const openable = !!o && o.kind === \"entry\" && !!o.modelSlug && !!env.onOpenReference;\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <div data-slot=\"kit-reference-card\" className=\"group/ref flex items-center gap-2.5 rounded-kit-lg border border-kit-line bg-kit-control-bg p-1.5 pr-1 transition-colors hover:border-kit-line-strong\">\n <PopoverTrigger\n id={id}\n disabled={!editable}\n aria-label={`${field.title}: ${title}.${editable ? \" Change\" : \"\"}`}\n className=\"flex min-w-0 flex-1 items-center gap-2.5 text-left\"\n >\n <RefThumb o={o ?? null} size={32} />\n <span className=\"min-w-0 flex-1\">\n <span className={cn(\"block truncate text-kit-sm font-medium text-kit-fg\", !o && !rec.canLookup && \"font-kit-mono text-kit-xs\")}>{title}</span>\n {subtitle ? <span className={cn(\"block truncate text-kit-xs\", rec.error && !o ? \"text-kit-danger-fg\" : \"text-kit-fg-3\")}>{subtitle}</span> : null}\n </span>\n <DraftChip status={o?.status} missingRequired={o?.missingRequired} />\n </PopoverTrigger>\n {readOnly ? null : (\n <Menu>\n <MenuTrigger\n aria-label={`${o?.title ?? field.title} actions`}\n className=\"flex size-7 shrink-0 items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg data-[popup-open]:bg-kit-hover\"\n >\n <IconDots className=\"size-4\" stroke={1.5} aria-hidden />\n </MenuTrigger>\n <MenuContent align=\"end\" className=\"w-48\">\n {openable ? (\n <MenuItem icon={<IconArrowUpRight stroke={1.5} />} onClick={() => env.onOpenReference!({ collectionId: o!.modelSlug!, entryId: o!.id, title: o!.title })}>\n Open {o!.title.length > 18 ? `${o!.title.slice(0, 16)}…` : o!.title}\n </MenuItem>\n ) : null}\n {editable ? (\n <MenuItem icon={<IconReplace stroke={1.5} />} onClick={() => window.setTimeout(() => setOpen(true), 0)}>\n Replace\n </MenuItem>\n ) : null}\n {openable || editable ? <MenuSeparator /> : null}\n <MenuItem danger icon={<IconTrash stroke={1.5} />} onClick={() => onChange(null)}>\n Remove\n </MenuItem>\n </MenuContent>\n </Menu>\n )}\n </div>\n {body}\n </Popover>\n );\n }\n /* empty, or a saved id the lookup cannot find: V2's select trigger (V2 draws an unresolved id as no selection). Ours\n says \"Missing\" on it instead of hiding the saved id (DESIGN 9.6); the picker's None clears it, a row replaces it. */\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger\n id={id}\n disabled={!editable}\n data-slot={missing ? \"kit-reference-card\" : undefined}\n data-missing={missing || undefined}\n aria-label={missing ? `${field.title}: Missing ${noun}.${editable ? \" Change\" : \"\"}` : `${field.title}: select ${withArticle(noun)}`}\n className={cn(\n \"flex h-8 w-full items-center gap-2 rounded-kit-md border border-kit-field-border bg-kit-field-bg px-2.5 text-left text-kit-sm text-kit-fg-3 transition-colors hover:border-kit-field-border-hover data-[popup-open]:border-kit-field-border-focus data-[popup-open]:bg-kit-field-bg\",\n missing && \"border-kit-warning-line text-kit-warning-fg hover:border-kit-warning-line data-[popup-open]:border-kit-warning-line\",\n )}\n >\n <IconFileDatabase className=\"size-4\" stroke={1.5} aria-hidden />\n {missing ? (\n <span className=\"flex-1 truncate\">\n Missing {noun}\n <span className=\"sr-only\">. Deleted, or not visible to you. The saved id stays until you replace or remove it.</span>\n </span>\n ) : (\n <span className=\"flex-1 truncate\">Select {withArticle(noun)}</span>\n )}\n <IconChevronDown className=\"size-3.5\" stroke={1.5} aria-hidden />\n </PopoverTrigger>\n {body}\n </Popover>\n );\n}\n\n/* ── Multi-reference: an array of ids ─────────────────────────────── */\nfunction RefChip({\n id,\n o,\n canLookup,\n readOnly,\n sort,\n onRemove,\n}: {\n id: string;\n o?: KitReferenceOption;\n /** false: no lookup service, so the saved id is all there is to show (never a \"Loading…\" that never ends) */\n canLookup: boolean;\n readOnly?: boolean;\n sort: ReturnType<typeof useDragReorder>;\n onRemove: () => void;\n}) {\n const handle = sort.handle(id);\n const register = sort.register(id);\n const title = o?.title ?? (canLookup ? \"Loading…\" : id);\n /* V2: the chip itself is the sortable item (thumb, title and remove button inside it) */\n return (\n <span\n {...(readOnly ? {} : handle)}\n ref={(el: HTMLElement | null) => {\n register(el);\n if (!readOnly) handle.ref(el);\n }}\n style={sort.style(id)}\n tabIndex={0}\n role=\"group\"\n aria-roledescription=\"sortable item\"\n aria-label={readOnly ? title : `${title}, drag to reorder`}\n onKeyDown={(e) => {\n // keys on the remove button are the button's own\n if (readOnly || e.target !== e.currentTarget) return;\n if (e.key === \"Delete\" || e.key === \"Backspace\") {\n e.preventDefault();\n onRemove();\n return;\n }\n handle.onKeyDown(e);\n }}\n className={cn(\n \"inline-flex h-6 max-w-full cursor-grab touch-none items-center gap-1.5 rounded-kit-md border border-kit-line bg-kit-control-bg pl-0.5 pr-1 text-kit-sm text-kit-fg shadow-kit-xs active:cursor-grabbing\",\n sort.active === id && \"z-10 shadow-kit-md\",\n )}\n >\n <RefThumb o={o ?? null} size={20} />\n <span className=\"truncate\">{title}</span>\n {/* a picker-made draft says what is left to fill, as the single card does; other chips stay V2's */}\n {o?.missingRequired ? <DraftChip status={o.status} missingRequired={o.missingRequired} /> : null}\n {readOnly ? null : (\n <button type=\"button\" aria-label={`Remove ${title}`} onPointerDown={(e) => e.stopPropagation()} onClick={onRemove} className=\"flex rounded-kit-md p-0.5 text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\">\n <IconX className=\"size-3\" stroke={1.5} aria-hidden />\n </button>\n )}\n </span>\n );\n}\n\n/** Multi-reference: an array of reference ids. `field` is the ARRAY field; the engine hands it the item's `reference`. */\nexport function ReferencesControl({ field, value, onChange, readOnly, id, path }: ControlProps) {\n const { searchReferences } = useKitServices();\n const item = Array.isArray(field.of) ? field.of[0] : undefined;\n const to = item?.reference?.to ?? field.reference?.to ?? [];\n const connect = useConnect(path, to, readOnly);\n const filter = refFilterText(item?.reference?.filter ?? field.reference?.filter);\n const noun = referenceNoun(to, item?.reference?.noun ?? field.reference?.noun);\n const ids = React.useMemo(() => (Array.isArray(value) ? value : []).filter((x): x is string => typeof x === \"string\" && x !== \"\"), [value]);\n const rec = useReferenceRecords(ids, to);\n const createState = useCreate(to);\n const canCreate = createState.can && !readOnly;\n const max = field.validation?.max;\n /* ids the lookup cannot find are drawn as ONE compact \"n missing\" chip after Add (V2 hides them; one row keeps V2's height),\n so the chips that sort are the rest; a reorder puts them back around the missing ids, which keep their places */\n const missingIds = ids.filter((x) => rec.missing.has(x));\n const shown = missingIds.length ? ids.filter((x) => !rec.missing.has(x)) : ids;\n const sort = useDragReorder(\n shown,\n (from, to2) => {\n const next = [...shown];\n const [moved] = next.splice(from, 1);\n next.splice(to2, 0, moved);\n let i = 0;\n onChange(ids.map((x) => (rec.missing.has(x) ? x : next[i++])));\n },\n { axis: \"grid\", disabled: readOnly },\n );\n const missingNoun = missingIds.length === 1 ? noun : plural(noun);\n const toggle = (o: KitReferenceOption) => {\n rec.remember(o);\n if (ids.includes(o.id)) return onChange(ids.filter((x) => x !== o.id));\n if (max != null && ids.length >= max) return onChange([...ids.slice(0, -1), o.id]); // swap in place at the limit\n onChange([...ids, o.id]);\n };\n return (\n <div className=\"flex flex-col gap-1\">\n {/* the field label points at the Add trigger; read-only there is none, so the box carries the id. The chips sit\n straight in the wrapping box, as V2's do (a wrapper would take them out of the box's flow). V2's box has no\n role or name while editing; read-only (no Add to label) it is named as a group. */}\n <div\n id={readOnly ? id : undefined}\n role={readOnly ? \"group\" : undefined}\n aria-label={readOnly ? field.title : undefined}\n className=\"flex min-h-8 flex-wrap items-center gap-1 rounded-kit-md border border-kit-field-border bg-kit-field-bg p-1 transition-colors hover:border-kit-field-border-hover\"\n >\n {shown.map((x) => (\n <RefChip key={x} id={x} o={rec.known[x]} canLookup={rec.canLookup} readOnly={readOnly} sort={sort} onRemove={() => onChange(ids.filter((y) => y !== x))} />\n ))}\n {sort.a11y}\n {!readOnly ? (\n <Popover>\n <PopoverTrigger id={id} className=\"inline-flex h-6 items-center gap-1 rounded-kit-md px-1.5 text-kit-sm text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\">\n <IconPlus className=\"size-3.5\" stroke={1.5} aria-hidden />\n Add\n </PopoverTrigger>\n <PopoverContent className=\"w-[300px] p-0\" align=\"start\" collisionAvoidance={SHIFT}>\n {/* no search service: the picker says why instead of listing anything */}\n {!searchReferences ? (\n <div className=\"p-3\">\n <NoSearch title={field.title} />\n </div>\n ) : connect ? (\n <ConnectPanel connect={connect} noun={noun} />\n ) : (\n <PickerBody\n to={to}\n filter={filter}\n excludeId={item?.reference?.excludeId ?? field.reference?.excludeId}\n selected={ids}\n multi\n max={max}\n noun={noun}\n onPick={toggle}\n canCreate={canCreate}\n noCreateWhy={createState.why}\n onCreated={(o) => {\n rec.remember(o);\n onChange(max != null && ids.length >= max ? [...ids.slice(0, -1), o.id] : [...ids, o.id]);\n }}\n />\n )}\n </PopoverContent>\n </Popover>\n ) : ids.length === 0 ? (\n <span className=\"px-1.5 text-kit-sm text-kit-fg-3\">None</span>\n ) : null}\n {/* after Add, so Add keeps V2's place (V2 draws nothing for these ids) */}\n {missingIds.length ? (\n <span\n data-missing\n data-slot=\"kit-reference-missing\"\n className=\"inline-flex h-6 max-w-full items-center gap-1 rounded-kit-md border border-kit-warning-line bg-kit-control-bg pl-1.5 pr-1 text-kit-sm text-kit-warning-fg shadow-kit-xs\"\n >\n <span className=\"truncate tabular-nums\">\n {missingIds.length} missing\n <span className=\"sr-only\">\n {\" \"}\n {missingNoun}. Deleted, or not visible to you. The saved {missingIds.length === 1 ? \"id stays\" : \"ids stay\"} until you remove {missingIds.length === 1 ? \"it\" : \"them\"}.\n </span>\n </span>\n {readOnly ? null : (\n <button\n type=\"button\"\n aria-label={`Remove ${missingIds.length} missing ${missingNoun}`}\n onClick={() => onChange(ids.filter((y) => !rec.missing.has(y)))}\n className=\"flex rounded-kit-sm p-0.5 hover:bg-kit-hover hover:text-kit-fg\"\n >\n <IconX className=\"size-3\" stroke={1.5} aria-hidden />\n </button>\n )}\n </span>\n ) : null}\n </div>\n {rec.error ? (\n <p role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">\n {rec.error}\n </p>\n ) : null}\n {max != null ? (\n <span className=\"tabular-nums self-end text-kit-xs text-kit-fg-3\">\n {ids.length} / {max}\n </span>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAM,4BAAY,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAc;AAAS,CAAC;AACnE,IAAM,iBAAiB,MAAc,CAAC,UAAU,IAAI,CAAC;AACrD,IAAM,aAAa,UAAiC,MAAM,WAAW,MAAM,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IAAI,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC;OAC1F;MACD,CAAA;KAEa,CAAA,CACT,EAAA,CAAA,IACP,IAAI,WAAW,IACjB,oBAAC,QAAD;MAAM,WAAU;MAAmC,UAAA;KAAU,CAAA,IAC3D;KAEH,WAAW,SACV,qBAAC,QAAD;MACE,gBAAA;MACA,aAAU;MACV,WAAU;MAHZ,UAAA,CAKE,qBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA;QACG,WAAW;QAAO;QACnB,qBAAC,QAAD;SAAM,WAAU;SAAhB,UAAA;UACG;UACA;UAAY;UAA6C,WAAW,WAAW,IAAI,aAAa;UAAW;UAAmB,WAAW,WAAW,IAAI,OAAO;UAAO;SACnK;;OACF;MACL,CAAA,GAAA,WAAW,OACV,oBAAC,UAAD;OACE,MAAK;OACL,cAAY,UAAU,WAAW,OAAO,WAAW;OACnD,eAAe,SAAS,IAAI,QAAQ,MAAM,CAAC,IAAI,QAAQ,IAAI,CAAC,CAAC,CAAC;OAC9D,WAAU;OAEV,UAAA,oBAAC,OAAD;QAAO,WAAU;QAAS,QAAQ;QAAK,eAAA;OAAa,CAAA;MAC9C,CAAA,CAEN;KACJ,CAAA,IAAA;IACD;;GACJ,IAAI,QACH,oBAAC,KAAD;IAAG,MAAK;IAAQ,WAAU;IACvB,UAAA,IAAI;GACJ,CAAA,IACD;GACH,OAAO,OACN,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA;KACG,IAAI;KAAO;KAAI;IACZ;GACJ,CAAA,IAAA;EACD;;AAET"}
1
+ {"version":3,"file":"reference.js","names":[],"sources":["../../src/controls/reference.tsx"],"sourcesContent":["/**\n * REFERENCE — single: a select-like trigger (\"Select a CMS item\") → a 300px search popover with \"None\", result rows,\n * drafts labelled, and \"Create new\" inline when the host can create. Never lists the document being edited. No one-click\n * clear (⋯ → Remove). MULTI-REFERENCE — reorderable chips + \"+ Add\", \"n / max\"; at the limit the picker swaps in place.\n * (V2 HEAD 9829bf1 kit/controls/reference.tsx, DESIGN.md 6.8, 8.16, 9.6.)\n *\n * The rows come from the host (reference-services.ts): `searchReferences` is POST /content/reference-options, which\n * already applies the field's `reference.filter` and scope; `truncated` says its filter scan stopped early, and the\n * picker says so. The stored value is the target id (\"en_12\"; a list for many), exactly V2's shape.\n *\n * Kit deviations from V2: no seed rows (every row is a real record from the service); matching is the server's title /\n * slug search, so rows keep the server's order; a stored id the lookup cannot find shows as a \"Missing\" card, or in a\n * multi list one compact \"n missing\" chip with Remove (DESIGN 9.6's production rule), instead of disappearing; chips sort with the engine's `useDragReorder`\n * (@dnd-kit is not on the kit allow-list).\n */\nimport * as React from \"react\";\nimport { IconArrowUpRight, IconCheck, IconChevronDown, IconDatabase, IconDots, IconFileDatabase, IconFileText, IconForms, IconPlus, IconReplace, IconSearch, IconShoppingBag, IconTrash, IconX } from \"@tabler/icons-react\";\nimport type { KitReferenceConnect, KitReferenceCreateCapability, KitReferenceKind, KitReferenceOption } from \"./reference-services\";\nimport { Button } from \"../ui/button\";\nimport { Avatar } from \"../ui/display\";\nimport { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Popover, PopoverContent, PopoverTrigger } from \"../ui/overlay\";\nimport { cn } from \"../lib/cn\";\nimport { refFilterText } from \"../lib/schema\";\nimport { useDragReorder } from \"../engine/item-list\";\nimport { useKitEnv, useKitServices } from \"../context\";\nimport type { ControlProps } from \"../types\";\nimport type { FieldPath } from \"../schema/types\";\n\nconst NON_ENTRY = new Set([\"page\", \"form\", \"collection\", \"shopify\"]);\nconst isEntryTarget = (t: string) => !NON_ENTRY.has(t);\nconst targetsOf = (field: ControlProps[\"field\"]) => field.reference?.to ?? [];\n\n/** The noun the picker uses: the field's own (`reference.noun`), else D48's (\"CMS item\" where V2 says \"entry\"). */\nexport function referenceNoun(to: string[], noun?: string): string {\n if (noun) return noun;\n if (to.length === 1) return to[0] === \"page\" ? \"page\" : to[0] === \"form\" ? \"form\" : to[0] === \"collection\" ? \"collection\" : to[0] === \"shopify\" ? \"product\" : \"CMS item\";\n return to.length && to.every(isEntryTarget) ? \"CMS item\" : \"item\";\n}\nconst plural = (noun: string) => (noun === \"CMS item\" ? \"CMS items\" : `${noun}s`);\nconst withArticle = (noun: string) => `${/^[aeiou]/i.test(noun) ? \"an\" : \"a\"} ${noun}`;\nconst reasonOf = (e: unknown) => (e instanceof Error ? e.message : String(e));\nconst PAGE = 25;\n/** V2 (Radix) slides a picker that would overflow along the edge, keeping it over the panel; Base UI would flip it to\n * end-aligned, which hangs it left over the preview */\nconst SHIFT = { align: \"shift\" } as const;\n\nconst KIND_ICON: Record<KitReferenceKind, React.ComponentType<{ className?: string; stroke?: number }>> = {\n entry: IconFileDatabase,\n page: IconFileText,\n form: IconForms,\n collection: IconDatabase,\n shopify: IconShoppingBag,\n};\n\nexport function RefThumb({ o, size = 28 }: { o: Pick<KitReferenceOption, \"kind\" | \"title\" | \"photo\" | \"avatar\" | \"cover\"> | null; size?: number }) {\n // V2 reference.tsx:152-156: a person is their round avatar (initials without a photo), a record with a cover its image\n if (o?.avatar || o?.photo) return <Avatar name={o.title} src={o.photo ?? undefined} size={size} decorative />;\n if (o?.cover) return <img src={o.cover} alt=\"\" style={{ width: size, height: size }} className=\"shrink-0 rounded-kit-md border border-kit-line object-cover\" />;\n const Icon = o ? KIND_ICON[o.kind] : IconFileDatabase;\n return (\n <span aria-hidden style={{ width: size, height: size }} className=\"flex shrink-0 items-center justify-center rounded-kit-md border border-kit-line bg-kit-subtle text-kit-fg-3\">\n <Icon className={size > 24 ? \"size-4\" : \"size-3.5\"} stroke={1.5} />\n </span>\n );\n}\n\nfunction DraftChip({ status, missingRequired }: { status?: string | null; missingRequired?: number }) {\n if (status !== \"draft\") return null;\n const n = missingRequired ?? 0;\n return (\n <span className=\"shrink-0 rounded-kit-md bg-kit-muted px-1 text-kit-2xs text-kit-fg-3\">\n Draft{n > 0 ? ` · ${n} required field${n === 1 ? \"\" : \"s\"} empty` : \"\"}\n </span>\n );\n}\n\n/* ── Lookup: stored ids → their records ────────────────────────────── */\n/**\n * The records behind `ids`, read once per id through `lookupReferences`. An id the service does not hand back is\n * `missing`; a failed read is `error` (in words). A row picked in the picker is `remember`ed, so it shows at once.\n */\nexport function useReferenceRecords(ids: string[], to: string[]) {\n const { lookupReferences } = useKitServices();\n const [known, setKnown] = React.useState<Record<string, KitReferenceOption>>({});\n const [missing, setMissing] = React.useState<ReadonlySet<string>>(new Set());\n const [error, setError] = React.useState<string | null>(null);\n const inflight = React.useRef(new Set<string>());\n const alive = React.useRef(true);\n // set on every mount: StrictMode mounts, unmounts and mounts again, and a flag only cleared would drop every read\n React.useEffect(() => {\n alive.current = true;\n return () => {\n alive.current = false;\n };\n }, []);\n const idsKey = ids.join(\"|\");\n const toKey = to.join(\"|\");\n React.useEffect(() => {\n if (!lookupReferences) return;\n const asked = ids.filter((x) => !known[x] && !missing.has(x) && !inflight.current.has(x));\n if (!asked.length) return;\n for (const x of asked) inflight.current.add(x);\n lookupReferences(asked, to)\n .then((rows) => {\n if (!alive.current) return;\n const found = new Set(rows.map((r) => r.id));\n setKnown((k) => ({ ...k, ...Object.fromEntries(rows.map((r) => [r.id, r])) }));\n setMissing((m) => new Set([...m, ...asked.filter((x) => !found.has(x))]));\n setError(null);\n })\n .catch((e: unknown) => alive.current && setError(`The saved ${plural(referenceNoun(to))} could not be read: ${reasonOf(e)}`))\n .finally(() => {\n for (const x of asked) inflight.current.delete(x);\n });\n }, [idsKey, toKey, lookupReferences, known, missing]); // eslint-disable-line react-hooks/exhaustive-deps\n const remember = React.useCallback((o: KitReferenceOption) => {\n setKnown((k) => ({ ...k, [o.id]: o }));\n setMissing((m) => (m.has(o.id) ? new Set([...m].filter((x) => x !== o.id)) : m));\n }, []);\n return { known, missing, loading: !!lookupReferences && ids.some((x) => !known[x] && !missing.has(x)) && !error, error, remember, canLookup: !!lookupReferences };\n}\n\n/* ── The search popover body, shared by single and multi ───────────── */\nfunction PickerBody({\n to,\n filter,\n selected,\n multi,\n max,\n noun,\n onPick,\n onNone,\n canCreate,\n noCreateWhy,\n onCreated,\n excludeId,\n}: {\n to: string[];\n filter?: string;\n /** a record never listed besides the document being edited (the field's `reference.excludeId`) */\n excludeId?: string;\n selected: string[];\n multi?: boolean;\n max?: number;\n noun: string;\n onPick: (o: KitReferenceOption) => void;\n onNone?: () => void;\n canCreate: boolean;\n /** why \"Create new\" isn't offered here, for the empty state (useCreate) */\n noCreateWhy?: string;\n onCreated: (o: KitReferenceOption) => void;\n}) {\n const { searchReferences, createReference, toast } = useKitServices();\n const env = useKitEnv();\n const [q, setQ] = React.useState(\"\");\n const [query, setQuery] = React.useState(\"\");\n const [rows, setRows] = React.useState<KitReferenceOption[]>([]);\n const [truncated, setTruncated] = React.useState(false);\n const [loading, setLoading] = React.useState(true);\n const [error, setError] = React.useState<string | null>(null);\n const [active, setActive] = React.useState(0);\n const [creating, setCreating] = React.useState(false);\n const [createBusy, setCreateBusy] = React.useState(false);\n const [createError, setCreateError] = React.useState<string | null>(null);\n const listId = React.useId();\n\n React.useEffect(() => {\n const t = window.setTimeout(() => setQuery(q.trim()), q.trim() ? 180 : 0);\n return () => window.clearTimeout(t);\n }, [q]);\n const toKey = to.join(\"|\");\n React.useEffect(() => {\n if (!searchReferences) return;\n const ctrl = new AbortController();\n setLoading(true);\n searchReferences({ to, filter, q: query, limit: PAGE, excludeId: excludeId ?? env.docId, signal: ctrl.signal })\n .then((r) => {\n if (ctrl.signal.aborted) return;\n setRows(r.options.filter((o) => o.id !== env.docId && o.id !== excludeId));\n setTruncated(r.truncated);\n setError(null);\n setActive(0);\n })\n .catch((e: unknown) => !ctrl.signal.aborted && setError(reasonOf(e)))\n .finally(() => !ctrl.signal.aborted && setLoading(false));\n return () => ctrl.abort();\n }, [query, toKey, filter, env.docId, excludeId, searchReferences]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const none = onNone && !q;\n const total = rows.length + (none ? 1 : 0);\n const at = (i: number) => (none ? (i === 0 ? null : rows[i - 1]) : rows[i]);\n const full = multi && max != null && selected.length >= max;\n const choose = (i: number) => {\n const o = at(i);\n if (o) onPick(o);\n else if (none) onNone!();\n };\n const optionId = (i: number) => `${listId}-${i}`;\n // one create at a time: a second Enter or click while the first is out is the same request, not another draft\n const createOut = React.useRef(false);\n const create = async (title: string) => {\n if (!createReference || createOut.current) return;\n createOut.current = true;\n setCreateBusy(true);\n setCreateError(null);\n try {\n const o = await createReference({ to: to[0], title });\n setCreating(false);\n onCreated(o);\n const open =\n o.kind === \"entry\" && o.modelSlug && env.onOpenReference\n ? { label: \"Open\", onClick: () => env.onOpenReference!({ collectionId: o.modelSlug!, entryId: o.id, title: o.title }) }\n : undefined;\n toast?.success(o.created === false ? `Using existing ‘${o.title}’` : `Created ‘${o.title}’ as a draft`, open ? { action: open } : undefined);\n } catch (e) {\n setCreateError(`Not created: ${reasonOf(e)}`);\n } finally {\n createOut.current = false;\n setCreateBusy(false);\n }\n };\n // V2's search copy: \"pages\" for a page picker, \"entries\" for every other one\n const searchLabel = `Search ${noun === \"page\" ? \"pages\" : \"entries\"}`;\n return (\n <div className=\"flex flex-col\">\n <label className=\"flex h-10 items-center gap-2 border-b border-kit-line px-3 text-kit-fg-3\">\n <IconSearch className=\"size-4 shrink-0\" stroke={1.5} aria-hidden />\n <input\n autoFocus\n value={q}\n onChange={(e) => {\n setQ(e.target.value);\n setActive(0);\n }}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setActive((a) => Math.min(total - 1, a + 1));\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setActive((a) => Math.max(0, a - 1));\n } else if (e.key === \"Home\") {\n e.preventDefault();\n setActive(0);\n } else if (e.key === \"End\") {\n e.preventDefault();\n setActive(Math.max(0, total - 1));\n } else if (e.key === \"Enter\" && total) {\n e.preventDefault();\n choose(Math.min(active, total - 1));\n }\n }}\n placeholder={`${searchLabel}…`}\n role=\"combobox\"\n aria-expanded\n aria-autocomplete=\"list\"\n aria-controls={listId}\n aria-activedescendant={total ? optionId(Math.min(active, total - 1)) : undefined}\n aria-label={searchLabel}\n className=\"h-full min-w-0 flex-1 bg-transparent text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3\"\n />\n </label>\n <div id={listId} className=\"max-h-72 overflow-y-auto p-1\" role=\"listbox\" aria-label={`${noun} results`} aria-multiselectable={multi || undefined} aria-busy={loading || undefined}>\n {none ? (\n <button\n type=\"button\"\n id={optionId(0)}\n role=\"option\"\n aria-selected={false}\n tabIndex={-1}\n onMouseEnter={() => setActive(0)}\n onMouseDown={(e) => e.preventDefault()}\n onClick={onNone}\n className={cn(\"flex h-8 w-full items-center gap-2 rounded-kit-md px-2 text-left text-kit-sm text-kit-fg-3 hover:bg-kit-hover\", active === 0 && \"bg-kit-hover\")}\n >\n None\n </button>\n ) : null}\n {rows.map((o, j) => {\n const i = j + (none ? 1 : 0);\n const on = selected.includes(o.id);\n return (\n <button\n type=\"button\"\n key={`${o.kind}:${o.id}`}\n id={optionId(i)}\n role=\"option\"\n aria-selected={on}\n tabIndex={-1}\n onMouseEnter={() => setActive(i)}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => onPick(o)}\n className={cn(\"flex w-full items-center gap-2.5 rounded-kit-md p-1.5 text-left\", i === active && \"bg-kit-hover\")}\n >\n {multi ? (\n <span aria-hidden className={cn(\"flex size-4 shrink-0 items-center justify-center rounded-kit-md border\", on ? \"border-kit-accent bg-kit-accent text-kit-accent-on\" : \"border-kit-line-strong\", !on && full && \"opacity-40\")}>\n {on ? <IconCheck className=\"size-3\" stroke={3} /> : null}\n </span>\n ) : null}\n <RefThumb o={o} size={28} />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-kit-sm text-kit-fg\">{o.title}</span>\n {o.subtitle ? <span className=\"block truncate text-kit-xs text-kit-fg-3\">{o.subtitle}</span> : null}\n </span>\n <DraftChip status={o.status} missingRequired={o.missingRequired} />\n {!multi && on ? <IconCheck className=\"size-4 shrink-0 text-kit-fg\" stroke={2} aria-hidden /> : null}\n </button>\n );\n })}\n {!loading && !error && rows.length === 0 ? (\n <div className=\"px-3 py-6 text-center text-kit-sm text-kit-fg-3\">\n No matches\n {noCreateWhy ? (\n <p role=\"note\" className=\"mt-1 text-kit-xs\">\n {noCreateWhy}\n </p>\n ) : null}\n </div>\n ) : null}\n {loading && rows.length === 0 ? (\n <div role=\"status\" className=\"px-3 py-6 text-center text-kit-sm text-kit-fg-3\">\n Searching…\n </div>\n ) : null}\n {error ? (\n <p role=\"alert\" className=\"px-3 py-3 text-kit-xs text-kit-danger-fg\">\n {plural(noun).replace(/^./, (c) => c.toUpperCase())} could not be listed: {error}\n </p>\n ) : null}\n </div>\n {truncated && !error ? (\n <p role=\"note\" className=\"border-t border-kit-line px-3 py-2 text-kit-xs text-kit-warning-fg\">\n Some {plural(noun)} were not checked against this field's filter, so the list may be incomplete. Search by name to narrow it.\n </p>\n ) : null}\n {multi ? (\n <div className={cn(\"border-t border-kit-line px-3 py-2 text-kit-xs\", full ? \"text-kit-warning-fg\" : \"text-kit-fg-3\")}>\n {selected.length}\n {max != null ? ` of ${max}` : \"\"} selected{full ? ` · Limit is ${max}. Picking another swaps out the last one.` : \"\"}\n </div>\n ) : null}\n {canCreate ? (\n <div className=\"border-t border-kit-line p-1.5\">\n {creating ? (\n <>\n <form\n className=\"flex items-center gap-1.5\"\n onSubmit={(e) => {\n e.preventDefault();\n e.stopPropagation();\n const t = String(new FormData(e.currentTarget).get(\"t\") ?? \"\").trim();\n if (t) void create(t);\n }}\n >\n <input\n name=\"t\"\n autoFocus\n defaultValue={q}\n aria-label={`New ${noun} name`}\n placeholder={`New ${noun} name`}\n className=\"h-8 min-w-0 flex-1 rounded-kit-md border border-kit-line-strong bg-kit-field-bg px-2 text-kit-sm text-kit-fg outline-none focus:bg-kit-field-bg focus:ring-1 focus:ring-kit-line-strong\"\n />\n <Button size=\"sm\" type=\"submit\" variant=\"primary\" loading={createBusy} disabled={createBusy}>\n Create\n </Button>\n </form>\n {createError ? (\n <p role=\"alert\" className=\"mt-1.5 px-1 text-kit-xs text-kit-danger-fg\">\n {createError}\n </p>\n ) : null}\n </>\n ) : (\n <button\n type=\"button\"\n onClick={() => setCreating(true)}\n className=\"flex h-8 w-full items-center gap-2 rounded-kit-md px-2 text-left text-kit-sm text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg\"\n >\n <IconPlus className=\"size-4\" stroke={1.5} aria-hidden />\n Create new {noun}\n {q ? <span className=\"truncate text-kit-fg-3\">“{q}”</span> : null}\n </button>\n )}\n </div>\n ) : null}\n </div>\n );\n}\n\nconst noCapability = (_to: string | null): KitReferenceCreateCapability | undefined => undefined;\nconst noConnect = (_req: { path: FieldPath; to: string[] }): KitReferenceConnect | null => null;\n\n/** A8 (c): the host's answer for a field that points at no collection, else null. */\nfunction useConnect(path: FieldPath, to: string[], readOnly?: boolean): KitReferenceConnect | null {\n const { useReferenceConnect } = useKitServices();\n const c = (useReferenceConnect ?? noConnect)({ path, to });\n return readOnly ? null : c;\n}\n\n/**\n * A8 (c): in place of a search that can only say \"No matches\", the field's own fix: the project's collections, one\n * press each. The host points the field at the one chosen; the picker then lists that collection.\n */\nfunction ConnectPanel({ connect, noun }: { connect: KitReferenceConnect; noun: string }) {\n const [busy, setBusy] = React.useState<string | null>(null);\n const [error, setError] = React.useState<string | null>(null);\n const choose = async (id: string) => {\n if (busy) return;\n setBusy(id);\n setError(null);\n try {\n await connect.connect(id);\n } catch (e) {\n setError(`Not connected: ${reasonOf(e)}`);\n } finally {\n setBusy(null);\n }\n };\n return (\n <div className=\"flex flex-col\">\n <p role=\"note\" className=\"border-b border-kit-line px-3 py-2.5 text-kit-xs text-kit-fg-2\">\n {connect.reason}\n </p>\n {connect.collections.length ? (\n <div role=\"group\" aria-label={`Collections to take ${plural(noun)} from`} className=\"max-h-64 overflow-y-auto py-1\">\n {connect.collections.map((c) => (\n <button\n key={c.id}\n type=\"button\"\n disabled={!!busy}\n onClick={() => void choose(c.id)}\n className=\"flex w-full items-center gap-2 px-3 py-1.5 text-left text-kit-sm text-kit-fg hover:bg-kit-hover disabled:opacity-60\"\n >\n <IconDatabase className=\"size-4 shrink-0 text-kit-fg-3\" stroke={1.5} aria-hidden />\n <span className=\"min-w-0 flex-1 truncate\">Use {c.label}</span>\n {busy === c.id ? <span className=\"text-kit-xs text-kit-fg-3\">Connecting…</span> : null}\n </button>\n ))}\n </div>\n ) : (\n <p className=\"px-3 py-3 text-kit-xs text-kit-fg-3\">This project has no collections yet. Add one in Content, then connect it here.</p>\n )}\n {error ? (\n <p role=\"alert\" className=\"border-t border-kit-line px-3 py-2 text-kit-xs text-kit-danger-fg\">\n {error}\n </p>\n ) : null}\n </div>\n );\n}\n\n/**\n * \"Create new\" only where the host can create a draft in the ONE entry model the field targets, and, when the host\n * answers per target (useReferenceCreate), only where that model takes one. Otherwise `why`, for the empty state:\n * the target's own refusal, else the host's createDisabledReason. A capability not known yet shows neither.\n */\nfunction useCreate(to: string[]): { can: boolean; why?: string } {\n const { createReference, createDisabledReason, useReferenceCreate } = useKitServices();\n const one = to.length === 1 && isEntryTarget(to[0]) ? to[0] : null;\n const useCapability = useReferenceCreate ?? noCapability;\n const cap = useCapability(one);\n if (!one) return { can: false };\n if (useReferenceCreate) {\n if (!cap) return { can: false };\n if (!cap.ok) return { can: false, why: cap.reason };\n }\n return createReference ? { can: true } : { can: false, why: createDisabledReason };\n}\n\n/** Why the field cannot change its value here (no search service), in words. */\nfunction NoSearch({ title }: { title: string }) {\n return (\n <p role=\"note\" className=\"text-kit-xs text-kit-fg-3\">\n No reference search is connected to this editor, so {title} can't be changed here.\n </p>\n );\n}\n\n/* ── Single reference ──────────────────────────────────────────────── */\nexport function ReferenceControl({ field, value, onChange, readOnly, id, path }: ControlProps) {\n const env = useKitEnv();\n const { searchReferences } = useKitServices();\n const to = targetsOf(field);\n const connect = useConnect(path, to, readOnly);\n const noun = referenceNoun(to, field.reference?.noun);\n const current = typeof value === \"string\" && value ? value : null;\n const ids = React.useMemo(() => (current ? [current] : []), [current]);\n const rec = useReferenceRecords(ids, to);\n const createState = useCreate(to);\n const canCreate = createState.can && !readOnly;\n const [open, setOpen] = React.useState(false);\n const pick = (o: KitReferenceOption) => {\n rec.remember(o);\n onChange(o.id);\n setOpen(false);\n };\n /* the trigger opens like V2's even with no search service; the popover then says why nothing can be picked */\n const editable = !readOnly;\n const body = !editable ? null : !searchReferences ? (\n <PopoverContent className=\"w-[300px] p-3\" align=\"start\" collisionAvoidance={SHIFT}>\n <NoSearch title={field.title} />\n </PopoverContent>\n ) : connect ? (\n <PopoverContent className=\"w-[300px] p-0\" align=\"start\" collisionAvoidance={SHIFT}>\n <ConnectPanel connect={connect} noun={noun} />\n </PopoverContent>\n ) : (\n <PopoverContent className=\"w-[300px] p-0\" align=\"start\" collisionAvoidance={SHIFT}>\n <PickerBody\n to={to}\n filter={refFilterText(field.reference?.filter)}\n excludeId={field.reference?.excludeId}\n selected={current ? [current] : []}\n noun={noun}\n onPick={pick}\n onNone={\n current\n ? () => {\n onChange(null);\n setOpen(false);\n }\n : undefined\n }\n canCreate={canCreate}\n noCreateWhy={createState.why}\n onCreated={pick}\n />\n </PopoverContent>\n );\n\n const missing = !!current && rec.missing.has(current);\n if (current && !missing) {\n const o = rec.known[current];\n const title = o?.title ?? (rec.loading ? \"Loading…\" : current);\n const subtitle = o ? o.subtitle : rec.error ?? (!rec.canLookup ? `Saved ${noun} id` : null);\n const openable = !!o && o.kind === \"entry\" && !!o.modelSlug && !!env.onOpenReference;\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <div data-slot=\"kit-reference-card\" className=\"group/ref flex items-center gap-2.5 rounded-kit-lg border border-kit-line bg-kit-control-bg p-1.5 pr-1 transition-colors hover:border-kit-line-strong\">\n <PopoverTrigger\n id={id}\n disabled={!editable}\n aria-label={`${field.title}: ${title}.${editable ? \" Change\" : \"\"}`}\n className=\"flex min-w-0 flex-1 items-center gap-2.5 text-left\"\n >\n <RefThumb o={o ?? null} size={32} />\n <span className=\"min-w-0 flex-1\">\n <span className={cn(\"block truncate text-kit-sm font-medium text-kit-fg\", !o && !rec.canLookup && \"font-kit-mono text-kit-xs\")}>{title}</span>\n {subtitle ? <span className={cn(\"block truncate text-kit-xs\", rec.error && !o ? \"text-kit-danger-fg\" : \"text-kit-fg-3\")}>{subtitle}</span> : null}\n </span>\n <DraftChip status={o?.status} missingRequired={o?.missingRequired} />\n </PopoverTrigger>\n {readOnly ? null : (\n <Menu>\n <MenuTrigger\n aria-label={`${o?.title ?? field.title} actions`}\n className=\"flex size-7 shrink-0 items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg data-[popup-open]:bg-kit-hover\"\n >\n <IconDots className=\"size-4\" stroke={1.5} aria-hidden />\n </MenuTrigger>\n <MenuContent align=\"end\" className=\"w-48\">\n {openable ? (\n <MenuItem icon={<IconArrowUpRight stroke={1.5} />} onClick={() => env.onOpenReference!({ collectionId: o!.modelSlug!, entryId: o!.id, title: o!.title })}>\n Open {o!.title.length > 18 ? `${o!.title.slice(0, 16)}…` : o!.title}\n </MenuItem>\n ) : null}\n {editable ? (\n <MenuItem icon={<IconReplace stroke={1.5} />} onClick={() => window.setTimeout(() => setOpen(true), 0)}>\n Replace\n </MenuItem>\n ) : null}\n {openable || editable ? <MenuSeparator /> : null}\n <MenuItem danger icon={<IconTrash stroke={1.5} />} onClick={() => onChange(null)}>\n Remove\n </MenuItem>\n </MenuContent>\n </Menu>\n )}\n </div>\n {body}\n </Popover>\n );\n }\n /* empty, or a saved id the lookup cannot find: V2's select trigger (V2 draws an unresolved id as no selection). Ours\n says \"Missing\" on it instead of hiding the saved id (DESIGN 9.6); the picker's None clears it, a row replaces it. */\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger\n id={id}\n disabled={!editable}\n data-slot={missing ? \"kit-reference-card\" : undefined}\n data-missing={missing || undefined}\n aria-label={missing ? `${field.title}: Missing ${noun}.${editable ? \" Change\" : \"\"}` : `${field.title}: select ${withArticle(noun)}`}\n className={cn(\n \"flex h-8 w-full items-center gap-2 rounded-kit-md border border-kit-line-strong bg-kit-field-bg px-2.5 text-left text-kit-sm text-kit-fg-3 transition-colors hover:border-kit-line-strong data-[popup-open]:border-kit-line-strong data-[popup-open]:bg-kit-field-bg\",\n missing && \"border-kit-warning-line text-kit-warning-fg hover:border-kit-warning-line data-[popup-open]:border-kit-warning-line\",\n )}\n >\n <IconFileDatabase className=\"size-4\" stroke={1.5} aria-hidden />\n {missing ? (\n <span className=\"flex-1 truncate\">\n Missing {noun}\n <span className=\"sr-only\">. Deleted, or not visible to you. The saved id stays until you replace or remove it.</span>\n </span>\n ) : (\n <span className=\"flex-1 truncate\">Select {withArticle(noun)}</span>\n )}\n <IconChevronDown className=\"size-3.5\" stroke={1.5} aria-hidden />\n </PopoverTrigger>\n {body}\n </Popover>\n );\n}\n\n/* ── Multi-reference: an array of ids ─────────────────────────────── */\nfunction RefChip({\n id,\n o,\n canLookup,\n readOnly,\n sort,\n onRemove,\n}: {\n id: string;\n o?: KitReferenceOption;\n /** false: no lookup service, so the saved id is all there is to show (never a \"Loading…\" that never ends) */\n canLookup: boolean;\n readOnly?: boolean;\n sort: ReturnType<typeof useDragReorder>;\n onRemove: () => void;\n}) {\n const handle = sort.handle(id);\n const register = sort.register(id);\n const title = o?.title ?? (canLookup ? \"Loading…\" : id);\n /* V2: the chip itself is the sortable item (thumb, title and remove button inside it) */\n return (\n <span\n {...(readOnly ? {} : handle)}\n ref={(el: HTMLElement | null) => {\n register(el);\n if (!readOnly) handle.ref(el);\n }}\n style={sort.style(id)}\n tabIndex={0}\n role=\"group\"\n aria-roledescription=\"sortable item\"\n aria-label={readOnly ? title : `${title}, drag to reorder`}\n onKeyDown={(e) => {\n // keys on the remove button are the button's own\n if (readOnly || e.target !== e.currentTarget) return;\n if (e.key === \"Delete\" || e.key === \"Backspace\") {\n e.preventDefault();\n onRemove();\n return;\n }\n handle.onKeyDown(e);\n }}\n className={cn(\n \"inline-flex h-6 max-w-full cursor-grab touch-none items-center gap-1.5 rounded-kit-md border border-kit-line bg-kit-control-bg pl-0.5 pr-1 text-kit-sm text-kit-fg shadow-kit-xs active:cursor-grabbing\",\n sort.active === id && \"z-10 shadow-kit-md\",\n )}\n >\n <RefThumb o={o ?? null} size={20} />\n <span className=\"truncate\">{title}</span>\n {/* a picker-made draft says what is left to fill, as the single card does; other chips stay V2's */}\n {o?.missingRequired ? <DraftChip status={o.status} missingRequired={o.missingRequired} /> : null}\n {readOnly ? null : (\n <button type=\"button\" aria-label={`Remove ${title}`} onPointerDown={(e) => e.stopPropagation()} onClick={onRemove} className=\"flex rounded-kit-md p-0.5 text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\">\n <IconX className=\"size-3\" stroke={1.5} aria-hidden />\n </button>\n )}\n </span>\n );\n}\n\n/** Multi-reference: an array of reference ids. `field` is the ARRAY field; the engine hands it the item's `reference`. */\nexport function ReferencesControl({ field, value, onChange, readOnly, id, path }: ControlProps) {\n const { searchReferences } = useKitServices();\n const item = Array.isArray(field.of) ? field.of[0] : undefined;\n const to = item?.reference?.to ?? field.reference?.to ?? [];\n const connect = useConnect(path, to, readOnly);\n const filter = refFilterText(item?.reference?.filter ?? field.reference?.filter);\n const noun = referenceNoun(to, item?.reference?.noun ?? field.reference?.noun);\n const ids = React.useMemo(() => (Array.isArray(value) ? value : []).filter((x): x is string => typeof x === \"string\" && x !== \"\"), [value]);\n const rec = useReferenceRecords(ids, to);\n const createState = useCreate(to);\n const canCreate = createState.can && !readOnly;\n const max = field.validation?.max;\n /* ids the lookup cannot find are drawn as ONE compact \"n missing\" chip after Add (V2 hides them; one row keeps V2's height),\n so the chips that sort are the rest; a reorder puts them back around the missing ids, which keep their places */\n const missingIds = ids.filter((x) => rec.missing.has(x));\n const shown = missingIds.length ? ids.filter((x) => !rec.missing.has(x)) : ids;\n const sort = useDragReorder(\n shown,\n (from, to2) => {\n const next = [...shown];\n const [moved] = next.splice(from, 1);\n next.splice(to2, 0, moved);\n let i = 0;\n onChange(ids.map((x) => (rec.missing.has(x) ? x : next[i++])));\n },\n { axis: \"grid\", disabled: readOnly },\n );\n const missingNoun = missingIds.length === 1 ? noun : plural(noun);\n const toggle = (o: KitReferenceOption) => {\n rec.remember(o);\n if (ids.includes(o.id)) return onChange(ids.filter((x) => x !== o.id));\n if (max != null && ids.length >= max) return onChange([...ids.slice(0, -1), o.id]); // swap in place at the limit\n onChange([...ids, o.id]);\n };\n return (\n <div className=\"flex flex-col gap-1\">\n {/* the field label points at the Add trigger; read-only there is none, so the box carries the id. The chips sit\n straight in the wrapping box, as V2's do (a wrapper would take them out of the box's flow). V2's box has no\n role or name while editing; read-only (no Add to label) it is named as a group. */}\n <div\n id={readOnly ? id : undefined}\n role={readOnly ? \"group\" : undefined}\n aria-label={readOnly ? field.title : undefined}\n className=\"flex min-h-8 flex-wrap items-center gap-1 rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-1 transition-colors hover:border-kit-line-strong\"\n >\n {shown.map((x) => (\n <RefChip key={x} id={x} o={rec.known[x]} canLookup={rec.canLookup} readOnly={readOnly} sort={sort} onRemove={() => onChange(ids.filter((y) => y !== x))} />\n ))}\n {sort.a11y}\n {!readOnly ? (\n <Popover>\n <PopoverTrigger id={id} className=\"inline-flex h-6 items-center gap-1 rounded-kit-md px-1.5 text-kit-sm text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\">\n <IconPlus className=\"size-3.5\" stroke={1.5} aria-hidden />\n Add\n </PopoverTrigger>\n <PopoverContent className=\"w-[300px] p-0\" align=\"start\" collisionAvoidance={SHIFT}>\n {/* no search service: the picker says why instead of listing anything */}\n {!searchReferences ? (\n <div className=\"p-3\">\n <NoSearch title={field.title} />\n </div>\n ) : connect ? (\n <ConnectPanel connect={connect} noun={noun} />\n ) : (\n <PickerBody\n to={to}\n filter={filter}\n excludeId={item?.reference?.excludeId ?? field.reference?.excludeId}\n selected={ids}\n multi\n max={max}\n noun={noun}\n onPick={toggle}\n canCreate={canCreate}\n noCreateWhy={createState.why}\n onCreated={(o) => {\n rec.remember(o);\n onChange(max != null && ids.length >= max ? [...ids.slice(0, -1), o.id] : [...ids, o.id]);\n }}\n />\n )}\n </PopoverContent>\n </Popover>\n ) : ids.length === 0 ? (\n <span className=\"px-1.5 text-kit-sm text-kit-fg-3\">None</span>\n ) : null}\n {/* after Add, so Add keeps V2's place (V2 draws nothing for these ids) */}\n {missingIds.length ? (\n <span\n data-missing\n data-slot=\"kit-reference-missing\"\n className=\"inline-flex h-6 max-w-full items-center gap-1 rounded-kit-md border border-kit-warning-line bg-kit-control-bg pl-1.5 pr-1 text-kit-sm text-kit-warning-fg shadow-kit-xs\"\n >\n <span className=\"truncate tabular-nums\">\n {missingIds.length} missing\n <span className=\"sr-only\">\n {\" \"}\n {missingNoun}. Deleted, or not visible to you. The saved {missingIds.length === 1 ? \"id stays\" : \"ids stay\"} until you remove {missingIds.length === 1 ? \"it\" : \"them\"}.\n </span>\n </span>\n {readOnly ? null : (\n <button\n type=\"button\"\n aria-label={`Remove ${missingIds.length} missing ${missingNoun}`}\n onClick={() => onChange(ids.filter((y) => !rec.missing.has(y)))}\n className=\"flex rounded-kit-sm p-0.5 hover:bg-kit-hover hover:text-kit-fg\"\n >\n <IconX className=\"size-3\" stroke={1.5} aria-hidden />\n </button>\n )}\n </span>\n ) : null}\n </div>\n {rec.error ? (\n <p role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">\n {rec.error}\n </p>\n ) : null}\n {max != null ? (\n <span className=\"tabular-nums self-end text-kit-xs text-kit-fg-3\">\n {ids.length} / {max}\n </span>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAM,4BAAY,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAc;AAAS,CAAC;AACnE,IAAM,iBAAiB,MAAc,CAAC,UAAU,IAAI,CAAC;AACrD,IAAM,aAAa,UAAiC,MAAM,WAAW,MAAM,CAAC;;AAG5E,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AG,KAAK,EAAE,EAAE,CAAC;OAC1F;MACD,CAAA;KAEa,CAAA,CACT,EAAA,CAAA,IACP,IAAI,WAAW,IACjB,oBAAC,QAAD;MAAM,WAAU;MAAmC,UAAA;KAAU,CAAA,IAC3D;KAEH,WAAW,SACV,qBAAC,QAAD;MACE,gBAAA;MACA,aAAU;MACV,WAAU;MAHZ,UAAA,CAKE,qBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA;QACG,WAAW;QAAO;QACnB,qBAAC,QAAD;SAAM,WAAU;SAAhB,UAAA;UACG;UACA;UAAY;UAA6C,WAAW,WAAW,IAAI,aAAa;UAAW;UAAmB,WAAW,WAAW,IAAI,OAAO;UAAO;SACnK;;OACF;MACL,CAAA,GAAA,WAAW,OACV,oBAAC,UAAD;OACE,MAAK;OACL,cAAY,UAAU,WAAW,OAAO,WAAW;OACnD,eAAe,SAAS,IAAI,QAAQ,MAAM,CAAC,IAAI,QAAQ,IAAI,CAAC,CAAC,CAAC;OAC9D,WAAU;OAEV,UAAA,oBAAC,OAAD;QAAO,WAAU;QAAS,QAAQ;QAAK,eAAA;OAAa,CAAA;MAC9C,CAAA,CAEN;KACJ,CAAA,IAAA;IACD;;GACJ,IAAI,QACH,oBAAC,KAAD;IAAG,MAAK;IAAQ,WAAU;IACvB,UAAA,IAAI;GACJ,CAAA,IACD;GACH,OAAO,OACN,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA;KACG,IAAI;KAAO;KAAI;IACZ;GACJ,CAAA,IAAA;EACD;;AAET"}
@@ -6,8 +6,6 @@ export declare const RT_PANEL = "text-kit-sm leading-[1.6] [&_h1:not([data-rt-is
6
6
  export declare function countWords(html: string): number;
7
7
  /** Linked component instances in the body. */
8
8
  export declare const countComponents: (html: string) => number;
9
- /** "1,840 words · 3 components" */
10
- export declare const bodyCountLabel: (html: string) => string;
11
9
  /**
12
10
  * Where the slash menu goes, collision-aware: below the caret when the whole menu fits there, else on the side with
13
11
  * more room, and never taller than that room (its list scrolls), so the last row (More components) stays reachable in
@@ -141,12 +141,6 @@ function countWords(html) {
141
141
  }
142
142
  /** Linked component instances in the body. */
143
143
  var countComponents = (html) => (html.match(/data-rt="component"/g) ?? []).length;
144
- /** "1,840 words · 3 components" */
145
- var bodyCountLabel = (html) => {
146
- const w = countWords(html);
147
- const c = countComponents(html);
148
- return `${w.toLocaleString("en-US")} ${w === 1 ? "word" : "words"}${c ? ` · ${c} ${c === 1 ? "component" : "components"}` : ""}`;
149
- };
150
144
  function insertTextAtCaret(text) {
151
145
  if (exec("insertText", text)) return;
152
146
  const s = window.getSelection();
@@ -1281,8 +1275,8 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
1281
1275
  const btn = dense ? "size-5 [&_svg:not([data-rt-isolate]_*)]:size-3.5" : "size-[22px] [&_svg:not([data-rt-isolate]_*)]:size-3.5";
1282
1276
  const gutterMode = readOnly || dense || single ? "none" : gutterRoom ? "outside" : "inset";
1283
1277
  const showGutter = gutterMode !== "none";
1284
- /** BL-540: a one-line or panel field counts no words */
1285
- const counts = !single && !dense;
1278
+ /** BL-540: a one-line or panel field counts no words; the expanded modal shows no stamp (owner 2026-11-08, KP-134) */
1279
+ const counts = !single && !dense && !inModal;
1286
1280
  const minH = expanded ? "min-h-[60vh]" : single ? "min-h-9" : dense ? "min-h-[120px]" : "min-h-[190px]";
1287
1281
  const turnStyles = stylesFor(allows).filter((s) => [
1288
1282
  "p",
@@ -1296,7 +1290,7 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
1296
1290
  children: /* @__PURE__ */ jsxs("div", {
1297
1291
  ref: wrap,
1298
1292
  "data-rt-editor": "",
1299
- className: cn("relative [--rt-toolbar-h:2rem] pointer-coarse:[--rt-toolbar-h:2.75rem]", "rounded-kit-lg border transition-colors duration-150", expanded ? "bg-[var(--kit-surface-raised)]" : "bg-kit-surface", invalid ? "border-[var(--kit-field-invalid)]" : toolbarOpen ? "border-kit-field-border-focus" : "border-kit-field-border"),
1293
+ className: cn("relative [--rt-toolbar-h:2rem] pointer-coarse:[--rt-toolbar-h:2.75rem]", "rounded-kit-lg border transition-colors duration-150", expanded ? "bg-[var(--kit-surface-raised)]" : "bg-kit-surface", invalid ? "border-[var(--kit-field-invalid)]" : toolbarOpen ? "border-kit-line-strong" : "border-kit-line"),
1300
1294
  style: { "--rt-sticky-top": toolbarOpen && !dense ? `calc(${stickyTop}px + var(--rt-toolbar-h))` : "var(--kit-sticky-top, 0px)" },
1301
1295
  onMouseLeave: () => !blockMenu && !gutterInsert && !drag && setGutter(null),
1302
1296
  onKeyDown: onWrapKeyDown,
@@ -1848,7 +1842,6 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
1848
1842
  onOpenChange: setModalOpen,
1849
1843
  crumbs: expandCrumbs?.length ? expandCrumbs : ["Text"],
1850
1844
  returnFocus: () => ref.current,
1851
- meta: bodyCountLabel(value),
1852
1845
  children: modalOpen ? /* @__PURE__ */ jsx(RichTextEditor, {
1853
1846
  value,
1854
1847
  onChange,
@@ -1873,6 +1866,6 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
1873
1866
  });
1874
1867
  }
1875
1868
  //#endregion
1876
- export { RT_PANEL, RT_PROSE, RichTextEditor, bodyCountLabel, countComponents, countWords, slashPlacement };
1869
+ export { RT_PANEL, RT_PROSE, RichTextEditor, countComponents, countWords, slashPlacement };
1877
1870
 
1878
1871
  //# sourceMappingURL=editor.js.map