@bettercms-ai/kit 3.1.2 → 3.1.3

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.
@@ -131,6 +131,15 @@ function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }
131
131
  const [hover, setHover] = React.useState(null);
132
132
  const [draft, setDraft] = React.useState(null);
133
133
  const shown = hover ?? n ?? 0;
134
+ const group = React.useRef(null);
135
+ const tabStop = (n != null ? Math.min(stars, Math.max(1, Math.ceil(n))) : 0) || 1;
136
+ const step = (e, i) => {
137
+ const to = e.key === "ArrowRight" || e.key === "ArrowUp" ? Math.min(stars, i + 1) : e.key === "ArrowLeft" || e.key === "ArrowDown" ? Math.max(1, i - 1) : e.key === "Home" ? 1 : e.key === "End" ? stars : null;
138
+ if (to === null || readOnly) return;
139
+ e.preventDefault();
140
+ onChange(snapRating(to, scale));
141
+ group.current?.querySelectorAll("[role=\"radio\"]")[to - 1]?.focus();
142
+ };
134
143
  const commit = () => {
135
144
  if (draft !== null) {
136
145
  const t = draft.trim();
@@ -143,6 +152,7 @@ function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }
143
152
  className: "flex items-center gap-3",
144
153
  children: [
145
154
  /* @__PURE__ */ jsx("div", {
155
+ ref: group,
146
156
  role: "radiogroup",
147
157
  "aria-label": `${field.title} rating`,
148
158
  className: "flex items-center",
@@ -155,6 +165,8 @@ function RatingControl({ field, value, onChange, readOnly, id, invalid, onBlur }
155
165
  role: "radio",
156
166
  "aria-checked": n != null && Math.ceil(n) === i,
157
167
  "aria-label": `${i} star${i > 1 ? "s" : ""}`,
168
+ tabIndex: i === tabStop ? 0 : -1,
169
+ onKeyDown: (e) => step(e, i),
158
170
  disabled: readOnly,
159
171
  onMouseEnter: () => setHover(i),
160
172
  onClick: () => onChange(pick),
@@ -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-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 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 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 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: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AAU,+BAAgC,CAAA;MACtD,CAAA,CACA;KAdD,GAAA,CAcC;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"}
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,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AC;KACrD,MAAM,OAAO,WAAW,GAAG,KAAK;KAChC,OACE,qBAAC,UAAD;MAEE,MAAK;MACL,MAAK;MACL,gBAAc,KAAK,QAAQ,KAAK,KAAK,CAAC,MAAM;MAC5C,cAAY,GAAG,EAAE,OAAO,IAAI,IAAI,MAAM;MACtC,UAAU,MAAM,UAAU,IAAI;MAC9B,YAAY,MAAM,KAAK,GAAG,CAAC;MAC3B,UAAU;MACV,oBAAoB,SAAS,CAAC;MAC9B,eAAe,SAAS,IAAI;MAC5B,WAAU;MAXZ,UAAA,CAaE,oBAAC,gBAAD,EAAgB,WAAU,mCAAoC,CAAA,GAC9D,oBAAC,QAAD;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"}
@@ -430,18 +430,21 @@ var score = (q, it) => {
430
430
  if (l.includes(q)) return 2;
431
431
  return it.description.toLowerCase().includes(q) ? 1 : 0;
432
432
  };
433
- /** Ranked by recently used among the strong matches, then by match, then catalogue order. */
433
+ /**
434
+ * Ranked by match, then by recently used among blocks the query names EXACTLY (label, id or alias), then catalogue
435
+ * order. Recency used to outrank the match itself, so "/heading" took the H3 used last over Heading 2, "/list" the
436
+ * numbered list over List, and "/image" a gallery over Image.
437
+ */
434
438
  var rank = (q, list, recent) => list.map((it, i) => {
435
439
  const s = score(q, it);
436
440
  const r = recent.indexOf(it.key);
437
441
  return {
438
442
  it,
439
443
  s,
440
- strong: s >= 3 ? 1 : 0,
441
- r: s >= 3 && r >= 0 ? r : 999,
444
+ r: s === 5 && r >= 0 ? r : 999,
442
445
  i
443
446
  };
444
- }).filter((x) => x.s > 0).sort((a, b) => b.strong - a.strong || a.r - b.r || b.s - a.s || a.i - b.i).map((x) => x.it);
447
+ }).filter((x) => x.s > 0).sort((a, b) => b.s - a.s || a.r - b.r || a.i - b.i).map((x) => x.it);
445
448
  /** `folder`: the More components view (its way back first, then the components, searched by `query`). */
446
449
  function useCatalog(query, allows, folder = false, own) {
447
450
  const recent = useRecents();
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.js","names":[],"sources":["../../../src/controls/rich-text/catalog.tsx"],"sourcesContent":["/**\n * RICH TEXT · the block catalogue shared by the toolbar Insert menu, the gutter \"+\" and the \"/\" slash menu (V2 HEAD\n * controls/rich-text/catalog.tsx, CPO D55).\n *\n * browse Text · Media · Data, grouped, then one quiet \"More components N\" row that opens the components the\n * field may embed (V2 HEAD catalog.tsx MORE), with its own search and a way back (\"All blocks\")\n * search every block and every embeddable component in one list: recently used first among the strong matches,\n * then by match (label, aliases, then description)\n * no match \"No match.\"\n *\n * Only the blocks the field accepts are offered (`features`, from the host's codec: each block is offered only where\n * the field's stored shape has a place for it). Not in this catalogue, and why:\n * (none: every V2 block has a stored form now, plan RT0–RT8; each is offered only where the field's codec declares it)\n *\n * Components come from the host (KitServices.useInsertableComponents: the project's components, narrowed to the ones\n * the field's config accepts), handed in through CatalogComponentsProvider. Without that service none is offered.\n * Deviation from V2: the library has no inline / page-section placement, so every component sits in one\n * \"Components\" group (V2: \"Article\" and \"Page sections\"), and no live preview flyout is drawn beside a row.\n */\nimport * as React from \"react\";\nimport {\n IconClick, IconCode, IconColumns2, IconNews, IconSuperscript, IconUserCircle, IconLayoutGrid, IconListCheck, IconListTree,\n IconArrowLeft, IconBlockquote, IconChevronRight, IconComponents, IconFileText, IconH1, IconH2, IconH3, IconH4, IconH5, IconH6, IconInfoCircle, IconLayoutNavbarCollapse, IconList, IconListDetails, IconListNumbers, IconPhoto,\n IconPilcrow, IconQuote, IconSearch, IconSeparatorHorizontal, IconTable, IconTerminal2, IconVideo,\n} from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { PopoverContent } from \"../../ui/overlay\";\nimport type { RichTextFeature } from \"./codec\";\nimport type { KitInsertableComponent } from \"../component-services\";\n\nexport type BasicId =\n | \"p\" | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"quote\" | \"pullquote\" | \"callout\" | \"toggle\" | \"takeaways\" | \"ul\" | \"ol\" | \"code\" | \"hr\"\n | \"image\" | \"video\" | \"file\" | \"table\" | \"task\" | \"button\" | \"gallery\" | \"embed\" | \"toc\" | \"footnote\" | \"columns\" | \"related\" | \"author\";\n\nexport interface CatalogItem {\n key: string;\n /** a basic block (absent on a component, the More components row and the way back) */\n id?: BasicId;\n /** component: embeds `component`; folder: opens More components; back: returns to every block */\n kind?: \"component\" | \"folder\" | \"back\";\n component?: KitInsertableComponent;\n /** the folder row's component count */\n count?: number;\n label: string;\n description: string;\n icon: React.ReactNode;\n /** extra words that find it */\n aliases?: string[];\n /** why it can't be picked here (a component this field refuses): shown in place of the description */\n disabled?: string;\n}\n\nconst i = (I: React.ComponentType<{ stroke?: number }>) => <I stroke={1.5} />;\ntype Row = [BasicId, string, string, React.ReactNode, string[]?];\nconst rows = (list: Row[]): CatalogItem[] => list.map(([id, label, description, icon, aliases]) => ({ key: id, id, label, description, icon, aliases }));\n\nconst TEXT = rows([\n [\"p\", \"Text\", \"Plain body text\", i(IconPilcrow), [\"paragraph\", \"body\"]],\n [\"h2\", \"Heading 2\", \"Section heading\", i(IconH2), [\"title\", \"subtitle\"]],\n [\"h3\", \"Heading 3\", \"Subsection heading\", i(IconH3)],\n [\"h4\", \"Heading 4\", \"Minor heading\", i(IconH4)],\n [\"quote\", \"Quote\", \"A quoted passage\", i(IconBlockquote), [\"blockquote\"]],\n [\"pullquote\", \"Pull quote\", \"A highlighted line with who said it\", i(IconQuote), [\"pq\", \"testimonial\", \"attribution\"]],\n [\"ul\", \"List\", \"Bulleted list\", i(IconList), [\"bullets\", \"bulleted list\", \"unordered\"]],\n [\"ol\", \"Numbered list\", \"Ordered steps\", i(IconListNumbers), [\"ordered\", \"steps\"]],\n [\"toggle\", \"Toggle\", \"Collapsible title and body\", i(IconLayoutNavbarCollapse), [\"accordion\", \"details\", \"collapse\"]],\n [\"callout\", \"Callout\", \"A highlighted note with a tone\", i(IconInfoCircle), [\"note\", \"tip\", \"warning\", \"aside\"]],\n [\"takeaways\", \"Key takeaways\", \"The story in a few points\", i(IconListDetails), [\"summary\", \"tldr\", \"tl;dr\", \"highlights\"]],\n [\"hr\", \"Divider\", \"A line between parts\", i(IconSeparatorHorizontal), [\"line\", \"separator\", \"rule\"]],\n [\"code\", \"Code\", \"Monospaced snippet\", i(IconTerminal2), [\"code block\", \"snippet\", \"pre\"]],\n [\"footnote\", \"Footnote\", \"A numbered note at the end\", i(IconSuperscript), [\"fn\", \"reference\", \"citation\", \"source\"]],\n]);\nconst MEDIA = rows([\n [\"image\", \"Image\", \"Image with alt text and caption\", i(IconPhoto), [\"img\", \"picture\", \"photo\"]],\n [\"gallery\", \"Gallery\", \"Several images as a grid or carousel\", i(IconLayoutGrid), [\"images\", \"photos\", \"carousel\", \"slideshow\"]],\n [\"video\", \"Video\", \"A YouTube, Vimeo or video file link\", i(IconVideo), [\"mp4\", \"youtube\", \"yt\", \"vimeo\", \"clip\", \"movie\"]],\n [\"embed\", \"Embed\", \"YouTube, X, CodePen, Figma, maps or audio\", i(IconCode), [\"yt\", \"youtube\", \"vimeo\", \"x\", \"tweet\", \"twitter\", \"codepen\", \"figma\", \"map\", \"maps\", \"spotify\", \"podcast\", \"audio\", \"iframe\"]],\n [\"file\", \"File\", \"A downloadable PDF or file\", i(IconFileText), [\"pdf\", \"download\", \"attachment\"]],\n]);\n/** V2 catalog.tsx ARTICLE: article blocks written in the body itself (the rest land with plan RT6–RT8). */\nconst ARTICLE = rows([\n [\"related\", \"Related posts\", \"More stories, picked or automatic\", i(IconNews), [\"related stories\", \"read next\", \"more stories\"]],\n [\"toc\", \"Table of contents\", \"Built from the headings\", i(IconListTree), [\"contents\", \"outline\", \"index\"]],\n [\"author\", \"Author bio\", \"Photo, name and short bio\", i(IconUserCircle), [\"bio\", \"byline\", \"about the author\"]],\n]);\nconst DATA = rows([[\"table\", \"Table\", \"Rows and columns\", i(IconTable), [\"grid\", \"data\", \"comparison\", \"spreadsheet\"]]]);\n/** Found by search, not listed: rare in a body (H1 is the page title). */\nconst SEARCH_ONLY = rows([\n [\"h1\", \"Heading 1\", \"Largest heading\", i(IconH1)],\n [\"h5\", \"Heading 5\", \"Smallest heading\", i(IconH5)],\n [\"h6\", \"Heading 6\", \"Eyebrow heading\", i(IconH6)],\n // V2 catalog.tsx:89, :91 (rare in a story, so found by search)\n [\"task\", \"Checklist\", \"To-do list with checkboxes\", i(IconListCheck), [\"todo\", \"checkbox\"]],\n [\"columns\", \"Columns\", \"Side by side text\", i(IconColumns2), [\"layout\"]],\n [\"button\", \"Button\", \"A call to action link\", i(IconClick), [\"link button\"]],\n]);\n\n/** The feature a block needs (Text needs none). */\nconst NEEDS: Record<BasicId, RichTextFeature | null> = {\n p: null, h1: \"h1\", h2: \"h2\", h3: \"h3\", h4: \"h4\", h5: \"h5\", h6: \"h6\", quote: \"blockquote\", ul: \"ul\", ol: \"ol\", code: \"pre\", hr: \"hr\", image: \"image\",\n pullquote: \"pullquote\", takeaways: \"takeaways\", callout: \"callout\", toggle: \"toggle\", video: \"video\", file: \"file\", table: \"table\",\n task: \"checklist\", button: \"button\", gallery: \"gallery\", embed: \"embed\", toc: \"toc\",\n footnote: \"footnote\", columns: \"columns\", related: \"related\", author: \"author\",\n};\nconst MORE: CatalogItem = { key: \"more\", kind: \"folder\", label: \"More blocks\", description: \"Shared across your site\", icon: i(IconComponents) };\nconst BACK: CatalogItem = { key: \"back\", kind: \"back\", label: \"All blocks\", description: \"\", icon: i(IconArrowLeft) };\nconst componentRow = (c: KitInsertableComponent): CatalogItem => ({\n key: `c:${c.id}`,\n kind: \"component\",\n component: c,\n label: c.name,\n description: c.disabled || c.description || \"Shared across your site\",\n icon: c.thumb ? <img src={c.thumb} alt=\"\" loading=\"lazy\" className=\"size-full rounded-[inherit] object-cover\" /> : i(IconComponents),\n ...(c.disabled ? { disabled: c.disabled } : {}),\n});\n\n/** The components this field may embed, as the host answered (KitServices.useInsertableComponents). */\nexport interface CatalogComponents {\n components: KitInsertableComponent[];\n loading?: boolean;\n error?: string;\n}\nconst ComponentsContext = React.createContext<CatalogComponents | null>(null);\nexport const CatalogComponentsProvider = ComponentsContext.Provider;\n/** The components this field may embed (a component card's Swap component). */\nexport const useCatalogComponents = () => React.useContext(ComponentsContext);\n\nexport const blockAllowed = (id: BasicId, allows: (f: RichTextFeature) => boolean) => {\n const need = NEEDS[id];\n return !need || allows(need);\n};\n\n/* ── Recently used (per person, CPO D55): this browser's storage; a browser that keeps none just has no recents ── */\nconst RECENTS_KEY = \"kit-rt-insert-recents\";\nlet recents: string[] = (() => {\n try {\n const v = JSON.parse(globalThis.localStorage?.getItem(RECENTS_KEY) ?? \"[]\") as unknown;\n return Array.isArray(v) ? v.filter((x): x is string => typeof x === \"string\") : [];\n } catch {\n return [];\n }\n})();\nconst recentSubs = new Set<() => void>();\n/** Remember a pick so search ranks it first next time. */\nexport function noteRecent(it: CatalogItem) {\n recents = [it.key, ...recents.filter((k) => k !== it.key)].slice(0, 12);\n try {\n globalThis.localStorage?.setItem(RECENTS_KEY, JSON.stringify(recents));\n } catch {\n /* storage is off: recents last for this session */\n }\n recentSubs.forEach((s) => s());\n}\nfunction useRecents() {\n return React.useSyncExternalStore(\n (cb) => {\n recentSubs.add(cb);\n return () => recentSubs.delete(cb);\n },\n () => recents,\n () => recents,\n );\n}\n\nexport interface CatalogSection {\n title: string | null;\n items: CatalogItem[];\n}\n\n/** 5 exact (label, id or alias) · 4 label or alias starts with it · 3 a word of the label starts with it · 2 inside the\n * label · 1 the description. */\nconst score = (q: string, it: CatalogItem) => {\n const l = it.label.toLowerCase();\n const al = it.aliases ?? [];\n if (l === q || it.id === q || al.includes(q)) return 5;\n if (l.startsWith(q) || al.some((a) => a.startsWith(q))) return 4;\n if (l.split(/[\\s-]+/).some((w) => w.startsWith(q))) return 3;\n if (l.includes(q)) return 2;\n return it.description.toLowerCase().includes(q) ? 1 : 0;\n};\n/** Ranked by recently used among the strong matches, then by match, then catalogue order. */\nconst rank = (q: string, list: CatalogItem[], recent: string[]) =>\n list\n .map((it, i) => {\n const s = score(q, it);\n const r = recent.indexOf(it.key);\n return { it, s, strong: s >= 3 ? 1 : 0, r: s >= 3 && r >= 0 ? r : 999, i };\n })\n .filter((x) => x.s > 0)\n .sort((a, b) => b.strong - a.strong || a.r - b.r || b.s - a.s || a.i - b.i)\n .map((x) => x.it);\n\n/** `folder`: the More components view (its way back first, then the components, searched by `query`). */\nexport function useCatalog(query: string, allows: (f: RichTextFeature) => boolean, folder = false, own?: CatalogComponents | null) {\n const recent = useRecents();\n const provided = React.useContext(ComponentsContext);\n // the editor reads its own list (it renders the provider, so cannot read it)\n const lib = own === undefined ? provided : own;\n return React.useMemo(() => {\n const q = query.trim().toLowerCase().replace(/^\\//, \"\");\n const keep = (list: CatalogItem[]) => list.filter((it) => !it.id || blockAllowed(it.id, allows));\n const comps = (lib?.components ?? []).map(componentRow);\n // the folder counts what can go in; a refused component is listed inside with its reason\n const pickable = comps.filter((c) => !c.disabled).length;\n let sections: CatalogSection[];\n let noMatch = false;\n let emptyText = \"No match.\";\n if (folder) {\n const found = q ? rank(q, comps, recent) : comps;\n noMatch = !!q && !!comps.length && !found.length;\n if (!comps.length) emptyText = lib?.error ?? (lib?.loading ? \"Loading blocks…\" : \"This field takes no blocks.\");\n sections = [{ title: null, items: [BACK] }, { title: \"Blocks\", items: found }];\n } else if (q) {\n const found = rank(q, [...keep(TEXT), ...keep(MEDIA), ...keep(DATA), ...keep(ARTICLE), ...keep(SEARCH_ONLY), ...comps], recent);\n noMatch = !found.length;\n sections = [{ title: null, items: found }];\n } else\n sections = [\n { title: \"Text\", items: keep(TEXT) },\n { title: \"Media\", items: keep(MEDIA) },\n { title: \"Data\", items: keep(DATA) },\n { title: \"Article\", items: keep(ARTICLE) },\n // offered while the list loads or failed too: opening it says which\n { title: null, items: lib && (comps.length || lib.loading || lib.error) ? [{ ...MORE, ...(pickable ? { count: pickable } : {}) }] : [] },\n ];\n sections = sections.filter((s) => s.items.length);\n const flat = sections.flatMap((s) => s.items);\n const empty = !flat.some((it) => it.kind !== \"back\");\n return { sections, flat, empty, noMatch, emptyText };\n }, [query, allows, recent, lib, folder]);\n}\n\n/* ── The list ───────────────────────────────────────────────────────────\n * Browsing: compact one-line rows (icon · name), grouped. Search results add the one-line description. */\nexport function CatalogList({\n sections,\n flat,\n active,\n onHover,\n onPick,\n empty,\n emptyText = \"No match.\",\n noMatch,\n detail,\n listId,\n className,\n}: {\n sections: CatalogSection[];\n flat: CatalogItem[];\n active: number;\n onHover: (i: number) => void;\n onPick: (it: CatalogItem) => void;\n empty: boolean;\n /** what an empty list says (\"No match.\", or why More components has none) */\n emptyText?: string;\n noMatch?: boolean;\n /** show each row's description (search results, More components) */\n detail?: boolean;\n listId: string;\n className?: string;\n}) {\n const box = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n // scroll only the list (scrollIntoView would also scroll the page behind a floating menu)\n const b = box.current;\n const row = b?.querySelector<HTMLElement>(`[data-idx=\"${active}\"]`);\n if (!b || !row) return;\n if (row.offsetTop < b.scrollTop) b.scrollTop = row.offsetTop - 6;\n else if (row.offsetTop + row.offsetHeight > b.scrollTop + b.clientHeight) b.scrollTop = row.offsetTop + row.offsetHeight - b.clientHeight + 6;\n }, [active]);\n return (\n <div ref={box} id={listId} role=\"listbox\" aria-label=\"Blocks\" className={cn(\"relative max-h-[320px] overflow-y-auto p-1.5\", className)}>\n {noMatch ? <div className=\"px-2 pb-1 pt-1.5 text-kit-sm text-kit-fg-3\">No match.</div> : null}\n {sections.map((s, si) => (\n <div\n key={s.title ?? `s${si}`}\n role=\"group\"\n aria-label={s.title ?? undefined}\n className={cn(!s.title && si > 0 && s.items[0]?.kind === \"folder\" && \"mt-1.5 border-t border-kit-line-subtle pt-1.5\")}\n >\n {s.title ? <div className=\"px-2 pb-0.5 pt-2 text-kit-2xs font-medium text-kit-fg-3\">{s.title}</div> : null}\n {s.items.map((it) => {\n const idx = flat.indexOf(it);\n const on = idx === active;\n const desc = detail && it.kind !== \"back\" && it.kind !== \"folder\" ? it.description : \"\";\n return (\n <button\n key={it.key}\n type=\"button\"\n role=\"option\"\n aria-selected={on}\n aria-disabled={it.disabled ? true : undefined}\n aria-description={!desc && it.description ? it.description : undefined}\n data-idx={idx}\n id={`${listId}-${idx}`}\n onMouseDown={(e) => e.preventDefault()}\n onMouseMove={() => !on && onHover(idx)}\n onClick={() => !it.disabled && onPick(it)}\n className={cn(\n \"flex w-full items-center gap-2 rounded-kit-md px-2 text-left transition-colors motion-reduce:transition-none\",\n desc ? \"py-1.5\" : \"h-8\",\n it.kind === \"back\" ? \"text-kit-fg-2\" : it.disabled ? \"cursor-default text-kit-fg-3\" : \"text-kit-fg\",\n on && \"bg-kit-hover text-kit-fg\",\n )}\n >\n <span className={cn(\"flex shrink-0 items-center justify-center text-kit-fg-2 [&_svg]:size-4\", desc ? \"size-7 rounded-kit-md border border-kit-line bg-kit-control-bg\" : \"size-5\")}>\n {it.icon}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-kit-sm\">{it.label}</span>\n {desc ? <span className=\"block truncate text-kit-xs text-kit-fg-3\">{desc}</span> : null}\n </span>\n {it.count != null ? <span className=\"text-kit-2xs tabular-nums text-kit-fg-3\">{it.count}</span> : null}\n {it.kind === \"folder\" ? <IconChevronRight className=\"size-3.5 shrink-0 text-kit-fg-3\" stroke={1.5} aria-hidden /> : null}\n </button>\n );\n })}\n </div>\n ))}\n {/* a search with no result says \"No match.\" once, in the line above (V2 catalog.tsx:263) */}\n {empty && !noMatch ? <div className=\"px-2 py-6 text-center text-kit-sm text-kit-fg-3\">{emptyText}</div> : null}\n </div>\n );\n}\n\nconst Footer = () => (\n <div data-hint=\"shortcuts\" className=\"flex h-7 shrink-0 items-center border-t border-kit-line px-3 text-kit-2xs text-kit-fg-3\">\n <span>\n <kbd className=\"font-kit-sans\">↵</kbd> select · type to search\n </span>\n </div>\n);\n\n/** Shared keyboard model: ↑↓ wrap, Home/End, Enter / Tab, → into More components. Returns true when handled. */\nexport function catalogKey(\n e: React.KeyboardEvent | KeyboardEvent,\n flat: CatalogItem[],\n active: number,\n setActive: (i: number) => void,\n pick: (it: CatalogItem) => void,\n homeEnd = true,\n) {\n const n = flat.length;\n if (!n) return false;\n if (e.key === \"ArrowDown\") return setActive((active + 1) % n), true;\n if (e.key === \"ArrowUp\") return setActive((active - 1 + n) % n), true;\n if (homeEnd && e.key === \"Home\") return setActive(0), true;\n if (homeEnd && e.key === \"End\") return setActive(n - 1), true;\n if (e.key === \"ArrowRight\" && flat[active]?.kind === \"folder\") return pick(flat[active]), true;\n if (e.key === \"Enter\" || e.key === \"Tab\") {\n const it = flat[active];\n if (it && !it.disabled) pick(it);\n return true;\n }\n return false;\n}\n\n/* ── Insert menu (popover content for the toolbar \"Insert\" and the gutter \"+\") ─ */\nexport function InsertMenuContent({\n onInsert,\n allows,\n keepFocusOnClose,\n align = \"start\",\n side = \"bottom\",\n}: {\n onInsert: (it: CatalogItem) => void;\n allows: (f: RichTextFeature) => boolean;\n /** after an insert the caret stays in the editor: the menu gives no focus back to its trigger */\n keepFocusOnClose?: () => boolean;\n align?: \"start\" | \"center\" | \"end\";\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n}) {\n const [q, setQ] = React.useState(\"\");\n const [active, setActive] = React.useState(0);\n const input = React.useRef<HTMLInputElement>(null);\n const listId = React.useId();\n const [folder, setFolder] = React.useState(false);\n const { sections, flat, empty, emptyText, noMatch } = useCatalog(q, allows, folder);\n // in More components the first row is the way back: the first component starts active\n React.useEffect(() => setActive(folder && flat.length > 1 ? 1 : 0), [q, folder]); // eslint-disable-line react-hooks/exhaustive-deps\n const leave = () => {\n setFolder(false);\n setQ(\"\");\n input.current?.focus();\n };\n const pick = (it: CatalogItem) => {\n if (it.kind === \"folder\") {\n setFolder(true);\n setQ(\"\");\n input.current?.focus();\n } else if (it.kind === \"back\") leave();\n else onInsert(it);\n };\n return (\n <PopoverContent\n side={side}\n align={align}\n className=\"flex max-h-[420px] w-[320px] flex-col overflow-hidden p-0\"\n initialFocus={input}\n finalFocus={keepFocusOnClose ? () => !keepFocusOnClose() : undefined}\n // Esc in More components steps back to every block, wherever focus sits in the menu (the list scrolls, so the\n // browser can focus it): caught before the popover's own Esc, which would close it\n onKeyDownCapture={(e) => {\n if (!folder || e.key !== \"Escape\") return;\n e.preventDefault();\n e.stopPropagation();\n leave();\n }}\n >\n <div className=\"flex h-10 shrink-0 items-center gap-2 border-b border-kit-line px-3\">\n <IconSearch className=\"size-4 shrink-0 text-kit-fg-3\" stroke={1.5} aria-hidden />\n <input\n ref={input}\n value={q}\n onChange={(e) => setQ(e.target.value)}\n onKeyDown={(e) => {\n if (folder && e.key === \"Backspace\" && !q) {\n // ⌫ in an empty search steps back to every block (Esc: the popup's capture above)\n e.preventDefault();\n e.stopPropagation();\n leave();\n } else if (catalogKey(e, flat, active, setActive, pick, !q)) e.preventDefault();\n }}\n role=\"combobox\"\n aria-expanded\n aria-controls={listId}\n aria-activedescendant={flat.length ? `${listId}-${active}` : undefined}\n aria-label={folder ? \"Search blocks\" : \"Search or pick a block\"}\n placeholder={folder ? \"Search blocks\" : \"Search or pick a block\"}\n className=\"h-full min-w-0 flex-1 bg-transparent text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3 focus-visible:shadow-none\"\n />\n </div>\n <CatalogList\n sections={sections}\n flat={flat}\n active={active}\n onHover={setActive}\n onPick={pick}\n empty={empty}\n emptyText={emptyText}\n noMatch={noMatch}\n detail={!!q || folder}\n listId={listId}\n className=\"min-h-0 flex-1\"\n />\n <Footer />\n </PopoverContent>\n );\n}\n\n/* ── Slash menu panel (positioned by the editor; never takes focus) ── */\nexport function SlashMenuPanel({\n query,\n folder = false,\n active,\n setActive,\n onPick,\n allows,\n maxHeight,\n}: {\n /** the room the editor found for the menu (collision-aware); the list scrolls inside it */\n maxHeight?: number;\n query: string;\n /** the More components view (the editor keeps it with the rest of the slash state) */\n folder?: boolean;\n active: number;\n setActive: (i: number) => void;\n onPick: (it: CatalogItem) => void;\n allows: (f: RichTextFeature) => boolean;\n}) {\n const listId = React.useId();\n const { sections, flat, empty, emptyText, noMatch } = useCatalog(query, allows, folder);\n return (\n <div\n data-kit-scope=\"\"\n className=\"glass-strong flex w-[320px] flex-col overflow-hidden rounded-kit-xl border border-kit-line\"\n style={maxHeight ? { maxHeight } : undefined}\n onMouseDown={(e) => e.preventDefault()}\n >\n <div className=\"flex h-8 shrink-0 items-center gap-2 border-b border-kit-line px-3 text-kit-sm\">\n <span className={cn(\"flex-1 truncate\", query ? \"text-kit-fg\" : \"text-kit-fg-3\")}>{query ? `${folder ? \"More blocks · \" : \"\"}/${query}` : folder ? \"More blocks\" : \"Type to search\"}</span>\n <kbd data-hint=\"shortcuts\" className=\"font-kit-sans text-kit-2xs text-kit-fg-3\">\n esc\n </kbd>\n </div>\n <CatalogList\n sections={sections}\n flat={flat}\n active={active}\n onHover={setActive}\n onPick={onPick}\n empty={empty}\n emptyText={emptyText}\n noMatch={noMatch}\n detail={!!query || folder}\n listId={listId}\n className=\"max-h-[300px] min-h-0 flex-1\"\n />\n <Foot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e;KAAI,UAAA,QAAQ,GAAG,SAAS,mBAAmB,GAAG,GAAG,UAAU,SAAS,gBAAgB;IAAuB,CAAA,GACzL,oBAAC,OAAD;KAAK,aAAU;KAAY,WAAU;KAA2C,UAAA;IAE3E,CAAA,CACF;;GACL,oBAAC,aAAD;IACY;IACJ;IACE;IACR,SAAS;IACD;IACD;IACI;IACF;IACT,QAAQ,CAAC,CAAC,SAAS;IACX;IACR,WAAU;GACX,CAAA;GACD,oBAAC,QAAD,CAAS,CAAA;EACN;;AAET"}
1
+ {"version":3,"file":"catalog.js","names":[],"sources":["../../../src/controls/rich-text/catalog.tsx"],"sourcesContent":["/**\n * RICH TEXT · the block catalogue shared by the toolbar Insert menu, the gutter \"+\" and the \"/\" slash menu (V2 HEAD\n * controls/rich-text/catalog.tsx, CPO D55).\n *\n * browse Text · Media · Data, grouped, then one quiet \"More components N\" row that opens the components the\n * field may embed (V2 HEAD catalog.tsx MORE), with its own search and a way back (\"All blocks\")\n * search every block and every embeddable component in one list: recently used first among the strong matches,\n * then by match (label, aliases, then description)\n * no match \"No match.\"\n *\n * Only the blocks the field accepts are offered (`features`, from the host's codec: each block is offered only where\n * the field's stored shape has a place for it). Not in this catalogue, and why:\n * (none: every V2 block has a stored form now, plan RT0–RT8; each is offered only where the field's codec declares it)\n *\n * Components come from the host (KitServices.useInsertableComponents: the project's components, narrowed to the ones\n * the field's config accepts), handed in through CatalogComponentsProvider. Without that service none is offered.\n * Deviation from V2: the library has no inline / page-section placement, so every component sits in one\n * \"Components\" group (V2: \"Article\" and \"Page sections\"), and no live preview flyout is drawn beside a row.\n */\nimport * as React from \"react\";\nimport {\n IconClick, IconCode, IconColumns2, IconNews, IconSuperscript, IconUserCircle, IconLayoutGrid, IconListCheck, IconListTree,\n IconArrowLeft, IconBlockquote, IconChevronRight, IconComponents, IconFileText, IconH1, IconH2, IconH3, IconH4, IconH5, IconH6, IconInfoCircle, IconLayoutNavbarCollapse, IconList, IconListDetails, IconListNumbers, IconPhoto,\n IconPilcrow, IconQuote, IconSearch, IconSeparatorHorizontal, IconTable, IconTerminal2, IconVideo,\n} from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { PopoverContent } from \"../../ui/overlay\";\nimport type { RichTextFeature } from \"./codec\";\nimport type { KitInsertableComponent } from \"../component-services\";\n\nexport type BasicId =\n | \"p\" | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"quote\" | \"pullquote\" | \"callout\" | \"toggle\" | \"takeaways\" | \"ul\" | \"ol\" | \"code\" | \"hr\"\n | \"image\" | \"video\" | \"file\" | \"table\" | \"task\" | \"button\" | \"gallery\" | \"embed\" | \"toc\" | \"footnote\" | \"columns\" | \"related\" | \"author\";\n\nexport interface CatalogItem {\n key: string;\n /** a basic block (absent on a component, the More components row and the way back) */\n id?: BasicId;\n /** component: embeds `component`; folder: opens More components; back: returns to every block */\n kind?: \"component\" | \"folder\" | \"back\";\n component?: KitInsertableComponent;\n /** the folder row's component count */\n count?: number;\n label: string;\n description: string;\n icon: React.ReactNode;\n /** extra words that find it */\n aliases?: string[];\n /** why it can't be picked here (a component this field refuses): shown in place of the description */\n disabled?: string;\n}\n\nconst i = (I: React.ComponentType<{ stroke?: number }>) => <I stroke={1.5} />;\ntype Row = [BasicId, string, string, React.ReactNode, string[]?];\nconst rows = (list: Row[]): CatalogItem[] => list.map(([id, label, description, icon, aliases]) => ({ key: id, id, label, description, icon, aliases }));\n\nconst TEXT = rows([\n [\"p\", \"Text\", \"Plain body text\", i(IconPilcrow), [\"paragraph\", \"body\"]],\n [\"h2\", \"Heading 2\", \"Section heading\", i(IconH2), [\"title\", \"subtitle\"]],\n [\"h3\", \"Heading 3\", \"Subsection heading\", i(IconH3)],\n [\"h4\", \"Heading 4\", \"Minor heading\", i(IconH4)],\n [\"quote\", \"Quote\", \"A quoted passage\", i(IconBlockquote), [\"blockquote\"]],\n [\"pullquote\", \"Pull quote\", \"A highlighted line with who said it\", i(IconQuote), [\"pq\", \"testimonial\", \"attribution\"]],\n [\"ul\", \"List\", \"Bulleted list\", i(IconList), [\"bullets\", \"bulleted list\", \"unordered\"]],\n [\"ol\", \"Numbered list\", \"Ordered steps\", i(IconListNumbers), [\"ordered\", \"steps\"]],\n [\"toggle\", \"Toggle\", \"Collapsible title and body\", i(IconLayoutNavbarCollapse), [\"accordion\", \"details\", \"collapse\"]],\n [\"callout\", \"Callout\", \"A highlighted note with a tone\", i(IconInfoCircle), [\"note\", \"tip\", \"warning\", \"aside\"]],\n [\"takeaways\", \"Key takeaways\", \"The story in a few points\", i(IconListDetails), [\"summary\", \"tldr\", \"tl;dr\", \"highlights\"]],\n [\"hr\", \"Divider\", \"A line between parts\", i(IconSeparatorHorizontal), [\"line\", \"separator\", \"rule\"]],\n [\"code\", \"Code\", \"Monospaced snippet\", i(IconTerminal2), [\"code block\", \"snippet\", \"pre\"]],\n [\"footnote\", \"Footnote\", \"A numbered note at the end\", i(IconSuperscript), [\"fn\", \"reference\", \"citation\", \"source\"]],\n]);\nconst MEDIA = rows([\n [\"image\", \"Image\", \"Image with alt text and caption\", i(IconPhoto), [\"img\", \"picture\", \"photo\"]],\n [\"gallery\", \"Gallery\", \"Several images as a grid or carousel\", i(IconLayoutGrid), [\"images\", \"photos\", \"carousel\", \"slideshow\"]],\n [\"video\", \"Video\", \"A YouTube, Vimeo or video file link\", i(IconVideo), [\"mp4\", \"youtube\", \"yt\", \"vimeo\", \"clip\", \"movie\"]],\n [\"embed\", \"Embed\", \"YouTube, X, CodePen, Figma, maps or audio\", i(IconCode), [\"yt\", \"youtube\", \"vimeo\", \"x\", \"tweet\", \"twitter\", \"codepen\", \"figma\", \"map\", \"maps\", \"spotify\", \"podcast\", \"audio\", \"iframe\"]],\n [\"file\", \"File\", \"A downloadable PDF or file\", i(IconFileText), [\"pdf\", \"download\", \"attachment\"]],\n]);\n/** V2 catalog.tsx ARTICLE: article blocks written in the body itself (the rest land with plan RT6–RT8). */\nconst ARTICLE = rows([\n [\"related\", \"Related posts\", \"More stories, picked or automatic\", i(IconNews), [\"related stories\", \"read next\", \"more stories\"]],\n [\"toc\", \"Table of contents\", \"Built from the headings\", i(IconListTree), [\"contents\", \"outline\", \"index\"]],\n [\"author\", \"Author bio\", \"Photo, name and short bio\", i(IconUserCircle), [\"bio\", \"byline\", \"about the author\"]],\n]);\nconst DATA = rows([[\"table\", \"Table\", \"Rows and columns\", i(IconTable), [\"grid\", \"data\", \"comparison\", \"spreadsheet\"]]]);\n/** Found by search, not listed: rare in a body (H1 is the page title). */\nconst SEARCH_ONLY = rows([\n [\"h1\", \"Heading 1\", \"Largest heading\", i(IconH1)],\n [\"h5\", \"Heading 5\", \"Smallest heading\", i(IconH5)],\n [\"h6\", \"Heading 6\", \"Eyebrow heading\", i(IconH6)],\n // V2 catalog.tsx:89, :91 (rare in a story, so found by search)\n [\"task\", \"Checklist\", \"To-do list with checkboxes\", i(IconListCheck), [\"todo\", \"checkbox\"]],\n [\"columns\", \"Columns\", \"Side by side text\", i(IconColumns2), [\"layout\"]],\n [\"button\", \"Button\", \"A call to action link\", i(IconClick), [\"link button\"]],\n]);\n\n/** The feature a block needs (Text needs none). */\nconst NEEDS: Record<BasicId, RichTextFeature | null> = {\n p: null, h1: \"h1\", h2: \"h2\", h3: \"h3\", h4: \"h4\", h5: \"h5\", h6: \"h6\", quote: \"blockquote\", ul: \"ul\", ol: \"ol\", code: \"pre\", hr: \"hr\", image: \"image\",\n pullquote: \"pullquote\", takeaways: \"takeaways\", callout: \"callout\", toggle: \"toggle\", video: \"video\", file: \"file\", table: \"table\",\n task: \"checklist\", button: \"button\", gallery: \"gallery\", embed: \"embed\", toc: \"toc\",\n footnote: \"footnote\", columns: \"columns\", related: \"related\", author: \"author\",\n};\nconst MORE: CatalogItem = { key: \"more\", kind: \"folder\", label: \"More blocks\", description: \"Shared across your site\", icon: i(IconComponents) };\nconst BACK: CatalogItem = { key: \"back\", kind: \"back\", label: \"All blocks\", description: \"\", icon: i(IconArrowLeft) };\nconst componentRow = (c: KitInsertableComponent): CatalogItem => ({\n key: `c:${c.id}`,\n kind: \"component\",\n component: c,\n label: c.name,\n description: c.disabled || c.description || \"Shared across your site\",\n icon: c.thumb ? <img src={c.thumb} alt=\"\" loading=\"lazy\" className=\"size-full rounded-[inherit] object-cover\" /> : i(IconComponents),\n ...(c.disabled ? { disabled: c.disabled } : {}),\n});\n\n/** The components this field may embed, as the host answered (KitServices.useInsertableComponents). */\nexport interface CatalogComponents {\n components: KitInsertableComponent[];\n loading?: boolean;\n error?: string;\n}\nconst ComponentsContext = React.createContext<CatalogComponents | null>(null);\nexport const CatalogComponentsProvider = ComponentsContext.Provider;\n/** The components this field may embed (a component card's Swap component). */\nexport const useCatalogComponents = () => React.useContext(ComponentsContext);\n\nexport const blockAllowed = (id: BasicId, allows: (f: RichTextFeature) => boolean) => {\n const need = NEEDS[id];\n return !need || allows(need);\n};\n\n/* ── Recently used (per person, CPO D55): this browser's storage; a browser that keeps none just has no recents ── */\nconst RECENTS_KEY = \"kit-rt-insert-recents\";\nlet recents: string[] = (() => {\n try {\n const v = JSON.parse(globalThis.localStorage?.getItem(RECENTS_KEY) ?? \"[]\") as unknown;\n return Array.isArray(v) ? v.filter((x): x is string => typeof x === \"string\") : [];\n } catch {\n return [];\n }\n})();\nconst recentSubs = new Set<() => void>();\n/** Remember a pick so search ranks it first next time. */\nexport function noteRecent(it: CatalogItem) {\n recents = [it.key, ...recents.filter((k) => k !== it.key)].slice(0, 12);\n try {\n globalThis.localStorage?.setItem(RECENTS_KEY, JSON.stringify(recents));\n } catch {\n /* storage is off: recents last for this session */\n }\n recentSubs.forEach((s) => s());\n}\nfunction useRecents() {\n return React.useSyncExternalStore(\n (cb) => {\n recentSubs.add(cb);\n return () => recentSubs.delete(cb);\n },\n () => recents,\n () => recents,\n );\n}\n\nexport interface CatalogSection {\n title: string | null;\n items: CatalogItem[];\n}\n\n/** 5 exact (label, id or alias) · 4 label or alias starts with it · 3 a word of the label starts with it · 2 inside the\n * label · 1 the description. */\nconst score = (q: string, it: CatalogItem) => {\n const l = it.label.toLowerCase();\n const al = it.aliases ?? [];\n if (l === q || it.id === q || al.includes(q)) return 5;\n if (l.startsWith(q) || al.some((a) => a.startsWith(q))) return 4;\n if (l.split(/[\\s-]+/).some((w) => w.startsWith(q))) return 3;\n if (l.includes(q)) return 2;\n return it.description.toLowerCase().includes(q) ? 1 : 0;\n};\n/**\n * Ranked by match, then by recently used among blocks the query names EXACTLY (label, id or alias), then catalogue\n * order. Recency used to outrank the match itself, so \"/heading\" took the H3 used last over Heading 2, \"/list\" the\n * numbered list over List, and \"/image\" a gallery over Image.\n */\nconst rank = (q: string, list: CatalogItem[], recent: string[]) =>\n list\n .map((it, i) => {\n const s = score(q, it);\n const r = recent.indexOf(it.key);\n return { it, s, r: s === 5 && r >= 0 ? r : 999, i };\n })\n .filter((x) => x.s > 0)\n .sort((a, b) => b.s - a.s || a.r - b.r || a.i - b.i)\n .map((x) => x.it);\n\n/** `folder`: the More components view (its way back first, then the components, searched by `query`). */\nexport function useCatalog(query: string, allows: (f: RichTextFeature) => boolean, folder = false, own?: CatalogComponents | null) {\n const recent = useRecents();\n const provided = React.useContext(ComponentsContext);\n // the editor reads its own list (it renders the provider, so cannot read it)\n const lib = own === undefined ? provided : own;\n return React.useMemo(() => {\n const q = query.trim().toLowerCase().replace(/^\\//, \"\");\n const keep = (list: CatalogItem[]) => list.filter((it) => !it.id || blockAllowed(it.id, allows));\n const comps = (lib?.components ?? []).map(componentRow);\n // the folder counts what can go in; a refused component is listed inside with its reason\n const pickable = comps.filter((c) => !c.disabled).length;\n let sections: CatalogSection[];\n let noMatch = false;\n let emptyText = \"No match.\";\n if (folder) {\n const found = q ? rank(q, comps, recent) : comps;\n noMatch = !!q && !!comps.length && !found.length;\n if (!comps.length) emptyText = lib?.error ?? (lib?.loading ? \"Loading blocks…\" : \"This field takes no blocks.\");\n sections = [{ title: null, items: [BACK] }, { title: \"Blocks\", items: found }];\n } else if (q) {\n const found = rank(q, [...keep(TEXT), ...keep(MEDIA), ...keep(DATA), ...keep(ARTICLE), ...keep(SEARCH_ONLY), ...comps], recent);\n noMatch = !found.length;\n sections = [{ title: null, items: found }];\n } else\n sections = [\n { title: \"Text\", items: keep(TEXT) },\n { title: \"Media\", items: keep(MEDIA) },\n { title: \"Data\", items: keep(DATA) },\n { title: \"Article\", items: keep(ARTICLE) },\n // offered while the list loads or failed too: opening it says which\n { title: null, items: lib && (comps.length || lib.loading || lib.error) ? [{ ...MORE, ...(pickable ? { count: pickable } : {}) }] : [] },\n ];\n sections = sections.filter((s) => s.items.length);\n const flat = sections.flatMap((s) => s.items);\n const empty = !flat.some((it) => it.kind !== \"back\");\n return { sections, flat, empty, noMatch, emptyText };\n }, [query, allows, recent, lib, folder]);\n}\n\n/* ── The list ───────────────────────────────────────────────────────────\n * Browsing: compact one-line rows (icon · name), grouped. Search results add the one-line description. */\nexport function CatalogList({\n sections,\n flat,\n active,\n onHover,\n onPick,\n empty,\n emptyText = \"No match.\",\n noMatch,\n detail,\n listId,\n className,\n}: {\n sections: CatalogSection[];\n flat: CatalogItem[];\n active: number;\n onHover: (i: number) => void;\n onPick: (it: CatalogItem) => void;\n empty: boolean;\n /** what an empty list says (\"No match.\", or why More components has none) */\n emptyText?: string;\n noMatch?: boolean;\n /** show each row's description (search results, More components) */\n detail?: boolean;\n listId: string;\n className?: string;\n}) {\n const box = React.useRef<HTMLDivElement>(null);\n React.useEffect(() => {\n // scroll only the list (scrollIntoView would also scroll the page behind a floating menu)\n const b = box.current;\n const row = b?.querySelector<HTMLElement>(`[data-idx=\"${active}\"]`);\n if (!b || !row) return;\n if (row.offsetTop < b.scrollTop) b.scrollTop = row.offsetTop - 6;\n else if (row.offsetTop + row.offsetHeight > b.scrollTop + b.clientHeight) b.scrollTop = row.offsetTop + row.offsetHeight - b.clientHeight + 6;\n }, [active]);\n return (\n <div ref={box} id={listId} role=\"listbox\" aria-label=\"Blocks\" className={cn(\"relative max-h-[320px] overflow-y-auto p-1.5\", className)}>\n {noMatch ? <div className=\"px-2 pb-1 pt-1.5 text-kit-sm text-kit-fg-3\">No match.</div> : null}\n {sections.map((s, si) => (\n <div\n key={s.title ?? `s${si}`}\n role=\"group\"\n aria-label={s.title ?? undefined}\n className={cn(!s.title && si > 0 && s.items[0]?.kind === \"folder\" && \"mt-1.5 border-t border-kit-line-subtle pt-1.5\")}\n >\n {s.title ? <div className=\"px-2 pb-0.5 pt-2 text-kit-2xs font-medium text-kit-fg-3\">{s.title}</div> : null}\n {s.items.map((it) => {\n const idx = flat.indexOf(it);\n const on = idx === active;\n const desc = detail && it.kind !== \"back\" && it.kind !== \"folder\" ? it.description : \"\";\n return (\n <button\n key={it.key}\n type=\"button\"\n role=\"option\"\n aria-selected={on}\n aria-disabled={it.disabled ? true : undefined}\n aria-description={!desc && it.description ? it.description : undefined}\n data-idx={idx}\n id={`${listId}-${idx}`}\n onMouseDown={(e) => e.preventDefault()}\n onMouseMove={() => !on && onHover(idx)}\n onClick={() => !it.disabled && onPick(it)}\n className={cn(\n \"flex w-full items-center gap-2 rounded-kit-md px-2 text-left transition-colors motion-reduce:transition-none\",\n desc ? \"py-1.5\" : \"h-8\",\n it.kind === \"back\" ? \"text-kit-fg-2\" : it.disabled ? \"cursor-default text-kit-fg-3\" : \"text-kit-fg\",\n on && \"bg-kit-hover text-kit-fg\",\n )}\n >\n <span className={cn(\"flex shrink-0 items-center justify-center text-kit-fg-2 [&_svg]:size-4\", desc ? \"size-7 rounded-kit-md border border-kit-line bg-kit-control-bg\" : \"size-5\")}>\n {it.icon}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-kit-sm\">{it.label}</span>\n {desc ? <span className=\"block truncate text-kit-xs text-kit-fg-3\">{desc}</span> : null}\n </span>\n {it.count != null ? <span className=\"text-kit-2xs tabular-nums text-kit-fg-3\">{it.count}</span> : null}\n {it.kind === \"folder\" ? <IconChevronRight className=\"size-3.5 shrink-0 text-kit-fg-3\" stroke={1.5} aria-hidden /> : null}\n </button>\n );\n })}\n </div>\n ))}\n {/* a search with no result says \"No match.\" once, in the line above (V2 catalog.tsx:263) */}\n {empty && !noMatch ? <div className=\"px-2 py-6 text-center text-kit-sm text-kit-fg-3\">{emptyText}</div> : null}\n </div>\n );\n}\n\nconst Footer = () => (\n <div data-hint=\"shortcuts\" className=\"flex h-7 shrink-0 items-center border-t border-kit-line px-3 text-kit-2xs text-kit-fg-3\">\n <span>\n <kbd className=\"font-kit-sans\">↵</kbd> select · type to search\n </span>\n </div>\n);\n\n/** Shared keyboard model: ↑↓ wrap, Home/End, Enter / Tab, → into More components. Returns true when handled. */\nexport function catalogKey(\n e: React.KeyboardEvent | KeyboardEvent,\n flat: CatalogItem[],\n active: number,\n setActive: (i: number) => void,\n pick: (it: CatalogItem) => void,\n homeEnd = true,\n) {\n const n = flat.length;\n if (!n) return false;\n if (e.key === \"ArrowDown\") return setActive((active + 1) % n), true;\n if (e.key === \"ArrowUp\") return setActive((active - 1 + n) % n), true;\n if (homeEnd && e.key === \"Home\") return setActive(0), true;\n if (homeEnd && e.key === \"End\") return setActive(n - 1), true;\n if (e.key === \"ArrowRight\" && flat[active]?.kind === \"folder\") return pick(flat[active]), true;\n if (e.key === \"Enter\" || e.key === \"Tab\") {\n const it = flat[active];\n if (it && !it.disabled) pick(it);\n return true;\n }\n return false;\n}\n\n/* ── Insert menu (popover content for the toolbar \"Insert\" and the gutter \"+\") ─ */\nexport function InsertMenuContent({\n onInsert,\n allows,\n keepFocusOnClose,\n align = \"start\",\n side = \"bottom\",\n}: {\n onInsert: (it: CatalogItem) => void;\n allows: (f: RichTextFeature) => boolean;\n /** after an insert the caret stays in the editor: the menu gives no focus back to its trigger */\n keepFocusOnClose?: () => boolean;\n align?: \"start\" | \"center\" | \"end\";\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n}) {\n const [q, setQ] = React.useState(\"\");\n const [active, setActive] = React.useState(0);\n const input = React.useRef<HTMLInputElement>(null);\n const listId = React.useId();\n const [folder, setFolder] = React.useState(false);\n const { sections, flat, empty, emptyText, noMatch } = useCatalog(q, allows, folder);\n // in More components the first row is the way back: the first component starts active\n React.useEffect(() => setActive(folder && flat.length > 1 ? 1 : 0), [q, folder]); // eslint-disable-line react-hooks/exhaustive-deps\n const leave = () => {\n setFolder(false);\n setQ(\"\");\n input.current?.focus();\n };\n const pick = (it: CatalogItem) => {\n if (it.kind === \"folder\") {\n setFolder(true);\n setQ(\"\");\n input.current?.focus();\n } else if (it.kind === \"back\") leave();\n else onInsert(it);\n };\n return (\n <PopoverContent\n side={side}\n align={align}\n className=\"flex max-h-[420px] w-[320px] flex-col overflow-hidden p-0\"\n initialFocus={input}\n finalFocus={keepFocusOnClose ? () => !keepFocusOnClose() : undefined}\n // Esc in More components steps back to every block, wherever focus sits in the menu (the list scrolls, so the\n // browser can focus it): caught before the popover's own Esc, which would close it\n onKeyDownCapture={(e) => {\n if (!folder || e.key !== \"Escape\") return;\n e.preventDefault();\n e.stopPropagation();\n leave();\n }}\n >\n <div className=\"flex h-10 shrink-0 items-center gap-2 border-b border-kit-line px-3\">\n <IconSearch className=\"size-4 shrink-0 text-kit-fg-3\" stroke={1.5} aria-hidden />\n <input\n ref={input}\n value={q}\n onChange={(e) => setQ(e.target.value)}\n onKeyDown={(e) => {\n if (folder && e.key === \"Backspace\" && !q) {\n // ⌫ in an empty search steps back to every block (Esc: the popup's capture above)\n e.preventDefault();\n e.stopPropagation();\n leave();\n } else if (catalogKey(e, flat, active, setActive, pick, !q)) e.preventDefault();\n }}\n role=\"combobox\"\n aria-expanded\n aria-controls={listId}\n aria-activedescendant={flat.length ? `${listId}-${active}` : undefined}\n aria-label={folder ? \"Search blocks\" : \"Search or pick a block\"}\n placeholder={folder ? \"Search blocks\" : \"Search or pick a block\"}\n className=\"h-full min-w-0 flex-1 bg-transparent text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3 focus-visible:shadow-none\"\n />\n </div>\n <CatalogList\n sections={sections}\n flat={flat}\n active={active}\n onHover={setActive}\n onPick={pick}\n empty={empty}\n emptyText={emptyText}\n noMatch={noMatch}\n detail={!!q || folder}\n listId={listId}\n className=\"min-h-0 flex-1\"\n />\n <Footer />\n </PopoverContent>\n );\n}\n\n/* ── Slash menu panel (positioned by the editor; never takes focus) ── */\nexport function SlashMenuPanel({\n query,\n folder = false,\n active,\n setActive,\n onPick,\n allows,\n maxHeight,\n}: {\n /** the room the editor found for the menu (collision-aware); the list scrolls inside it */\n maxHeight?: number;\n query: string;\n /** the More components view (the editor keeps it with the rest of the slash state) */\n folder?: boolean;\n active: number;\n setActive: (i: number) => void;\n onPick: (it: CatalogItem) => void;\n allows: (f: RichTextFeature) => boolean;\n}) {\n const listId = React.useId();\n const { sections, flat, empty, emptyText, noMatch } = useCatalog(query, allows, folder);\n return (\n <div\n data-kit-scope=\"\"\n className=\"glass-strong flex w-[320px] flex-col overflow-hidden rounded-kit-xl border border-kit-line\"\n style={maxHeight ? { maxHeight } : undefined}\n onMouseDown={(e) => e.preventDefault()}\n >\n <div className=\"flex h-8 shrink-0 items-center gap-2 border-b border-kit-line px-3 text-kit-sm\">\n <span className={cn(\"flex-1 truncate\", query ? \"text-kit-fg\" : \"text-kit-fg-3\")}>{query ? `${folder ? \"More blocks · \" : \"\"}/${query}` : folder ? \"More blocks\" : \"Type to search\"}</span>\n <kbd data-hint=\"shortcuts\" className=\"font-kit-sans text-kit-2xs text-kit-fg-3\">\n esc\n </kbd>\n </div>\n <CatalogList\n sections={sections}\n flat={flat}\n active={active}\n onHover={setActive}\n onPick={onPick}\n empty={empty}\n emptyText={emptyText}\n noMatch={noMatch}\n detail={!!query || folder}\n listId={listId}\n className=\"max-h-[300px] min-h-0 flex-1\"\n />\n <Footer />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAM,KAAK,MAAgD,oBAAC,GAAD,EAAG,QAAQ,IAAM,CAAA;AAE5E,IAAM,QAAQ,SAA+B,KAAK,KAAK,CAAC,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I;IACF;IACT,QAAQ,CAAC,CAAC,SAAS;IACX;IACR,WAAU;GACX,CAAA;GACD,oBAAC,QAAD,CAAS,CAAA;EACN;;AAET"}
@@ -847,7 +847,7 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
847
847
  }
848
848
  if (r.startContainer !== slash.node || r.startOffset <= slash.offset || slash.node.data[slash.offset] !== "/") return setSlash(null);
849
849
  const q = slash.node.data.slice(slash.offset + 1, r.startOffset);
850
- if (/\s/.test(q) || q.length > 24) return setSlash(null);
850
+ if (/^\s|\s\s/.test(q) || q.length > 24) return setSlash(null);
851
851
  setSlash({
852
852
  ...slash,
853
853
  query: q,