@bettercms-ai/kit 3.2.0 → 4.0.0

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.
package/dist/context.d.ts CHANGED
@@ -157,12 +157,6 @@ export interface KitServices {
157
157
  * `useBlockThreads(docId, key)`). Used while the host has no `env.onComment`; absent → SchemaForm `comments` counts.
158
158
  */
159
159
  useFieldCommentCount?: (docId: string, fieldKey: string) => number;
160
- /**
161
- * The host's own control for a type (a FieldRenderer arm in the dashboard), drawn for a stored value a kit control
162
- * hands off because it cannot carry it unchanged (rich text, LegacyFallback). Bare inside the kit FieldShell, which
163
- * owns the label row and the help; the box is tagged `data-kit-legacy`. Absent → the field says why in words.
164
- */
165
- LegacyControl?: React.ComponentType<ControlProps>;
166
160
  /**
167
161
  * HELD fields (kit 3.2.0), for a hold that depends on the stored value (a value an adapter cannot map back unchanged):
168
162
  * a reason → the field at `path` renders read-only in its shell with that reason (`data-kit-held`) and is never
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../src/context.tsx"],"sourcesContent":["/**\n * Kit runtime contexts (V2 HEAD 9829bf1 kit/context.tsx).\n *\n * - KitServices — pluggable app services (media library picker, upload sink, toast, AI rewrite, comment threads).\n * Hosts register theirs once (`registerKitServices`) or provide them (`KitServicesProvider`); the kit\n * never imports a feature. A service that is absent hides the surface that needs it.\n * - KitEnv — the editing environment a control renders in: variant (panel | document), doc identity, site\n * palette, permissions, presence, comments. Has safe defaults so a control can render alone.\n * - FormApi — present only inside <SchemaForm>: value, writes, navigation, issues, baselines, history.\n */\nimport * as React from \"react\";\nimport type { Cap } from \"./schema/sources\";\nimport type { FieldAccess, FieldPath, FieldSchema, Fieldset, TypeSchema } from \"./schema/types\";\nimport type { KitIssue } from \"./lib/validate\";\nimport type { ControlProps } from \"./types\";\nimport type { LinkTarget } from \"./controls/link\";\n\n/* ── Services ─────────────────────────────────────────────────────────── */\n/** The media asset a picker hands back (the host's media library row, narrowed to what the kit reads). */\nexport interface KitMediaAsset {\n id: string;\n url: string;\n name?: string;\n alt?: string;\n kind?: \"image\" | \"video\" | \"file\" | \"svg\";\n width?: number;\n height?: number;\n size?: number;\n}\nexport interface KitMediaPickerProps {\n open: boolean;\n onOpenChange: (v: boolean) => void;\n onPick: (assets: KitMediaAsset[]) => void;\n multiple?: boolean;\n accept?: (\"image\" | \"video\" | \"file\" | \"svg\")[];\n /** What the dialog is for, in the author's words (\"Replace icon\"). Absent: the host's own title. */\n title?: string;\n /** An icon's Remove, in the dialog's footer (its row has no room for one). Absent: no Remove. */\n onRemove?: () => void;\n /**\n * An icon's first tab: the icons already on this site, each with the value it is stored as. The field's own icon\n * leads, marked `current`: picking it closes the dialog with no write. Absent: no such tab.\n */\n icons?: KitSiteIcon[];\n onPickIcon?: (value: unknown) => void;\n}\n/** One icon already on the site (KitServices.useSiteIcons), as the picker's first tab draws it. */\nexport interface KitSiteIcon {\n url: string;\n value: unknown;\n assetId?: string;\n current?: boolean;\n}\nexport interface KitToastOptions {\n /** the second line under the message (V2 sonner `description`) */\n description?: string;\n action?: { label: string; onClick: () => void };\n duration?: number;\n icon?: React.ReactNode;\n}\n/** The host's toaster. The kit has no toast dependency (V2 re-exported sonner's). */\nexport interface KitToast {\n (message: string, opts?: KitToastOptions): void;\n success: (message: string, opts?: KitToastOptions) => void;\n}\n/** Rewrite with AI presets (V2 lib/ai.ts). The host's `aiRewrite` service produces the text. */\nexport type AiPreset = \"improve\" | \"shorter\" | \"longer\" | \"simplify\" | \"grammar\" | \"translate\";\nexport const AI_PRESETS: { id: AiPreset; label: string }[] = [\n { id: \"improve\", label: \"Improve\" },\n { id: \"shorter\", label: \"Shorter\" },\n { id: \"longer\", label: \"Longer\" },\n { id: \"simplify\", label: \"Simplify\" },\n { id: \"grammar\", label: \"Fix spelling & grammar\" },\n { id: \"translate\", label: \"Translate to Spanish\" },\n];\n/**\n * GAP-004: words selected in a rich-text field, to comment on (W3C TextQuoteSelector). `prefix` / `suffix` are up to 32\n * characters of the field's text right before and after them, so the host can find the right occurrence again.\n */\nexport interface KitCommentSelection {\n quote: string;\n prefix?: string;\n suffix?: string;\n}\n/** The in-place field comments popover (V2 FieldThreads over the comments store), drawn by the host. */\nexport interface KitFieldCommentsProps {\n docId: string;\n /** pathKey of the field (\"items.1.answer\") */\n fieldKey: string;\n label: string;\n /** the field's text, first 80 characters */\n quote?: string;\n /** GAP-004: set when the popover opened from a rich-text selection's Comment: the new thread is about these words */\n selection?: KitCommentSelection;\n onClose: () => void;\n /** \"Open in panel\": set when the host has a comments panel (`env.onComment`) */\n onOpenPanel?: () => void;\n}\n/** One field's ⋯ menu, as the host's extra items see it (KitServices.FieldMenuExtras). */\nexport interface KitFieldMenuExtrasProps {\n field: FieldSchema;\n path: FieldPath;\n /** the field is read-only for the lens: a host offers nothing that edits */\n readOnly: boolean;\n}\n/* The popover around FieldComments keeps itself open on Escape while focus is on an element marked `data-esc-owner`\n (V2 guardEscape): the composer marks its input so Escape clears or blurs the draft instead of losing it. */\nexport interface KitServices {\n /** The media library picker. */\n MediaPicker?: React.ComponentType<KitMediaPickerProps>;\n /** Called after an upload so the host can file the assets into its media library. */\n onUploaded?: (assets: KitMediaAsset[]) => void;\n /**\n * Image placements keep their edits BESIDE the url (`${name}Alt` · `${name}Focal` · `${name}Crop` ·\n * `${name}Decorative`) instead of turning the value into an object — the Visuals block model.\n */\n imageSiblings?: boolean;\n /** Real metadata for an image url (the host's media library), so captions never show placeholders. */\n resolveImage?: (url: string) => { name?: string; width?: number; height?: number; size?: number } | undefined;\n /** The host's full image editor (crop, rotate, focal, alt…), opened in place. */\n editImage?: (req: { docId: string; path: FieldPath; title: string }) => void;\n /**\n * RP-047: whether a rich-text body image at this address can be cropped (the crop is drawn by the media library's\n * image URL, so a picture from elsewhere keeps its whole frame). False → the crop is disabled and says why; the focal\n * point still applies. Absent → the crop is offered.\n */\n canCrop?: (url: string) => boolean;\n /** The project's forms for `reference: { to: [\"form\"] }` (the host's Forms store). */\n forms?: () => { id: string; title: string; subtitle: string }[];\n /** Toasts for Copy / Paste / Reset / AI (each with Undo). Absent → the action still runs, silently. */\n toast?: KitToast;\n /**\n * A slug's \"Save new address\" with \"Redirect it to the new address\" ticked (V2 SlugControl): the host files the\n * redirect from the old slug to the new one. Absent → no checkbox is offered, and the toast says the old address\n * will return \"Not found\", which is what happens. A rejection is named in a toast (the new slug is already saved).\n */\n redirectSlug?: (from: string, to: string) => void | Promise<void>;\n /**\n * A slug's \"Save new address\": the host writes the new address before any redirect is filed. Absent → the form's\n * value is the save (V2). A rejection is named in a toast and the old-address box stays for another try.\n */\n saveSlug?: (to: string) => Promise<void>;\n /** Rewrite with AI. Absent → the ⋯ menu offers no rewrite. `attempt` counts \"Try again\" presses. */\n aiRewrite?: (text: string, preset: AiPreset, attempt: number) => string | Promise<string>;\n /** In-place field comments. Absent and no `env.onComment` → the field shows no add-comment control. */\n FieldComments?: React.ComponentType<KitFieldCommentsProps>;\n /**\n * A React hook: open (unresolved) threads on one field, read from the same store FieldComments draws (V2 counted\n * `useBlockThreads(docId, key)`). Used while the host has no `env.onComment`; absent → SchemaForm `comments` counts.\n */\n useFieldCommentCount?: (docId: string, fieldKey: string) => number;\n /**\n * The host's own control for a type (a FieldRenderer arm in the dashboard), drawn for a stored value a kit control\n * hands off because it cannot carry it unchanged (rich text, LegacyFallback). Bare inside the kit FieldShell, which\n * owns the label row and the help; the box is tagged `data-kit-legacy`. Absent → the field says why in words.\n */\n LegacyControl?: React.ComponentType<ControlProps>;\n /**\n * HELD fields (kit 3.2.0), for a hold that depends on the stored value (a value an adapter cannot map back unchanged):\n * a reason → the field at `path` renders read-only in its shell with that reason (`data-kit-held`) and is never\n * written; null/undefined → the field edits as usual. A schema-level hold is `FieldSchema.held`. Called on render, so\n * keep it cheap and pure.\n */\n heldReason?: (at: { field: FieldSchema; path: FieldPath; value: unknown }) => string | null | undefined;\n /**\n * The host's own items for a field's ⋯ menu (the entry editor's Move up · Move down · Move to panel), drawn after\n * History and before Rewrite with AI. It renders kit `MenuItem`s, with its own leading `MenuSeparator`, or null.\n * Absent → the menu is exactly V2's.\n */\n FieldMenuExtras?: React.ComponentType<KitFieldMenuExtrasProps>;\n /**\n * A React HOOK: the project's pages and CMS items a link can point at (controls/link.tsx). The host passes the same\n * function for the life of the form (it is called on every render of a link control). Absent → the link picker says\n * page search isn't available and takes a typed path. `error` is a whole sentence naming what failed (\"Pages couldn't\n * be loaded: …\", \"Items from Blog couldn't be loaded: …\"); the picker shows it under whatever did load.\n */\n useLinkTargets?: () => { targets: LinkTarget[]; loading?: boolean; error?: string };\n /**\n * A React HOOK: every SVG the site already uses (its pages, header and footer, the library's SVGs), for an icon's\n * picker. The host passes the same function for the life of the form. Absent → the picker has no site tab.\n */\n useSiteIcons?: () => KitSiteIcon[];\n /**\n * The entries a rich text's related posts or author bio block shows (kit-richtext-blocks-plan.md RT8). `ids`: the\n * hand-picked entries (an author bio's one author, related posts in hand-picked mode), answered in that order with\n * any the host cannot find left out. `query`: related posts chosen for the reader (owner 2026-10-24: `topic` = same\n * tags or category, `newest` = the collection newest first; `count` of them, `excludeId` the entry being edited).\n * Absent → the blocks show their empty state; a rejection's message is shown as said.\n */\n resolveRichTextRefs?: (req: KitRichTextRefRequest) => Promise<KitRichTextRef[]>;\n}\n\n/** What a related posts or author bio block asks the host for (KitServices.resolveRichTextRefs). */\nexport interface KitRichTextRefRequest {\n kind: \"relatedPosts\" | \"authorBio\";\n ids?: string[];\n query?: { collection?: string; mode: \"topic\" | \"newest\"; count: number; excludeId?: string };\n}\n/**\n * One resolved entry, as the block draws it: a post card (title, cover, category) or an author (avatar, title as name, bio).\n * A post with no `href` has no public page (its collection has no detail route); Related posts names that under its cards.\n */\nexport interface KitRichTextRef {\n id: string;\n title: string;\n href?: string;\n cover?: string;\n category?: string;\n avatar?: string;\n bio?: string;\n}\n\n/**\n * A React HOOK over KitServices.resolveRichTextRefs: `unavailable` when the host offers no resolver (draw the empty\n * state), else `loading`, then `items` or `error` (a sentence). `req` null asks nothing (a block with nothing picked).\n */\nexport function useRichTextRefs(req: KitRichTextRefRequest | null): { items: KitRichTextRef[]; loading: boolean; error?: string; unavailable: boolean } {\n const { resolveRichTextRefs } = useKitServices();\n const key = req ? JSON.stringify(req) : \"\";\n const [state, setState] = React.useState<{ key: string; items: KitRichTextRef[]; error?: string } | null>(null);\n React.useEffect(() => {\n if (!resolveRichTextRefs || !key) return;\n let live = true;\n resolveRichTextRefs(JSON.parse(key) as KitRichTextRefRequest).then(\n (items) => live && setState({ key, items }),\n (e: unknown) => live && setState({ key, items: [], error: e instanceof Error ? e.message : String(e) }),\n );\n return () => void (live = false);\n }, [resolveRichTextRefs, key]);\n if (!resolveRichTextRefs) return { items: [], loading: false, unavailable: true };\n if (!key) return { items: [], loading: false, unavailable: false };\n const done = state?.key === key ? state : null;\n return { items: done?.items ?? [], loading: !done, error: done?.error, unavailable: false };\n}\nlet registry: KitServices = {};\nconst listeners = new Set<() => void>();\n/** Register app services once at module load (e.g. the Content feature registers its media library). */\nexport function registerKitServices(s: KitServices) {\n registry = { ...registry, ...s };\n listeners.forEach((l) => l());\n}\nconst ServicesCtx = React.createContext<KitServices | null>(null);\nexport function KitServicesProvider({ value, children }: { value: KitServices; children: React.ReactNode }) {\n return <ServicesCtx.Provider value={value}>{children}</ServicesCtx.Provider>;\n}\nexport function useKitServices(): KitServices {\n const local = React.useContext(ServicesCtx);\n const global = React.useSyncExternalStore(\n (cb) => {\n listeners.add(cb);\n return () => listeners.delete(cb);\n },\n () => registry,\n () => registry,\n );\n return local ? { ...global, ...local } : global;\n}\n\n/** A host header element a top-level field (by path key) renders its actions into, instead of a label row. */\nexport const FieldHeaderSlot = React.createContext<{ key: string; el: HTMLElement } | null>(null);\n\n/* ── Environment ──────────────────────────────────────────────────────── */\nexport type KitVariant = \"panel\" | \"document\";\nexport interface KitPeer {\n id?: string;\n name: string;\n avatar?: string;\n /** presence colour (avatar ring, field border, caret flag) */\n color?: string;\n /** \"editing\" (soft lock + border) or \"viewing\" */\n status?: \"editing\" | \"viewing\";\n}\nexport interface Swatch {\n name: string;\n value: string;\n token?: string;\n}\n\n/** V2's demo site palette (Caldera). Hosts pass the project's brand palette through `env.palette`. */\nexport const SITE_PALETTE: Swatch[] = [\n { name: \"Ember\", value: \"#E0663B\", token: \"brand.ember\" },\n { name: \"Ochre\", value: \"#D97706\", token: \"brand.ochre\" },\n { name: \"Moss\", value: \"#4F6B4A\", token: \"brand.moss\" },\n { name: \"Lake\", value: \"#2563EB\", token: \"accent.lake\" },\n { name: \"Dusk\", value: \"#7C3AED\", token: \"accent.dusk\" },\n { name: \"Berry\", value: \"#DB2777\", token: \"accent.berry\" },\n { name: \"Char\", value: \"#1E1B18\", token: \"neutral.900\" },\n { name: \"Slate\", value: \"#4B5563\", token: \"neutral.600\" },\n { name: \"Bone\", value: \"#E7E0D6\", token: \"neutral.200\" },\n { name: \"Paper\", value: \"#F6F1EA\", token: \"neutral.50\" },\n];\n\nexport interface KitEnv {\n variant: KitVariant;\n /** Identity of the document/block being edited (rich-text sync, comments, history). */\n docId: string;\n /** The document's title — slug generation. */\n docTitle?: string;\n /** Public URL prefix for slug previews, e.g. \"caldera.bettercms.site/journal/\". */\n urlPrefix?: string;\n /** The document has been published (slug changes warn about the old address). */\n isPublished?: boolean;\n /**\n * The form's slug is the document's ADDRESS (a page's or an entry's URL). Only then does a changed slug on a published\n * document say the old address will stop working and offer the redirect. A slug prop or a key is not an address, so\n * it gets no such box (V2 draws it on document hosts only: its component-prop forms pass no published state).\n */\n slugIsAddress?: boolean;\n palette: Swatch[];\n /** The whole form is read-only for the lens (the host's content.edit rule, a generated twin…). */\n readOnly: boolean;\n /**\n * D58: the host's access check for the lens (`useCan` at the host). The kit never imports the store; it asks this for\n * field-level `access` and for developer surfaces (field keys, IDs, API names: `schema.view` or `api.view`).\n * Hosts that omit it (staff tools, demos) get allow-all.\n */\n can: (cap: Cap) => boolean;\n /** pathKey → teammates in that field */\n presence: Record<string, KitPeer[]>;\n /** pathKey → open comment threads */\n comments: Record<string, number>;\n /** Host comment panel. When absent, field comments live in the in-place popover only. */\n /** `quote`: the words selected in a rich text field when the comment came from its toolbar */\n onComment?: (path: FieldPath, field: FieldSchema, quote?: string) => void;\n /** The whole form is a global block (\"Navigation\") — every field is synced. */\n syncedFrom?: string;\n /** \"Open {title}\" on a reference card: the host edits the referenced entry in place (stacked panel). */\n onOpenReference?: (ref: { collectionId: string; entryId: string; title: string }) => void;\n /** CPO D39: \"inline\" (default) shows help under the label; \"tooltip\" moves it behind the ⓘ — for dense hosts (grid cells, popovers). */\n helpDisplay?: \"inline\" | \"tooltip\";\n /** D61 Review changes: the host's change markers, present only while its History panel is open. */\n review?: KitReview;\n /** D61 field ⋯ › History: the host opens its one History panel on this field. Absent = no History item. */\n onFieldHistory?: (path: FieldPath, field: FieldSchema) => void;\n /**\n * \"quiet\": a meta-form, like the schema editor's field settings (founder call, 2026-10-05). No comment, ⋯ or per-field\n * undo on the fields, and an on/off field is a label-left row with its switch on the right (the inspector's PRow), not a\n * switch card. \"preview\": the same chrome-free fields, controls exactly as editors see them (a schema preview, where a\n * comment would land on a sample, never a real document). Default \"full\".\n */\n fieldChrome?: \"full\" | \"preview\" | \"quiet\";\n /**\n * A host's own control for one field, by its path key (\"type\", \"options\"), drawn inside the usual shell. The schema\n * editor's field settings plug their Type, Options, Key and Show this field controls in here. Absent = kit controls only.\n */\n controls?: Record<string, React.ComponentType<ControlProps>>;\n /**\n * A collapsed fieldset's summary as chips, from the host (the schema editor's field settings: \"Required\", \"3 options\").\n * `undefined` falls back to the kit's own one-line summary. Keep it stable (a new function re-renders the form).\n */\n sectionSummary?: (set: Fieldset, value: Record<string, unknown>) => string[] | undefined;\n}\n\n/**\n * D61 Review changes, as the kit sees it. The host owns the history model; the kit only asks, per field path, whether\n * it changed in the range, and renders the host's marker (a 2px bar in the author's colour at the field's left edge,\n * with its hover card) where the at-rest \"changed\" dot would be.\n */\nexport interface KitReview {\n /** changes at or inside this field in the range (0 = unchanged) */\n count: (path: FieldPath) => number;\n /** the presence colour of whoever changed it last (list rows draw their own bar) */\n color: (path: FieldPath) => string | undefined;\n /** the host's change bar and hover card for a changed field (null when unchanged) */\n bar: (path: FieldPath, field: FieldSchema) => React.ReactNode;\n /** Show only changes: unchanged fields fold into one quiet line each run */\n onlyChanges: boolean;\n}\n\n/** The title of the fieldset a field sits in (null outside one). A quiet meta-form drops a field label that only repeats\n * its section's title (\"Options\" › \"Options\"): the section heading names it. */\nexport const KitSectionTitle = React.createContext<string | null>(null);\n/**\n * D66: the host's address row under a slug field (production URL, who serves it, the preview, live state). The host\n * knows the site's hosting; the kit only asks it to render the row for the slug being typed. Absent = the kit's own row.\n */\nexport const KitAddressContext = React.createContext<((slug: string) => React.ReactNode) | null>(null);\nexport const DEFAULT_ENV: KitEnv = {\n variant: \"panel\",\n docId: \"kit\",\n palette: [],\n readOnly: false,\n can: () => true,\n presence: {},\n comments: {},\n};\nconst EnvCtx = React.createContext<KitEnv>(DEFAULT_ENV);\n\n/** D58 field access: fields in the `seo` group default to `{ edit: \"seo.edit\" }`. */\nexport const fieldAccessOf = (field: FieldSchema): FieldAccess | undefined => field.access ?? (field.group === \"seo\" ? { edit: \"seo.edit\" } : undefined);\n\n/**\n * One field for the lens: hidden (no `view`), read-only (plain text: no `edit`, the field is `readOnly`, or the whole form\n * is read-only and the field has no edit cap of its own), or editable. An explicit `edit` cap wins over the form's\n * read-only rule, so an SEO specialist edits SEO fields inside a form they can't otherwise change.\n */\nexport function resolveFieldAccess(field: FieldSchema, env: Pick<KitEnv, \"can\" | \"readOnly\">): { hidden: boolean; readOnly: boolean } {\n const a = fieldAccessOf(field);\n if (a?.view && !env.can(a.view)) return { hidden: true, readOnly: true };\n if (field.readOnly === true) return { hidden: false, readOnly: true };\n if (a?.edit) return { hidden: false, readOnly: !env.can(a.edit) };\n return { hidden: false, readOnly: env.readOnly };\n}\n/** Drop the fields the lens can't `view` (recursively), so they are neither rendered nor validated. Same object back when\n * nothing is hidden. Values of dropped fields stay in the document untouched. */\nexport function visibleFields(fields: FieldSchema[], can: KitEnv[\"can\"]): FieldSchema[] {\n let changed = false;\n const out: FieldSchema[] = [];\n for (const f of fields) {\n const a = fieldAccessOf(f);\n if (a?.view && !can(a.view)) {\n changed = true;\n continue;\n }\n let g = f;\n if (f.fields) {\n const n = visibleFields(f.fields, can);\n if (n !== f.fields) g = { ...g, fields: n };\n }\n if (Array.isArray(f.of)) {\n const n = visibleFields(f.of, can);\n if (n !== f.of) g = { ...g, of: n };\n }\n if (f.slotSettings) {\n const n = visibleFields(f.slotSettings, can);\n if (n !== f.slotSettings) g = { ...g, slotSettings: n };\n }\n if (g !== f) changed = true;\n out.push(g);\n }\n return changed ? out : fields;\n}\nexport function visibleSchema(schema: TypeSchema, can: KitEnv[\"can\"]): TypeSchema {\n const fields = visibleFields(schema.fields, can);\n return fields === schema.fields ? schema : { ...schema, fields };\n}\n\n/** Developer surfaces (field keys, API names, IDs): `schema.view` or `api.view`. */\nexport const seesDevSurfaces = (env: Pick<KitEnv, \"can\">) => env.can(\"schema.view\") || env.can(\"api.view\");\nexport const KitEnvProvider = EnvCtx.Provider;\nexport const useKitEnv = () => React.useContext(EnvCtx);\n\n/* ── Form runtime (inside <SchemaForm>) ──────────────────────────────── */\nexport interface HistoryEntry {\n value: unknown;\n at: number;\n by: string;\n label?: string;\n}\nexport interface FormApi {\n schema: TypeSchema;\n value: Record<string, unknown>;\n /** write a value; `record: false` skips the field undo/history stack (e.g. programmatic sync) */\n setAt: (path: FieldPath, v: unknown, opts?: { record?: boolean; label?: string }) => void;\n getAt: (path: FieldPath) => unknown;\n /** value when the form mounted (field undo baseline) */\n baselineAt: (path: FieldPath) => unknown;\n /** published value (changed dot, Reset to published); undefined when never published */\n publishedAt: (path: FieldPath) => unknown;\n hasPublished: boolean;\n /** component instances (CPO D28): top-level fields inherit from a component unless overridden */\n inherited?: { from: string; isOverridden: (key: string) => boolean; reset: (key: string) => void };\n /** the current navigation path (drill-in stack) */\n path: FieldPath;\n navigate: (path: FieldPath) => void;\n /** the form draws frames for a non-root path. False while SchemaForm renders only the root frame: History and\n * drill-in rows hide or go inert instead of navigating to a path nothing shows (no silent no-op). */\n canNavigate: boolean;\n resolveSchema?: (blockType: string) => TypeSchema | undefined;\n /** blocks offered by \"+ Add block\" in slots (filtered by each slot's allow list) */\n blockLibrary?: TypeSchema[];\n /** all issues by pathKey */\n issues: Map<string, KitIssue>;\n /** the issue shown for a key (rules on blur, required after blur or a publish attempt) */\n visibleIssue: (key: string) => KitIssue | undefined;\n /** visible issues under a path prefix (rollup dots on rows, crumbs and tabs) */\n rollup: (prefix: FieldPath) => { errors: number; warnings: number };\n touch: (key: string) => void;\n showAllErrors: boolean;\n /** per-field undo (Undo last change to {label}) */\n canUndo: (key: string) => boolean;\n undo: (key: string) => void;\n /** versions of a field this session (newest first) */\n history: (key: string) => HistoryEntry[];\n /** the last change to this field came from AI (⋯ shows \"Undo AI change\") */\n aiKeys: Set<string>;\n markAi: (key: string, on: boolean) => void;\n /** remembered UI state per frame (selected group tab, open fieldsets) */\n memory: Map<string, unknown>;\n}\nconst FormCtx = React.createContext<FormApi | null>(null);\nexport const FormProvider = FormCtx.Provider;\nexport const useForm = () => React.useContext(FormCtx);\n"],"mappings":";;;;;;;;;;;;;AAmEA,IAAa,aAAgD;CAC3D;EAAE,IAAI;EAAW,OAAO;CAAU;CAClC;EAAE,IAAI;EAAW,OAAO;CAAU;CAClC;EAAE,IAAI;EAAU,OAAO;CAAS;CAChC;EAAE,IAAI;EAAY,OAAO;CAAW;CACpC;EAAE,IAAI;EAAW,OAAO;CAAyB;CACjD;EAAE,IAAI;EAAa,OAAO;CAAuB;AACnD;;;;;AA8IA,SAAgB,gBAAgB,KAAwH;CACtJ,MAAM,EAAE,wBAAwB,eAAe;CAC/C,MAAM,MAAM,MAAM,KAAK,UAAU,GAAG,IAAI;CACxC,MAAM,CAAC,OAAO,YAAY,MAAM,SAA0E,IAAI;CAC9G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ent":["/**\n * Kit runtime contexts (V2 HEAD 9829bf1 kit/context.tsx).\n *\n * - KitServices — pluggable app services (media library picker, upload sink, toast, AI rewrite, comment threads).\n * Hosts register theirs once (`registerKitServices`) or provide them (`KitServicesProvider`); the kit\n * never imports a feature. A service that is absent hides the surface that needs it.\n * - KitEnv — the editing environment a control renders in: variant (panel | document), doc identity, site\n * palette, permissions, presence, comments. Has safe defaults so a control can render alone.\n * - FormApi — present only inside <SchemaForm>: value, writes, navigation, issues, baselines, history.\n */\nimport * as React from \"react\";\nimport type { Cap } from \"./schema/sources\";\nimport type { FieldAccess, FieldPath, FieldSchema, Fieldset, TypeSchema } from \"./schema/types\";\nimport type { KitIssue } from \"./lib/validate\";\nimport type { ControlProps } from \"./types\";\nimport type { LinkTarget } from \"./controls/link\";\n\n/* ── Services ─────────────────────────────────────────────────────────── */\n/** The media asset a picker hands back (the host's media library row, narrowed to what the kit reads). */\nexport interface KitMediaAsset {\n id: string;\n url: string;\n name?: string;\n alt?: string;\n kind?: \"image\" | \"video\" | \"file\" | \"svg\";\n width?: number;\n height?: number;\n size?: number;\n}\nexport interface KitMediaPickerProps {\n open: boolean;\n onOpenChange: (v: boolean) => void;\n onPick: (assets: KitMediaAsset[]) => void;\n multiple?: boolean;\n accept?: (\"image\" | \"video\" | \"file\" | \"svg\")[];\n /** What the dialog is for, in the author's words (\"Replace icon\"). Absent: the host's own title. */\n title?: string;\n /** An icon's Remove, in the dialog's footer (its row has no room for one). Absent: no Remove. */\n onRemove?: () => void;\n /**\n * An icon's first tab: the icons already on this site, each with the value it is stored as. The field's own icon\n * leads, marked `current`: picking it closes the dialog with no write. Absent: no such tab.\n */\n icons?: KitSiteIcon[];\n onPickIcon?: (value: unknown) => void;\n}\n/** One icon already on the site (KitServices.useSiteIcons), as the picker's first tab draws it. */\nexport interface KitSiteIcon {\n url: string;\n value: unknown;\n assetId?: string;\n current?: boolean;\n}\nexport interface KitToastOptions {\n /** the second line under the message (V2 sonner `description`) */\n description?: string;\n action?: { label: string; onClick: () => void };\n duration?: number;\n icon?: React.ReactNode;\n}\n/** The host's toaster. The kit has no toast dependency (V2 re-exported sonner's). */\nexport interface KitToast {\n (message: string, opts?: KitToastOptions): void;\n success: (message: string, opts?: KitToastOptions) => void;\n}\n/** Rewrite with AI presets (V2 lib/ai.ts). The host's `aiRewrite` service produces the text. */\nexport type AiPreset = \"improve\" | \"shorter\" | \"longer\" | \"simplify\" | \"grammar\" | \"translate\";\nexport const AI_PRESETS: { id: AiPreset; label: string }[] = [\n { id: \"improve\", label: \"Improve\" },\n { id: \"shorter\", label: \"Shorter\" },\n { id: \"longer\", label: \"Longer\" },\n { id: \"simplify\", label: \"Simplify\" },\n { id: \"grammar\", label: \"Fix spelling & grammar\" },\n { id: \"translate\", label: \"Translate to Spanish\" },\n];\n/**\n * GAP-004: words selected in a rich-text field, to comment on (W3C TextQuoteSelector). `prefix` / `suffix` are up to 32\n * characters of the field's text right before and after them, so the host can find the right occurrence again.\n */\nexport interface KitCommentSelection {\n quote: string;\n prefix?: string;\n suffix?: string;\n}\n/** The in-place field comments popover (V2 FieldThreads over the comments store), drawn by the host. */\nexport interface KitFieldCommentsProps {\n docId: string;\n /** pathKey of the field (\"items.1.answer\") */\n fieldKey: string;\n label: string;\n /** the field's text, first 80 characters */\n quote?: string;\n /** GAP-004: set when the popover opened from a rich-text selection's Comment: the new thread is about these words */\n selection?: KitCommentSelection;\n onClose: () => void;\n /** \"Open in panel\": set when the host has a comments panel (`env.onComment`) */\n onOpenPanel?: () => void;\n}\n/** One field's ⋯ menu, as the host's extra items see it (KitServices.FieldMenuExtras). */\nexport interface KitFieldMenuExtrasProps {\n field: FieldSchema;\n path: FieldPath;\n /** the field is read-only for the lens: a host offers nothing that edits */\n readOnly: boolean;\n}\n/* The popover around FieldComments keeps itself open on Escape while focus is on an element marked `data-esc-owner`\n (V2 guardEscape): the composer marks its input so Escape clears or blurs the draft instead of losing it. */\nexport interface KitServices {\n /** The media library picker. */\n MediaPicker?: React.ComponentType<KitMediaPickerProps>;\n /** Called after an upload so the host can file the assets into its media library. */\n onUploaded?: (assets: KitMediaAsset[]) => void;\n /**\n * Image placements keep their edits BESIDE the url (`${name}Alt` · `${name}Focal` · `${name}Crop` ·\n * `${name}Decorative`) instead of turning the value into an object — the Visuals block model.\n */\n imageSiblings?: boolean;\n /** Real metadata for an image url (the host's media library), so captions never show placeholders. */\n resolveImage?: (url: string) => { name?: string; width?: number; height?: number; size?: number } | undefined;\n /** The host's full image editor (crop, rotate, focal, alt…), opened in place. */\n editImage?: (req: { docId: string; path: FieldPath; title: string }) => void;\n /**\n * RP-047: whether a rich-text body image at this address can be cropped (the crop is drawn by the media library's\n * image URL, so a picture from elsewhere keeps its whole frame). False → the crop is disabled and says why; the focal\n * point still applies. Absent → the crop is offered.\n */\n canCrop?: (url: string) => boolean;\n /** The project's forms for `reference: { to: [\"form\"] }` (the host's Forms store). */\n forms?: () => { id: string; title: string; subtitle: string }[];\n /** Toasts for Copy / Paste / Reset / AI (each with Undo). Absent → the action still runs, silently. */\n toast?: KitToast;\n /**\n * A slug's \"Save new address\" with \"Redirect it to the new address\" ticked (V2 SlugControl): the host files the\n * redirect from the old slug to the new one. Absent → no checkbox is offered, and the toast says the old address\n * will return \"Not found\", which is what happens. A rejection is named in a toast (the new slug is already saved).\n */\n redirectSlug?: (from: string, to: string) => void | Promise<void>;\n /**\n * A slug's \"Save new address\": the host writes the new address before any redirect is filed. Absent → the form's\n * value is the save (V2). A rejection is named in a toast and the old-address box stays for another try.\n */\n saveSlug?: (to: string) => Promise<void>;\n /** Rewrite with AI. Absent → the ⋯ menu offers no rewrite. `attempt` counts \"Try again\" presses. */\n aiRewrite?: (text: string, preset: AiPreset, attempt: number) => string | Promise<string>;\n /** In-place field comments. Absent and no `env.onComment` → the field shows no add-comment control. */\n FieldComments?: React.ComponentType<KitFieldCommentsProps>;\n /**\n * A React hook: open (unresolved) threads on one field, read from the same store FieldComments draws (V2 counted\n * `useBlockThreads(docId, key)`). Used while the host has no `env.onComment`; absent → SchemaForm `comments` counts.\n */\n useFieldCommentCount?: (docId: string, fieldKey: string) => number;\n /**\n * HELD fields (kit 3.2.0), for a hold that depends on the stored value (a value an adapter cannot map back unchanged):\n * a reason → the field at `path` renders read-only in its shell with that reason (`data-kit-held`) and is never\n * written; null/undefined → the field edits as usual. A schema-level hold is `FieldSchema.held`. Called on render, so\n * keep it cheap and pure.\n */\n heldReason?: (at: { field: FieldSchema; path: FieldPath; value: unknown }) => string | null | undefined;\n /**\n * The host's own items for a field's ⋯ menu (the entry editor's Move up · Move down · Move to panel), drawn after\n * History and before Rewrite with AI. It renders kit `MenuItem`s, with its own leading `MenuSeparator`, or null.\n * Absent → the menu is exactly V2's.\n */\n FieldMenuExtras?: React.ComponentType<KitFieldMenuExtrasProps>;\n /**\n * A React HOOK: the project's pages and CMS items a link can point at (controls/link.tsx). The host passes the same\n * function for the life of the form (it is called on every render of a link control). Absent → the link picker says\n * page search isn't available and takes a typed path. `error` is a whole sentence naming what failed (\"Pages couldn't\n * be loaded: …\", \"Items from Blog couldn't be loaded: …\"); the picker shows it under whatever did load.\n */\n useLinkTargets?: () => { targets: LinkTarget[]; loading?: boolean; error?: string };\n /**\n * A React HOOK: every SVG the site already uses (its pages, header and footer, the library's SVGs), for an icon's\n * picker. The host passes the same function for the life of the form. Absent → the picker has no site tab.\n */\n useSiteIcons?: () => KitSiteIcon[];\n /**\n * The entries a rich text's related posts or author bio block shows (kit-richtext-blocks-plan.md RT8). `ids`: the\n * hand-picked entries (an author bio's one author, related posts in hand-picked mode), answered in that order with\n * any the host cannot find left out. `query`: related posts chosen for the reader (owner 2026-10-24: `topic` = same\n * tags or category, `newest` = the collection newest first; `count` of them, `excludeId` the entry being edited).\n * Absent → the blocks show their empty state; a rejection's message is shown as said.\n */\n resolveRichTextRefs?: (req: KitRichTextRefRequest) => Promise<KitRichTextRef[]>;\n}\n\n/** What a related posts or author bio block asks the host for (KitServices.resolveRichTextRefs). */\nexport interface KitRichTextRefRequest {\n kind: \"relatedPosts\" | \"authorBio\";\n ids?: string[];\n query?: { collection?: string; mode: \"topic\" | \"newest\"; count: number; excludeId?: string };\n}\n/**\n * One resolved entry, as the block draws it: a post card (title, cover, category) or an author (avatar, title as name, bio).\n * A post with no `href` has no public page (its collection has no detail route); Related posts names that under its cards.\n */\nexport interface KitRichTextRef {\n id: string;\n title: string;\n href?: string;\n cover?: string;\n category?: string;\n avatar?: string;\n bio?: string;\n}\n\n/**\n * A React HOOK over KitServices.resolveRichTextRefs: `unavailable` when the host offers no resolver (draw the empty\n * state), else `loading`, then `items` or `error` (a sentence). `req` null asks nothing (a block with nothing picked).\n */\nexport function useRichTextRefs(req: KitRichTextRefRequest | null): { items: KitRichTextRef[]; loading: boolean; error?: string; unavailable: boolean } {\n const { resolveRichTextRefs } = useKitServices();\n const key = req ? JSON.stringify(req) : \"\";\n const [state, setState] = React.useState<{ key: string; items: KitRichTextRef[]; error?: string } | null>(null);\n React.useEffect(() => {\n if (!resolveRichTextRefs || !key) return;\n let live = true;\n resolveRichTextRefs(JSON.parse(key) as KitRichTextRefRequest).then(\n (items) => live && setState({ key, items }),\n (e: unknown) => live && setState({ key, items: [], error: e instanceof Error ? e.message : String(e) }),\n );\n return () => void (live = false);\n }, [resolveRichTextRefs, key]);\n if (!resolveRichTextRefs) return { items: [], loading: false, unavailable: true };\n if (!key) return { items: [], loading: false, unavailable: false };\n const done = state?.key === key ? state : null;\n return { items: done?.items ?? [], loading: !done, error: done?.error, unavailable: false };\n}\nlet registry: KitServices = {};\nconst listeners = new Set<() => void>();\n/** Register app services once at module load (e.g. the Content feature registers its media library). */\nexport function registerKitServices(s: KitServices) {\n registry = { ...registry, ...s };\n listeners.forEach((l) => l());\n}\nconst ServicesCtx = React.createContext<KitServices | null>(null);\nexport function KitServicesProvider({ value, children }: { value: KitServices; children: React.ReactNode }) {\n return <ServicesCtx.Provider value={value}>{children}</ServicesCtx.Provider>;\n}\nexport function useKitServices(): KitServices {\n const local = React.useContext(ServicesCtx);\n const global = React.useSyncExternalStore(\n (cb) => {\n listeners.add(cb);\n return () => listeners.delete(cb);\n },\n () => registry,\n () => registry,\n );\n return local ? { ...global, ...local } : global;\n}\n\n/** A host header element a top-level field (by path key) renders its actions into, instead of a label row. */\nexport const FieldHeaderSlot = React.createContext<{ key: string; el: HTMLElement } | null>(null);\n\n/* ── Environment ──────────────────────────────────────────────────────── */\nexport type KitVariant = \"panel\" | \"document\";\nexport interface KitPeer {\n id?: string;\n name: string;\n avatar?: string;\n /** presence colour (avatar ring, field border, caret flag) */\n color?: string;\n /** \"editing\" (soft lock + border) or \"viewing\" */\n status?: \"editing\" | \"viewing\";\n}\nexport interface Swatch {\n name: string;\n value: string;\n token?: string;\n}\n\n/** V2's demo site palette (Caldera). Hosts pass the project's brand palette through `env.palette`. */\nexport const SITE_PALETTE: Swatch[] = [\n { name: \"Ember\", value: \"#E0663B\", token: \"brand.ember\" },\n { name: \"Ochre\", value: \"#D97706\", token: \"brand.ochre\" },\n { name: \"Moss\", value: \"#4F6B4A\", token: \"brand.moss\" },\n { name: \"Lake\", value: \"#2563EB\", token: \"accent.lake\" },\n { name: \"Dusk\", value: \"#7C3AED\", token: \"accent.dusk\" },\n { name: \"Berry\", value: \"#DB2777\", token: \"accent.berry\" },\n { name: \"Char\", value: \"#1E1B18\", token: \"neutral.900\" },\n { name: \"Slate\", value: \"#4B5563\", token: \"neutral.600\" },\n { name: \"Bone\", value: \"#E7E0D6\", token: \"neutral.200\" },\n { name: \"Paper\", value: \"#F6F1EA\", token: \"neutral.50\" },\n];\n\nexport interface KitEnv {\n variant: KitVariant;\n /** Identity of the document/block being edited (rich-text sync, comments, history). */\n docId: string;\n /** The document's title — slug generation. */\n docTitle?: string;\n /** Public URL prefix for slug previews, e.g. \"caldera.bettercms.site/journal/\". */\n urlPrefix?: string;\n /** The document has been published (slug changes warn about the old address). */\n isPublished?: boolean;\n /**\n * The form's slug is the document's ADDRESS (a page's or an entry's URL). Only then does a changed slug on a published\n * document say the old address will stop working and offer the redirect. A slug prop or a key is not an address, so\n * it gets no such box (V2 draws it on document hosts only: its component-prop forms pass no published state).\n */\n slugIsAddress?: boolean;\n palette: Swatch[];\n /** The whole form is read-only for the lens (the host's content.edit rule, a generated twin…). */\n readOnly: boolean;\n /**\n * D58: the host's access check for the lens (`useCan` at the host). The kit never imports the store; it asks this for\n * field-level `access` and for developer surfaces (field keys, IDs, API names: `schema.view` or `api.view`).\n * Hosts that omit it (staff tools, demos) get allow-all.\n */\n can: (cap: Cap) => boolean;\n /** pathKey → teammates in that field */\n presence: Record<string, KitPeer[]>;\n /** pathKey → open comment threads */\n comments: Record<string, number>;\n /** Host comment panel. When absent, field comments live in the in-place popover only. */\n /** `quote`: the words selected in a rich text field when the comment came from its toolbar */\n onComment?: (path: FieldPath, field: FieldSchema, quote?: string) => void;\n /** The whole form is a global block (\"Navigation\") — every field is synced. */\n syncedFrom?: string;\n /** \"Open {title}\" on a reference card: the host edits the referenced entry in place (stacked panel). */\n onOpenReference?: (ref: { collectionId: string; entryId: string; title: string }) => void;\n /** CPO D39: \"inline\" (default) shows help under the label; \"tooltip\" moves it behind the ⓘ — for dense hosts (grid cells, popovers). */\n helpDisplay?: \"inline\" | \"tooltip\";\n /** D61 Review changes: the host's change markers, present only while its History panel is open. */\n review?: KitReview;\n /** D61 field ⋯ › History: the host opens its one History panel on this field. Absent = no History item. */\n onFieldHistory?: (path: FieldPath, field: FieldSchema) => void;\n /**\n * \"quiet\": a meta-form, like the schema editor's field settings (founder call, 2026-10-05). No comment, ⋯ or per-field\n * undo on the fields, and an on/off field is a label-left row with its switch on the right (the inspector's PRow), not a\n * switch card. \"preview\": the same chrome-free fields, controls exactly as editors see them (a schema preview, where a\n * comment would land on a sample, never a real document). Default \"full\".\n */\n fieldChrome?: \"full\" | \"preview\" | \"quiet\";\n /**\n * A host's own control for one field, by its path key (\"type\", \"options\"), drawn inside the usual shell. The schema\n * editor's field settings plug their Type, Options, Key and Show this field controls in here. Absent = kit controls only.\n */\n controls?: Record<string, React.ComponentType<ControlProps>>;\n /**\n * A collapsed fieldset's summary as chips, from the host (the schema editor's field settings: \"Required\", \"3 options\").\n * `undefined` falls back to the kit's own one-line summary. Keep it stable (a new function re-renders the form).\n */\n sectionSummary?: (set: Fieldset, value: Record<string, unknown>) => string[] | undefined;\n}\n\n/**\n * D61 Review changes, as the kit sees it. The host owns the history model; the kit only asks, per field path, whether\n * it changed in the range, and renders the host's marker (a 2px bar in the author's colour at the field's left edge,\n * with its hover card) where the at-rest \"changed\" dot would be.\n */\nexport interface KitReview {\n /** changes at or inside this field in the range (0 = unchanged) */\n count: (path: FieldPath) => number;\n /** the presence colour of whoever changed it last (list rows draw their own bar) */\n color: (path: FieldPath) => string | undefined;\n /** the host's change bar and hover card for a changed field (null when unchanged) */\n bar: (path: FieldPath, field: FieldSchema) => React.ReactNode;\n /** Show only changes: unchanged fields fold into one quiet line each run */\n onlyChanges: boolean;\n}\n\n/** The title of the fieldset a field sits in (null outside one). A quiet meta-form drops a field label that only repeats\n * its section's title (\"Options\" › \"Options\"): the section heading names it. */\nexport const KitSectionTitle = React.createContext<string | null>(null);\n/**\n * D66: the host's address row under a slug field (production URL, who serves it, the preview, live state). The host\n * knows the site's hosting; the kit only asks it to render the row for the slug being typed. Absent = the kit's own row.\n */\nexport const KitAddressContext = React.createContext<((slug: string) => React.ReactNode) | null>(null);\nexport const DEFAULT_ENV: KitEnv = {\n variant: \"panel\",\n docId: \"kit\",\n palette: [],\n readOnly: false,\n can: () => true,\n presence: {},\n comments: {},\n};\nconst EnvCtx = React.createContext<KitEnv>(DEFAULT_ENV);\n\n/** D58 field access: fields in the `seo` group default to `{ edit: \"seo.edit\" }`. */\nexport const fieldAccessOf = (field: FieldSchema): FieldAccess | undefined => field.access ?? (field.group === \"seo\" ? { edit: \"seo.edit\" } : undefined);\n\n/**\n * One field for the lens: hidden (no `view`), read-only (plain text: no `edit`, the field is `readOnly`, or the whole form\n * is read-only and the field has no edit cap of its own), or editable. An explicit `edit` cap wins over the form's\n * read-only rule, so an SEO specialist edits SEO fields inside a form they can't otherwise change.\n */\nexport function resolveFieldAccess(field: FieldSchema, env: Pick<KitEnv, \"can\" | \"readOnly\">): { hidden: boolean; readOnly: boolean } {\n const a = fieldAccessOf(field);\n if (a?.view && !env.can(a.view)) return { hidden: true, readOnly: true };\n if (field.readOnly === true) return { hidden: false, readOnly: true };\n if (a?.edit) return { hidden: false, readOnly: !env.can(a.edit) };\n return { hidden: false, readOnly: env.readOnly };\n}\n/** Drop the fields the lens can't `view` (recursively), so they are neither rendered nor validated. Same object back when\n * nothing is hidden. Values of dropped fields stay in the document untouched. */\nexport function visibleFields(fields: FieldSchema[], can: KitEnv[\"can\"]): FieldSchema[] {\n let changed = false;\n const out: FieldSchema[] = [];\n for (const f of fields) {\n const a = fieldAccessOf(f);\n if (a?.view && !can(a.view)) {\n changed = true;\n continue;\n }\n let g = f;\n if (f.fields) {\n const n = visibleFields(f.fields, can);\n if (n !== f.fields) g = { ...g, fields: n };\n }\n if (Array.isArray(f.of)) {\n const n = visibleFields(f.of, can);\n if (n !== f.of) g = { ...g, of: n };\n }\n if (f.slotSettings) {\n const n = visibleFields(f.slotSettings, can);\n if (n !== f.slotSettings) g = { ...g, slotSettings: n };\n }\n if (g !== f) changed = true;\n out.push(g);\n }\n return changed ? out : fields;\n}\nexport function visibleSchema(schema: TypeSchema, can: KitEnv[\"can\"]): TypeSchema {\n const fields = visibleFields(schema.fields, can);\n return fields === schema.fields ? schema : { ...schema, fields };\n}\n\n/** Developer surfaces (field keys, API names, IDs): `schema.view` or `api.view`. */\nexport const seesDevSurfaces = (env: Pick<KitEnv, \"can\">) => env.can(\"schema.view\") || env.can(\"api.view\");\nexport const KitEnvProvider = EnvCtx.Provider;\nexport const useKitEnv = () => React.useContext(EnvCtx);\n\n/* ── Form runtime (inside <SchemaForm>) ──────────────────────────────── */\nexport interface HistoryEntry {\n value: unknown;\n at: number;\n by: string;\n label?: string;\n}\nexport interface FormApi {\n schema: TypeSchema;\n value: Record<string, unknown>;\n /** write a value; `record: false` skips the field undo/history stack (e.g. programmatic sync) */\n setAt: (path: FieldPath, v: unknown, opts?: { record?: boolean; label?: string }) => void;\n getAt: (path: FieldPath) => unknown;\n /** value when the form mounted (field undo baseline) */\n baselineAt: (path: FieldPath) => unknown;\n /** published value (changed dot, Reset to published); undefined when never published */\n publishedAt: (path: FieldPath) => unknown;\n hasPublished: boolean;\n /** component instances (CPO D28): top-level fields inherit from a component unless overridden */\n inherited?: { from: string; isOverridden: (key: string) => boolean; reset: (key: string) => void };\n /** the current navigation path (drill-in stack) */\n path: FieldPath;\n navigate: (path: FieldPath) => void;\n /** the form draws frames for a non-root path. False while SchemaForm renders only the root frame: History and\n * drill-in rows hide or go inert instead of navigating to a path nothing shows (no silent no-op). */\n canNavigate: boolean;\n resolveSchema?: (blockType: string) => TypeSchema | undefined;\n /** blocks offered by \"+ Add block\" in slots (filtered by each slot's allow list) */\n blockLibrary?: TypeSchema[];\n /** all issues by pathKey */\n issues: Map<string, KitIssue>;\n /** the issue shown for a key (rules on blur, required after blur or a publish attempt) */\n visibleIssue: (key: string) => KitIssue | undefined;\n /** visible issues under a path prefix (rollup dots on rows, crumbs and tabs) */\n rollup: (prefix: FieldPath) => { errors: number; warnings: number };\n touch: (key: string) => void;\n showAllErrors: boolean;\n /** per-field undo (Undo last change to {label}) */\n canUndo: (key: string) => boolean;\n undo: (key: string) => void;\n /** versions of a field this session (newest first) */\n history: (key: string) => HistoryEntry[];\n /** the last change to this field came from AI (⋯ shows \"Undo AI change\") */\n aiKeys: Set<string>;\n markAi: (key: string, on: boolean) => void;\n /** remembered UI state per frame (selected group tab, open fieldsets) */\n memory: Map<string, unknown>;\n}\nconst FormCtx = React.createContext<FormApi | null>(null);\nexport const FormProvider = FormCtx.Provider;\nexport const useForm = () => React.useContext(FormCtx);\n"],"mappings":";;;;;;;;;;;;;AAmEA,IAAa,aAAgD;CAC3D;EAAE,IAAI;EAAW,OAAO;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GAAG;CAC/C,OAAO,WAAW,OAAO,SAAS,SAAS;EAAE,GAAG;EAAQ;CAAO;AACjE;;AAGA,IAAa,mBAAmB,QAA6B,IAAI,IAAI,aAAa,KAAK,IAAI,IAAI,UAAU;AACzG,IAAa,iBAAiB,OAAO;AACrC,IAAa,kBAAkB,MAAM,WAAW,MAAM;AAkDtD,IAAM,UAAU,MAAM,cAA8B,IAAI;AACxD,IAAa,eAAe,QAAQ;AACpC,IAAa,gBAAgB,MAAM,WAAW,OAAO"}
@@ -4,7 +4,7 @@
4
4
  * The V2 editor edits HTML (contentEditable). Production stores Portable Text, in the shape the classic editor of the
5
5
  * same surface writes (a block array for an entry field, the `{ content, html }` envelope for a component prop). The
6
6
  * conversion lives in the host, which owns the real converters, schema conformance and the field's Accept config; the
7
- * kit never imports them. A host with no codec gets its own control for rich text (LegacyFallback), never a guess.
7
+ * kit never imports them. A host with no codec gets a held field (read-only, with the reason), never a guess.
8
8
  *
9
9
  * The control opens a value only when it survives the trip editor → codec unchanged (`same`), so nothing the HTML
10
10
  * editor cannot hold (a checklist's ticks, a link's rel, an image's layout) is dropped by a first keystroke: such a
@@ -71,7 +71,7 @@ declare module "../../context" {
71
71
  interface KitServices {
72
72
  /**
73
73
  * Stored rich text ↔ the HTML the kit editor edits (see controls/rich-text/codec.ts). Absent → a rich text field
74
- * draws the host's own control for it (LegacyControl).
74
+ * is held (read-only, with the reason).
75
75
  */
76
76
  richText?: KitRichTextCodec;
77
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"codec.js","names":[],"sources":["../../../src/controls/rich-text/codec.ts"],"sourcesContent":["/**\n * RICH TEXT · the storage contract between the kit editor and its host.\n *\n * The V2 editor edits HTML (contentEditable). Production stores Portable Text, in the shape the classic editor of the\n * same surface writes (a block array for an entry field, the `{ content, html }` envelope for a component prop). The\n * conversion lives in the host, which owns the real converters, schema conformance and the field's Accept config; the\n * kit never imports them. A host with no codec gets its own control for rich text (LegacyFallback), never a guess.\n *\n * The control opens a value only when it survives the trip editor → codec unchanged (`same`), so nothing the HTML\n * editor cannot hold (a checklist's ticks, a link's rel, an image's layout) is dropped by a first keystroke: such a\n * value is edited by the host's own control instead, with the reason named.\n */\nimport type { FieldPath, FieldSchema } from \"../../schema/types\";\nimport type { UnknownValue } from \"../unknown-value\";\n\n/** What a field may hold, in the editor's vocabulary. The editor offers nothing outside it. */\nexport type RichTextFeature =\n | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\"\n | \"blockquote\" | \"ul\" | \"ol\" | \"pre\" | \"hr\"\n | \"bold\" | \"italic\" | \"underline\" | \"strike\" | \"sup\" | \"sub\" | \"code\"\n | \"link\" | \"image\"\n /* blocks, each stored as its own Portable Text block (see dom.ts) */\n | \"table\" | \"pullquote\" | \"takeaways\" | \"callout\" | \"toggle\" | \"video\" | \"file\"\n /* a task list (PT listItem \"check\" + checked) and a call-to-action link (the link markDef with button: true) */\n | \"checklist\" | \"button\"\n /* V2's article blocks, each a Portable Text block of its own (plan RT3–RT5): embed, gallery, table of contents */\n | \"embed\" | \"gallery\" | \"toc\"\n /* plan RT6–RT8: a footnote (inline, in the text), columns of text, an author bio and related posts (references) */\n | \"footnote\" | \"columns\" | \"author\" | \"related\"\n /* an embed's Shape (aspect): the host declares it once its stored embed keeps one (plan RT3) */\n | \"embedAspect\";\n\nexport const ALL_FEATURES: readonly RichTextFeature[] = [\n \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"blockquote\", \"ul\", \"ol\", \"pre\", \"hr\", \"bold\", \"italic\", \"underline\", \"strike\", \"sup\", \"sub\", \"code\", \"link\", \"image\",\n \"table\", \"pullquote\", \"takeaways\", \"callout\", \"toggle\", \"video\", \"file\", \"checklist\", \"button\", \"embed\", \"gallery\", \"toc\", \"footnote\", \"columns\", \"author\", \"related\", \"embedAspect\",\n];\n\nexport interface RichTextRead {\n /** the HTML the editor opens on */\n html: string;\n /** the stored value as the classic editor would open it (compared against the editor's round trip) */\n seed: unknown;\n /** what this value already cannot carry from an earlier editor, in words (\"2 links\"); shown before the first edit */\n losses: string[];\n /** what the field accepts */\n features: RichTextFeature[];\n /** one paragraph, stored inline (allowMultipleParagraphs: false) */\n single: boolean;\n /** links may open in a new tab */\n newTab: boolean;\n /**\n * the styles, marks and lists the value holds that the field no longer declares: kept by every write, flagged above\n * the editor with change-to and remove (H4; see `remap`). Absent or empty = none.\n */\n undeclared?: UnknownValue[];\n /**\n * Where an author bio and related posts point (plan RT8), from the field's config: the authors and posts collections,\n * and the entry being edited (left out of the automatic related modes). Author bio is offered only with `authors`.\n * `topic: false`: the posts collection has no tags or category field, so \"Same topic\" cannot rank there (the entry\n * write refuses it, relatedPosts.no_topic_field); a new block is Newest and Same topic is not offered. Absent = has one.\n */\n /** `postsNoun`: what one post is called (the posts collection's singular, \"story\"), so Hand-picked says \"Create new story\" */\n references?: { authors?: string; posts?: string; entryId?: string; topic?: boolean; postsNoun?: string };\n}\n\nexport interface RichTextWrite {\n /** the value to store, in the surface's own shape */\n value: unknown;\n /** what the stored shape would drop from this HTML, in words; non-empty = the write is refused */\n losses: string[];\n}\n\nexport interface RichTextAt {\n field: FieldSchema;\n path: FieldPath;\n}\n\nexport interface KitRichTextCodec {\n read(value: unknown, at: RichTextAt): RichTextRead;\n /** `prev` is the stored value being replaced (its keys are reused so an edit does not re-key the document) */\n write(html: string, at: RichTextAt, prev: unknown): RichTextWrite;\n /** the same document, ignoring keys, span splits and storage wrapper */\n same(a: unknown, b: unknown): boolean;\n /** the stored value with one `undeclared` value (its `key`) changed to `to`, or removed (`to` null); the words stay */\n remap?(value: unknown, at: RichTextAt, key: string, to: string | null): unknown;\n}\n\ndeclare module \"../../context\" {\n interface KitServices {\n /**\n * Stored rich text ↔ the HTML the kit editor edits (see controls/rich-text/codec.ts). Absent → a rich text field\n * draws the host's own control for it (LegacyControl).\n */\n richText?: KitRichTextCodec;\n }\n}\n"],"mappings":";AAgCA,IAAa,eAA2C;CACtD;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAc;CAAM;CAAM;CAAO;CAAM;CAAQ;CAAU;CAAa;CAAU;CAAO;CAAO;CAAQ;CAAQ;CAClJ;CAAS;CAAa;CAAa;CAAW;CAAU;CAAS;CAAQ;CAAa;CAAU;CAAS;CAAW;CAAO;CAAY;CAAW;CAAU;CAAW;AACzK"}
1
+ {"version":3,"file":"codec.js","names":[],"sources":["../../../src/controls/rich-text/codec.ts"],"sourcesContent":["/**\n * RICH TEXT · the storage contract between the kit editor and its host.\n *\n * The V2 editor edits HTML (contentEditable). Production stores Portable Text, in the shape the classic editor of the\n * same surface writes (a block array for an entry field, the `{ content, html }` envelope for a component prop). The\n * conversion lives in the host, which owns the real converters, schema conformance and the field's Accept config; the\n * kit never imports them. A host with no codec gets a held field (read-only, with the reason), never a guess.\n *\n * The control opens a value only when it survives the trip editor → codec unchanged (`same`), so nothing the HTML\n * editor cannot hold (a checklist's ticks, a link's rel, an image's layout) is dropped by a first keystroke: such a\n * value is edited by the host's own control instead, with the reason named.\n */\nimport type { FieldPath, FieldSchema } from \"../../schema/types\";\nimport type { UnknownValue } from \"../unknown-value\";\n\n/** What a field may hold, in the editor's vocabulary. The editor offers nothing outside it. */\nexport type RichTextFeature =\n | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\"\n | \"blockquote\" | \"ul\" | \"ol\" | \"pre\" | \"hr\"\n | \"bold\" | \"italic\" | \"underline\" | \"strike\" | \"sup\" | \"sub\" | \"code\"\n | \"link\" | \"image\"\n /* blocks, each stored as its own Portable Text block (see dom.ts) */\n | \"table\" | \"pullquote\" | \"takeaways\" | \"callout\" | \"toggle\" | \"video\" | \"file\"\n /* a task list (PT listItem \"check\" + checked) and a call-to-action link (the link markDef with button: true) */\n | \"checklist\" | \"button\"\n /* V2's article blocks, each a Portable Text block of its own (plan RT3–RT5): embed, gallery, table of contents */\n | \"embed\" | \"gallery\" | \"toc\"\n /* plan RT6–RT8: a footnote (inline, in the text), columns of text, an author bio and related posts (references) */\n | \"footnote\" | \"columns\" | \"author\" | \"related\"\n /* an embed's Shape (aspect): the host declares it once its stored embed keeps one (plan RT3) */\n | \"embedAspect\";\n\nexport const ALL_FEATURES: readonly RichTextFeature[] = [\n \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"blockquote\", \"ul\", \"ol\", \"pre\", \"hr\", \"bold\", \"italic\", \"underline\", \"strike\", \"sup\", \"sub\", \"code\", \"link\", \"image\",\n \"table\", \"pullquote\", \"takeaways\", \"callout\", \"toggle\", \"video\", \"file\", \"checklist\", \"button\", \"embed\", \"gallery\", \"toc\", \"footnote\", \"columns\", \"author\", \"related\", \"embedAspect\",\n];\n\nexport interface RichTextRead {\n /** the HTML the editor opens on */\n html: string;\n /** the stored value as the classic editor would open it (compared against the editor's round trip) */\n seed: unknown;\n /** what this value already cannot carry from an earlier editor, in words (\"2 links\"); shown before the first edit */\n losses: string[];\n /** what the field accepts */\n features: RichTextFeature[];\n /** one paragraph, stored inline (allowMultipleParagraphs: false) */\n single: boolean;\n /** links may open in a new tab */\n newTab: boolean;\n /**\n * the styles, marks and lists the value holds that the field no longer declares: kept by every write, flagged above\n * the editor with change-to and remove (H4; see `remap`). Absent or empty = none.\n */\n undeclared?: UnknownValue[];\n /**\n * Where an author bio and related posts point (plan RT8), from the field's config: the authors and posts collections,\n * and the entry being edited (left out of the automatic related modes). Author bio is offered only with `authors`.\n * `topic: false`: the posts collection has no tags or category field, so \"Same topic\" cannot rank there (the entry\n * write refuses it, relatedPosts.no_topic_field); a new block is Newest and Same topic is not offered. Absent = has one.\n */\n /** `postsNoun`: what one post is called (the posts collection's singular, \"story\"), so Hand-picked says \"Create new story\" */\n references?: { authors?: string; posts?: string; entryId?: string; topic?: boolean; postsNoun?: string };\n}\n\nexport interface RichTextWrite {\n /** the value to store, in the surface's own shape */\n value: unknown;\n /** what the stored shape would drop from this HTML, in words; non-empty = the write is refused */\n losses: string[];\n}\n\nexport interface RichTextAt {\n field: FieldSchema;\n path: FieldPath;\n}\n\nexport interface KitRichTextCodec {\n read(value: unknown, at: RichTextAt): RichTextRead;\n /** `prev` is the stored value being replaced (its keys are reused so an edit does not re-key the document) */\n write(html: string, at: RichTextAt, prev: unknown): RichTextWrite;\n /** the same document, ignoring keys, span splits and storage wrapper */\n same(a: unknown, b: unknown): boolean;\n /** the stored value with one `undeclared` value (its `key`) changed to `to`, or removed (`to` null); the words stay */\n remap?(value: unknown, at: RichTextAt, key: string, to: string | null): unknown;\n}\n\ndeclare module \"../../context\" {\n interface KitServices {\n /**\n * Stored rich text ↔ the HTML the kit editor edits (see controls/rich-text/codec.ts). Absent → a rich text field\n * is held (read-only, with the reason).\n */\n richText?: KitRichTextCodec;\n }\n}\n"],"mappings":";AAgCA,IAAa,eAA2C;CACtD;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAc;CAAM;CAAM;CAAO;CAAM;CAAQ;CAAU;CAAa;CAAU;CAAO;CAAO;CAAQ;CAAQ;CAClJ;CAAS;CAAa;CAAa;CAAW;CAAU;CAAS;CAAQ;CAAa;CAAU;CAAS;CAAW;CAAO;CAAY;CAAW;CAAU;CAAW;AACzK"}
@@ -13,7 +13,7 @@ type Opened = {
13
13
  };
14
14
  /**
15
15
  * Open a stored value: read it, then prove the editor carries it unchanged (load → serialize → write === stored).
16
- * A codec that throws, or a value that does not survive, is handed to the host's own control with the reason.
16
+ * A codec that throws, or a value that does not survive, is held with the reason.
17
17
  */
18
18
  export declare function openValue(codec: KitRichTextCodec, value: unknown, at: Parameters<KitRichTextCodec["read"]>[1]): Opened;
19
19
  export declare function RichTextControl(props: ControlProps): import("react/jsx-runtime").JSX.Element;
@@ -7,7 +7,6 @@ import { Textarea } from "../../ui/input.js";
7
7
  import { resolveFrames } from "../../lib/frames.js";
8
8
  import { editorRoundTrip } from "./dom.js";
9
9
  import { HeldValue } from "../../engine/held.js";
10
- import { LegacyFallback } from "../../engine/kit-field.js";
11
10
  import { TEXT_FOCUS } from "../text.js";
12
11
  import { UnknownValueNote } from "../unknown-value.js";
13
12
  import { RichTextEditor } from "./editor.js";
@@ -29,8 +28,7 @@ import { IconArrowsMaximize } from "@tabler/icons-react";
29
28
  * - write: edited HTML → the stored value, in the surface's own shape; a write that would drop something is refused,
30
29
  * named, and nothing is stored
31
30
  * - probe: a value the editor cannot carry unchanged (open → no edit → write ≠ stored) is not opened here at all: it
32
- * is HELD (read-only, its HTML shown, the reason above it; kit 3.2.0), or, while the host still provides
33
- * KitServices.LegacyControl (removed in 4.0.0), the host's own control edits it. Opening never writes.
31
+ * is HELD (read-only, its HTML shown, the reason above it). Opening never writes.
34
32
  */
35
33
  var openKey = null;
36
34
  var subs = /* @__PURE__ */ new Set();
@@ -69,7 +67,7 @@ function useExpandCrumbs(fieldTitle) {
69
67
  var holdsPullQuote = (seed) => Array.isArray(seed) ? seed.some((b) => !!b && typeof b === "object" && b._type === "pullQuote") : !!seed && typeof seed === "object" && holdsPullQuote(seed.content ?? seed.value);
70
68
  /**
71
69
  * Open a stored value: read it, then prove the editor carries it unchanged (load → serialize → write === stored).
72
- * A codec that throws, or a value that does not survive, is handed to the host's own control with the reason.
70
+ * A codec that throws, or a value that does not survive, is held with the reason.
73
71
  */
74
72
  function openValue(codec, value, at) {
75
73
  let read;
@@ -83,7 +81,7 @@ function openValue(codec, value, at) {
83
81
  }
84
82
  if (holdsPullQuote(read.seed) && (!/data-rt="pullquote"/.test(read.html) || !read.features.includes("pullquote"))) return {
85
83
  ok: false,
86
- reason: "it holds a pull quote, which the standard editor edits",
84
+ reason: "it holds a pull quote, which this field has no place for",
87
85
  html: read.html
88
86
  };
89
87
  const html = editorRoundTrip(read.html);
@@ -114,7 +112,12 @@ function openValue(codec, value, at) {
114
112
  }
115
113
  function RichTextControl(props) {
116
114
  const { richText } = useKitServices();
117
- if (!richText) return /* @__PURE__ */ jsx(LegacyFallback, { ...props });
115
+ if (!richText) return /* @__PURE__ */ jsx(HeldValue, {
116
+ field: props.field,
117
+ value: props.value,
118
+ id: props.id,
119
+ reason: "this view has no rich text editor"
120
+ });
118
121
  return /* @__PURE__ */ jsx(CodecRichText, {
119
122
  codec: richText,
120
123
  ...props
@@ -131,7 +134,7 @@ function CodecRichText({ codec, field, value, onChange, readOnly, path, id, inva
131
134
  field,
132
135
  path
133
136
  }), [field, path]);
134
- const { useInsertableComponents, LegacyControl } = useKitServices();
137
+ const { useInsertableComponents } = useKitServices();
135
138
  const insertable = useInsertableComponents?.(at);
136
139
  const mine = React.useRef(null);
137
140
  const [refusal, setRefusal] = React.useState(null);
@@ -158,34 +161,13 @@ function CodecRichText({ codec, field, value, onChange, readOnly, path, id, inva
158
161
  setHandedOff(docKey, !opened.ok);
159
162
  if (!opened.ok && openKey === docKey) setFullEditor(null);
160
163
  }, [docKey, opened.ok]);
161
- if (!opened.ok && !LegacyControl) return /* @__PURE__ */ jsx(HeldValue, {
164
+ if (!opened.ok) return /* @__PURE__ */ jsx(HeldValue, {
162
165
  field,
163
166
  value,
164
167
  id,
165
168
  reason: opened.reason,
166
169
  html: opened.html
167
170
  });
168
- if (!opened.ok) return /* @__PURE__ */ jsxs("div", {
169
- className: "flex min-w-0 flex-col gap-1.5",
170
- children: [/* @__PURE__ */ jsxs("p", {
171
- role: "note",
172
- "data-slot": "kit-richtext-handoff",
173
- className: "rounded-kit-md bg-kit-subtle px-2.5 py-1.5 text-kit-xs text-kit-fg-2",
174
- children: [
175
- "Edited with the standard editor: ",
176
- opened.reason,
177
- "."
178
- ]
179
- }), /* @__PURE__ */ jsx(LegacyFallback, {
180
- field,
181
- value,
182
- onChange,
183
- readOnly,
184
- path,
185
- id,
186
- invalid
187
- })]
188
- });
189
171
  const { read, html } = opened;
190
172
  const write = (next) => {
191
173
  let res;
@@ -1 +1 @@
1
- {"version":3,"file":"control.js","names":[],"sources":["../../../src/controls/rich-text/control.tsx"],"sourcesContent":["/**\n * Rich text field (V2 HEAD controls/richtext.tsx, CPO D49).\n * - The editor stays in place: the document variant is the full editor in the column, the panel variant (inspector)\n * the same editor height-capped.\n * - Expanding (the toolbar's expand button, ⌘↵, or the expand icon in the field's label row at rest) opens the shared\n * ExpandedEditorModal: breadcrumb \"Section › Item › Field\", word count, Done. Esc closes and focus returns.\n *\n * STORAGE. The editor edits HTML; the stored value stays what production stores for the field, through the host's\n * codec (KitServices.richText, see ./codec.ts):\n * - read: stored value → the HTML the editor opens on (+ what the field accepts)\n * - write: edited HTML → the stored value, in the surface's own shape; a write that would drop something is refused,\n * named, and nothing is stored\n * - probe: a value the editor cannot carry unchanged (open → no edit → write ≠ stored) is not opened here at all: it\n * is HELD (read-only, its HTML shown, the reason above it; kit 3.2.0), or, while the host still provides\n * KitServices.LegacyControl (removed in 4.0.0), the host's own control edits it. Opening never writes.\n */\nimport * as React from \"react\";\nimport { IconArrowsMaximize } from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { useForm, useKitEnv, useKitServices } from \"../../context\";\nimport { resolveFrames } from \"../../lib/frames\";\nimport { pathKey } from \"../../lib/path\";\nimport type { ControlProps } from \"../../types\";\nimport { Tooltip } from \"../../ui/overlay\";\nimport { LegacyFallback } from \"../../engine/kit-field\";\nimport { HeldValue } from \"../../engine/held\";\nimport { FieldCommentRequest } from \"../../engine/field-shell\";\nimport type { KitRichTextCodec, RichTextRead } from \"./codec\";\nimport { editorRoundTrip } from \"./dom\";\nimport { RichTextEditor } from \"./editor\";\nimport { paragraphsHtml, plainParagraphs, usePlainRichText } from \"./plain\";\nimport { Textarea } from \"../../ui/input\";\nimport { TEXT_FOCUS } from \"../text\";\nimport { UnknownValueNote } from \"../unknown-value\";\n\n/* ── which rich-text field (docKey) has its full editor open — shared with the label-row action ── */\nlet openKey: string | null = null;\nconst subs = new Set<() => void>();\nexport function setFullEditor(key: string | null) {\n openKey = key;\n subs.forEach((s) => s());\n}\nfunction useFullEditorKey() {\n return React.useSyncExternalStore(\n (cb) => {\n subs.add(cb);\n return () => subs.delete(cb);\n },\n () => openKey,\n () => openKey,\n );\n}\n\n/* ── fields whose value went to the host's own control: the label-row expand button is not theirs to draw ── */\nconst handedOff = new Set<string>();\nfunction setHandedOff(key: string, on: boolean) {\n if (handedOff.has(key) === on) return;\n if (on) handedOff.add(key);\n else handedOff.delete(key);\n subs.forEach((s) => s());\n}\nfunction useHandedOff(key: string) {\n return React.useSyncExternalStore(\n (cb) => {\n subs.add(cb);\n return () => subs.delete(cb);\n },\n () => handedOff.has(key),\n () => handedOff.has(key),\n );\n}\n\n/** The expanded editor's breadcrumb: the form's frames (root › drilled items) and this field. */\nfunction useExpandCrumbs(fieldTitle: string): string[] {\n const form = useForm();\n const env = useKitEnv();\n if (!form) return [env.docTitle, fieldTitle].filter(Boolean) as string[];\n const { frames } = resolveFrames(form.schema, form.value, form.path, form.resolveSchema);\n const titles = frames.filter((f) => f.kind !== \"history\").map((f, i) => (i === 0 ? env.docTitle || f.title : f.title));\n return [...titles, fieldTitle];\n}\n\n/** A stored block array, or the `{ content }` / `{ format, value }` envelope around one, holding a pull quote block. */\nconst holdsPullQuote = (seed: unknown): boolean =>\n Array.isArray(seed)\n ? seed.some((b) => !!b && typeof b === \"object\" && (b as { _type?: unknown })._type === \"pullQuote\")\n : !!seed && typeof seed === \"object\" && holdsPullQuote((seed as { content?: unknown; value?: unknown }).content ?? (seed as { value?: unknown }).value);\n\n/** What the control decided for one stored value. */\ntype Opened =\n | { ok: true; read: RichTextRead; html: string }\n | { ok: false; reason: string; /** the HTML the codec read, when it could: what a held field shows */ html?: string };\n\n/**\n * Open a stored value: read it, then prove the editor carries it unchanged (load → serialize → write === stored).\n * A codec that throws, or a value that does not survive, is handed to the host's own control with the reason.\n */\nexport function openValue(codec: KitRichTextCodec, value: unknown, at: Parameters<KitRichTextCodec[\"read\"]>[1]): Opened {\n let read: RichTextRead;\n try {\n read = codec.read(value, at);\n } catch (err) {\n return { ok: false, reason: `the stored text could not be read (${err instanceof Error ? err.message : String(err)})` };\n }\n // a pull quote (V2 D55 article block) opens as the editor's pull-quote island, but only when the codec renders the\n // stored block as its markup in a field that offers it: a codec that renders nothing for it, or a field with no place\n // for one (a single paragraph), would lose it, so the standard editor edits it\n if (holdsPullQuote(read.seed) && (!/data-rt=\"pullquote\"/.test(read.html) || !read.features.includes(\"pullquote\")))\n return { ok: false, reason: \"it holds a pull quote, which the standard editor edits\", html: read.html };\n // tables and pull quotes are islands (V2 TableBlock, PullQuote); the probe below proves they survive unchanged\n const html = editorRoundTrip(read.html);\n try {\n const back = codec.write(html, at, value);\n if (back.losses.length) return { ok: false, reason: `this editor would drop ${back.losses.join(\", \")}`, html: read.html };\n if (!codec.same(back.value, read.seed)) return { ok: false, reason: \"it holds formatting this editor cannot keep\", html: read.html };\n } catch (err) {\n return { ok: false, reason: `the text could not be checked (${err instanceof Error ? err.message : String(err)})`, html: read.html };\n }\n return { ok: true, read, html };\n}\n\nexport function RichTextControl(props: ControlProps) {\n const { richText } = useKitServices();\n if (!richText) return <LegacyFallback {...props} />;\n return <CodecRichText codec={richText} {...props} />;\n}\n\nfunction CodecRichText({ codec, field, value, onChange, readOnly, path, id, invalid }: ControlProps & { codec: KitRichTextCodec }) {\n const env = useKitEnv();\n /* GAP-004: with no comments panel (env.onComment), the field's own comments popover takes the selected words */\n const requestComment = React.useContext(FieldCommentRequest);\n const docKey = `${env.docId}:${pathKey(path)}`;\n const open = useFullEditorKey() === docKey;\n const crumbs = useExpandCrumbs(field.title);\n const plainScope = usePlainRichText();\n const at = React.useMemo(() => ({ field, path }), [field, path]);\n // the components this field may embed (More components): a hook with one identity for the form's life, so calling it\n // only when the host provides it keeps the hook order fixed\n const { useInsertableComponents, LegacyControl } = useKitServices();\n const insertable = useInsertableComponents?.(at);\n /* our own last write: its value comes back as `value`, and the editor keeps the HTML it emitted (no reload, no probe).\n Compared by content (NEW-RT5): a host hands it back as a new object (the dock re-reads its stored values), and the\n reload that followed replaced the body under an open footnote popover or block form after its first keystroke */\n const mine = React.useRef<{ value: unknown; html: string } | null>(null);\n const [refusal, setRefusal] = React.useState<string | null>(null);\n const opened = React.useMemo<Opened>(() => {\n if (mine.current && (mine.current.value === value || codec.same(mine.current.value, value))) {\n try {\n return { ok: true, read: codec.read(value, at), html: mine.current.html };\n } catch {\n /* judged afresh below, which names the failure */\n }\n }\n return openValue(codec, value, at);\n // `at` changes identity with the field object; the field's content is what matters\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [codec, value, JSON.stringify(field), pathKey(path)]);\n\n // close when this field goes away (block deselected, drilled elsewhere)\n React.useEffect(\n () => () => {\n if (openKey === docKey) setFullEditor(null);\n setHandedOff(docKey, false);\n },\n [docKey],\n );\n React.useLayoutEffect(() => {\n setHandedOff(docKey, !opened.ok);\n if (!opened.ok && openKey === docKey) setFullEditor(null);\n }, [docKey, opened.ok]);\n\n // kit 3.2.0: with no host control to hand it to, the value is held (shown read-only with the reason, never written)\n if (!opened.ok && !LegacyControl) return <HeldValue field={field} value={value} id={id} reason={opened.reason} html={opened.html} />;\n if (!opened.ok)\n return (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n <p role=\"note\" data-slot=\"kit-richtext-handoff\" className=\"rounded-kit-md bg-kit-subtle px-2.5 py-1.5 text-kit-xs text-kit-fg-2\">\n Edited with the standard editor: {opened.reason}.\n </p>\n <LegacyFallback field={field} value={value} onChange={onChange} readOnly={readOnly} path={path} id={id} invalid={invalid} />\n </div>\n );\n\n const { read, html } = opened;\n const write = (next: string) => {\n let res;\n try {\n res = codec.write(next, at, value);\n } catch (err) {\n setRefusal(`Not saved: the text could not be stored (${err instanceof Error ? err.message : String(err)}). Undo the last change with ⌘Z; leaving the field puts back the saved text.`);\n return;\n }\n if (res.losses.length) {\n setRefusal(`Not saved: this field cannot keep ${res.losses.join(\", \")}. Undo the last change with ⌘Z; leaving the field puts back the saved text.`);\n return;\n }\n setRefusal(null);\n if (codec.same(res.value, value)) return;\n mine.current = { value: res.value, html: next };\n onChange(res.value);\n };\n\n // The Values popover (PlainRichTextScope): plain paragraphs are V2's growing textarea (its `text` control), written\n // back through the same codec, one `<p>` per line. Anything richer keeps the editor below.\n const plain = plainScope && !read.losses.length ? plainParagraphs(html) : null;\n if (plain !== null)\n return (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n <Textarea\n id={id}\n rows={3}\n value={plain}\n readOnly={readOnly}\n aria-invalid={invalid || !!refusal}\n placeholder={field.placeholder}\n onChange={(e) => write(paragraphsHtml(e.target.value))}\n className={cn(TEXT_FOCUS, \"leading-5\")}\n />\n {refusal ? (\n <p role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">\n {refusal}\n </p>\n ) : null}\n </div>\n );\n\n /* V2 richtext.tsx:57: the editor sits in a plain <div>; the dash-only notes keep the 6px gap as their own margin */\n return (\n <div>\n {read.losses.length ? (\n <p role=\"status\" className=\"mb-1.5 rounded-kit-md bg-kit-warning-soft px-2.5 py-1.5 text-kit-xs text-kit-warning-fg\">\n Saved by an earlier editor. Editing here would drop {read.losses.join(\", \")}. Nothing changes until you edit.\n </p>\n ) : null}\n {read.undeclared?.length && codec.remap ? (\n <div className=\"mb-1.5\">\n <UnknownValueNote\n items={read.undeclared}\n onRemap={(key, to) => onChange(codec.remap!(value, at, key, to))}\n onRemove={(key) => onChange(codec.remap!(value, at, key, null))}\n readOnly={readOnly}\n />\n </div>\n ) : null}\n <RichTextEditor\n value={html}\n onChange={write}\n readOnly={readOnly}\n placeholder={field.placeholder}\n docKey={docKey}\n id={id}\n invalid={invalid || !!refusal}\n features={read.features}\n references={read.references}\n single={read.single}\n allowNewTab={read.newTab}\n components={insertable && !read.single && !readOnly ? insertable : undefined}\n variant={env.variant === \"document\" ? \"document\" : \"panel\"}\n maxHeight={env.variant === \"document\" ? undefined : 320}\n expandCrumbs={crumbs}\n expandedOpen={open}\n onExpandedOpenChange={(o) => setFullEditor(o ? docKey : null)}\n // select words → Comment in the toolbar: the host's comment popover opens on this field, quoting them\n onComment={\n env.onComment ? (quote) => env.onComment?.(path, field, quote) : requestComment ? (quote, around) => requestComment({ quote, ...around }) : undefined\n }\n // the field's popover sits under the field, behind the expanded editor's focus trap: no Comment in there\n commentInPlace={!env.onComment && !!requestComment}\n />\n {refusal ? (\n <p role=\"alert\" className=\"mt-1.5 text-kit-xs text-kit-danger-fg\">\n {refusal}\n </p>\n ) : null}\n </div>\n );\n}\n\n/** Label-row action (at rest): the field's toolbar holds the same button while it's open. */\nfunction readsPlain(codec: KitRichTextCodec, value: unknown, field: ControlProps[\"field\"], path: ControlProps[\"path\"]) {\n try {\n const read = codec.read(value, { field, path });\n return !read.losses.length && plainParagraphs(editorRoundTrip(read.html)) !== null;\n } catch {\n return false; // the control names the failure itself\n }\n}\n\nexport function RichTextExpandAction({ path, field, value }: ControlProps) {\n const env = useKitEnv();\n const { richText } = useKitServices();\n const handed = useHandedOff(`${env.docId}:${pathKey(path)}`);\n const plainScope = usePlainRichText();\n // the host's own control (no codec, or a value handed to it) has its own full-screen button\n if (env.variant === \"document\" || !richText || handed) return null;\n // drawn as a plain textarea (V2's `text` control has no ⤢)\n if (plainScope && readsPlain(richText, value, field, path)) return null;\n return (\n <Tooltip content=\"Expand editor\" shortcut=\"⌘↵\">\n <button\n type=\"button\"\n aria-label={`Expand ${field.title}`}\n onClick={() => setFullEditor(`${env.docId}:${pathKey(path)}`)}\n className={cn(\n \"-my-0.5 hidden size-6 items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\",\n \"group-hover/field:inline-flex group-focus-within/field:!hidden [@media(pointer:coarse)]:inline-flex\",\n )}\n >\n <IconArrowsMaximize className=\"size-3.5\" stroke={1.5} aria-hidden />\n </button>\n </Tooltip>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAI,UAAyB;AAC7B,IAAM,uBAAO,IAAI,IAAgB;AACjC,SAAgB,cAAc,KAAoB;CAChD,UAAU;CACV,KAAK,SAAS,MAAM,EAAE,CAAC;AACzB;AACA,SAAS,mBAAmB;CAC1B,OAAO,MAAM,sBACV,OAAO;EACN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BAAiB;CAEpC,IAAI,IAAI,YAAY,cAAc,CAAC,YAAY,QAAQ,OAAO;CAE9D,IAAI,cAAc,WAAW,UAAU,OAAO,OAAO,IAAI,GAAG,OAAO;CACnE,OACE,oBAAC,SAAD;EAAS,SAAQ;EAAgB,UAAS;EACxC,UAAA,oBAAC,UAAD;GACE,MAAK;GACL,cAAY,UAAU,MAAM;GAC5B,eAAe,cAAc,GAAG,IAAI,MAAM,GAAG,QAAQ,IAAI,GAAG;GAC5D,WAAW,GACT,uHACA,qGACF;GAEA,UAAA,oBAAC,oBAAD;IAAoB,WAAU;IAAW,QAAQ;IAAK,eAAA;GAAa,CAAA;EAC7D,CAAA;CACD,CAAA;AAEb"}
1
+ {"version":3,"file":"control.js","names":[],"sources":["../../../src/controls/rich-text/control.tsx"],"sourcesContent":["/**\n * Rich text field (V2 HEAD controls/richtext.tsx, CPO D49).\n * - The editor stays in place: the document variant is the full editor in the column, the panel variant (inspector)\n * the same editor height-capped.\n * - Expanding (the toolbar's expand button, ⌘↵, or the expand icon in the field's label row at rest) opens the shared\n * ExpandedEditorModal: breadcrumb \"Section › Item › Field\", word count, Done. Esc closes and focus returns.\n *\n * STORAGE. The editor edits HTML; the stored value stays what production stores for the field, through the host's\n * codec (KitServices.richText, see ./codec.ts):\n * - read: stored value → the HTML the editor opens on (+ what the field accepts)\n * - write: edited HTML → the stored value, in the surface's own shape; a write that would drop something is refused,\n * named, and nothing is stored\n * - probe: a value the editor cannot carry unchanged (open → no edit → write ≠ stored) is not opened here at all: it\n * is HELD (read-only, its HTML shown, the reason above it). Opening never writes.\n */\nimport * as React from \"react\";\nimport { IconArrowsMaximize } from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { useForm, useKitEnv, useKitServices } from \"../../context\";\nimport { resolveFrames } from \"../../lib/frames\";\nimport { pathKey } from \"../../lib/path\";\nimport type { ControlProps } from \"../../types\";\nimport { Tooltip } from \"../../ui/overlay\";\nimport { HeldValue } from \"../../engine/held\";\nimport { FieldCommentRequest } from \"../../engine/field-shell\";\nimport type { KitRichTextCodec, RichTextRead } from \"./codec\";\nimport { editorRoundTrip } from \"./dom\";\nimport { RichTextEditor } from \"./editor\";\nimport { paragraphsHtml, plainParagraphs, usePlainRichText } from \"./plain\";\nimport { Textarea } from \"../../ui/input\";\nimport { TEXT_FOCUS } from \"../text\";\nimport { UnknownValueNote } from \"../unknown-value\";\n\n/* ── which rich-text field (docKey) has its full editor open — shared with the label-row action ── */\nlet openKey: string | null = null;\nconst subs = new Set<() => void>();\nexport function setFullEditor(key: string | null) {\n openKey = key;\n subs.forEach((s) => s());\n}\nfunction useFullEditorKey() {\n return React.useSyncExternalStore(\n (cb) => {\n subs.add(cb);\n return () => subs.delete(cb);\n },\n () => openKey,\n () => openKey,\n );\n}\n\n/* ── fields whose value went to the host's own control: the label-row expand button is not theirs to draw ── */\nconst handedOff = new Set<string>();\nfunction setHandedOff(key: string, on: boolean) {\n if (handedOff.has(key) === on) return;\n if (on) handedOff.add(key);\n else handedOff.delete(key);\n subs.forEach((s) => s());\n}\nfunction useHandedOff(key: string) {\n return React.useSyncExternalStore(\n (cb) => {\n subs.add(cb);\n return () => subs.delete(cb);\n },\n () => handedOff.has(key),\n () => handedOff.has(key),\n );\n}\n\n/** The expanded editor's breadcrumb: the form's frames (root › drilled items) and this field. */\nfunction useExpandCrumbs(fieldTitle: string): string[] {\n const form = useForm();\n const env = useKitEnv();\n if (!form) return [env.docTitle, fieldTitle].filter(Boolean) as string[];\n const { frames } = resolveFrames(form.schema, form.value, form.path, form.resolveSchema);\n const titles = frames.filter((f) => f.kind !== \"history\").map((f, i) => (i === 0 ? env.docTitle || f.title : f.title));\n return [...titles, fieldTitle];\n}\n\n/** A stored block array, or the `{ content }` / `{ format, value }` envelope around one, holding a pull quote block. */\nconst holdsPullQuote = (seed: unknown): boolean =>\n Array.isArray(seed)\n ? seed.some((b) => !!b && typeof b === \"object\" && (b as { _type?: unknown })._type === \"pullQuote\")\n : !!seed && typeof seed === \"object\" && holdsPullQuote((seed as { content?: unknown; value?: unknown }).content ?? (seed as { value?: unknown }).value);\n\n/** What the control decided for one stored value. */\ntype Opened =\n | { ok: true; read: RichTextRead; html: string }\n | { ok: false; reason: string; /** the HTML the codec read, when it could: what a held field shows */ html?: string };\n\n/**\n * Open a stored value: read it, then prove the editor carries it unchanged (load → serialize → write === stored).\n * A codec that throws, or a value that does not survive, is held with the reason.\n */\nexport function openValue(codec: KitRichTextCodec, value: unknown, at: Parameters<KitRichTextCodec[\"read\"]>[1]): Opened {\n let read: RichTextRead;\n try {\n read = codec.read(value, at);\n } catch (err) {\n return { ok: false, reason: `the stored text could not be read (${err instanceof Error ? err.message : String(err)})` };\n }\n // a pull quote (V2 D55 article block) opens as the editor's pull-quote island, but only when the codec renders the\n // stored block as its markup in a field that offers it: a codec that renders nothing for it, or a field with no place\n // for one (a single paragraph), would lose it, so it is held\n if (holdsPullQuote(read.seed) && (!/data-rt=\"pullquote\"/.test(read.html) || !read.features.includes(\"pullquote\")))\n return { ok: false, reason: \"it holds a pull quote, which this field has no place for\", html: read.html };\n // tables and pull quotes are islands (V2 TableBlock, PullQuote); the probe below proves they survive unchanged\n const html = editorRoundTrip(read.html);\n try {\n const back = codec.write(html, at, value);\n if (back.losses.length) return { ok: false, reason: `this editor would drop ${back.losses.join(\", \")}`, html: read.html };\n if (!codec.same(back.value, read.seed)) return { ok: false, reason: \"it holds formatting this editor cannot keep\", html: read.html };\n } catch (err) {\n return { ok: false, reason: `the text could not be checked (${err instanceof Error ? err.message : String(err)})`, html: read.html };\n }\n return { ok: true, read, html };\n}\n\nexport function RichTextControl(props: ControlProps) {\n const { richText } = useKitServices();\n if (!richText) return <HeldValue field={props.field} value={props.value} id={props.id} reason=\"this view has no rich text editor\" />;\n return <CodecRichText codec={richText} {...props} />;\n}\n\nfunction CodecRichText({ codec, field, value, onChange, readOnly, path, id, invalid }: ControlProps & { codec: KitRichTextCodec }) {\n const env = useKitEnv();\n /* GAP-004: with no comments panel (env.onComment), the field's own comments popover takes the selected words */\n const requestComment = React.useContext(FieldCommentRequest);\n const docKey = `${env.docId}:${pathKey(path)}`;\n const open = useFullEditorKey() === docKey;\n const crumbs = useExpandCrumbs(field.title);\n const plainScope = usePlainRichText();\n const at = React.useMemo(() => ({ field, path }), [field, path]);\n // the components this field may embed (More components): a hook with one identity for the form's life, so calling it\n // only when the host provides it keeps the hook order fixed\n const { useInsertableComponents } = useKitServices();\n const insertable = useInsertableComponents?.(at);\n /* our own last write: its value comes back as `value`, and the editor keeps the HTML it emitted (no reload, no probe).\n Compared by content (NEW-RT5): a host hands it back as a new object (the dock re-reads its stored values), and the\n reload that followed replaced the body under an open footnote popover or block form after its first keystroke */\n const mine = React.useRef<{ value: unknown; html: string } | null>(null);\n const [refusal, setRefusal] = React.useState<string | null>(null);\n const opened = React.useMemo<Opened>(() => {\n if (mine.current && (mine.current.value === value || codec.same(mine.current.value, value))) {\n try {\n return { ok: true, read: codec.read(value, at), html: mine.current.html };\n } catch {\n /* judged afresh below, which names the failure */\n }\n }\n return openValue(codec, value, at);\n // `at` changes identity with the field object; the field's content is what matters\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [codec, value, JSON.stringify(field), pathKey(path)]);\n\n // close when this field goes away (block deselected, drilled elsewhere)\n React.useEffect(\n () => () => {\n if (openKey === docKey) setFullEditor(null);\n setHandedOff(docKey, false);\n },\n [docKey],\n );\n React.useLayoutEffect(() => {\n setHandedOff(docKey, !opened.ok);\n if (!opened.ok && openKey === docKey) setFullEditor(null);\n }, [docKey, opened.ok]);\n\n // a value the editor cannot carry unchanged is held: shown read-only with the reason, never written\n if (!opened.ok) return <HeldValue field={field} value={value} id={id} reason={opened.reason} html={opened.html} />;\n\n const { read, html } = opened;\n const write = (next: string) => {\n let res;\n try {\n res = codec.write(next, at, value);\n } catch (err) {\n setRefusal(`Not saved: the text could not be stored (${err instanceof Error ? err.message : String(err)}). Undo the last change with ⌘Z; leaving the field puts back the saved text.`);\n return;\n }\n if (res.losses.length) {\n setRefusal(`Not saved: this field cannot keep ${res.losses.join(\", \")}. Undo the last change with ⌘Z; leaving the field puts back the saved text.`);\n return;\n }\n setRefusal(null);\n if (codec.same(res.value, value)) return;\n mine.current = { value: res.value, html: next };\n onChange(res.value);\n };\n\n // The Values popover (PlainRichTextScope): plain paragraphs are V2's growing textarea (its `text` control), written\n // back through the same codec, one `<p>` per line. Anything richer keeps the editor below.\n const plain = plainScope && !read.losses.length ? plainParagraphs(html) : null;\n if (plain !== null)\n return (\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n <Textarea\n id={id}\n rows={3}\n value={plain}\n readOnly={readOnly}\n aria-invalid={invalid || !!refusal}\n placeholder={field.placeholder}\n onChange={(e) => write(paragraphsHtml(e.target.value))}\n className={cn(TEXT_FOCUS, \"leading-5\")}\n />\n {refusal ? (\n <p role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">\n {refusal}\n </p>\n ) : null}\n </div>\n );\n\n /* V2 richtext.tsx:57: the editor sits in a plain <div>; the dash-only notes keep the 6px gap as their own margin */\n return (\n <div>\n {read.losses.length ? (\n <p role=\"status\" className=\"mb-1.5 rounded-kit-md bg-kit-warning-soft px-2.5 py-1.5 text-kit-xs text-kit-warning-fg\">\n Saved by an earlier editor. Editing here would drop {read.losses.join(\", \")}. Nothing changes until you edit.\n </p>\n ) : null}\n {read.undeclared?.length && codec.remap ? (\n <div className=\"mb-1.5\">\n <UnknownValueNote\n items={read.undeclared}\n onRemap={(key, to) => onChange(codec.remap!(value, at, key, to))}\n onRemove={(key) => onChange(codec.remap!(value, at, key, null))}\n readOnly={readOnly}\n />\n </div>\n ) : null}\n <RichTextEditor\n value={html}\n onChange={write}\n readOnly={readOnly}\n placeholder={field.placeholder}\n docKey={docKey}\n id={id}\n invalid={invalid || !!refusal}\n features={read.features}\n references={read.references}\n single={read.single}\n allowNewTab={read.newTab}\n components={insertable && !read.single && !readOnly ? insertable : undefined}\n variant={env.variant === \"document\" ? \"document\" : \"panel\"}\n maxHeight={env.variant === \"document\" ? undefined : 320}\n expandCrumbs={crumbs}\n expandedOpen={open}\n onExpandedOpenChange={(o) => setFullEditor(o ? docKey : null)}\n // select words → Comment in the toolbar: the host's comment popover opens on this field, quoting them\n onComment={\n env.onComment ? (quote) => env.onComment?.(path, field, quote) : requestComment ? (quote, around) => requestComment({ quote, ...around }) : undefined\n }\n // the field's popover sits under the field, behind the expanded editor's focus trap: no Comment in there\n commentInPlace={!env.onComment && !!requestComment}\n />\n {refusal ? (\n <p role=\"alert\" className=\"mt-1.5 text-kit-xs text-kit-danger-fg\">\n {refusal}\n </p>\n ) : null}\n </div>\n );\n}\n\n/** Label-row action (at rest): the field's toolbar holds the same button while it's open. */\nfunction readsPlain(codec: KitRichTextCodec, value: unknown, field: ControlProps[\"field\"], path: ControlProps[\"path\"]) {\n try {\n const read = codec.read(value, { field, path });\n return !read.losses.length && plainParagraphs(editorRoundTrip(read.html)) !== null;\n } catch {\n return false; // the control names the failure itself\n }\n}\n\nexport function RichTextExpandAction({ path, field, value }: ControlProps) {\n const env = useKitEnv();\n const { richText } = useKitServices();\n const handed = useHandedOff(`${env.docId}:${pathKey(path)}`);\n const plainScope = usePlainRichText();\n // the host's own control (no codec, or a value handed to it) has its own full-screen button\n if (env.variant === \"document\" || !richText || handed) return null;\n // drawn as a plain textarea (V2's `text` control has no ⤢)\n if (plainScope && readsPlain(richText, value, field, path)) return null;\n return (\n <Tooltip content=\"Expand editor\" shortcut=\"⌘↵\">\n <button\n type=\"button\"\n aria-label={`Expand ${field.title}`}\n onClick={() => setFullEditor(`${env.docId}:${pathKey(path)}`)}\n className={cn(\n \"-my-0.5 hidden size-6 items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\",\n \"group-hover/field:inline-flex group-focus-within/field:!hidden [@media(pointer:coarse)]:inline-flex\",\n )}\n >\n <IconArrowsMaximize className=\"size-3.5\" stroke={1.5} aria-hidden />\n </button>\n </Tooltip>\n );\n}\n"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iB;CAEpC,IAAI,IAAI,YAAY,cAAc,CAAC,YAAY,QAAQ,OAAO;CAE9D,IAAI,cAAc,WAAW,UAAU,OAAO,OAAO,IAAI,GAAG,OAAO;CACnE,OACE,oBAAC,SAAD;EAAS,SAAQ;EAAgB,UAAS;EACxC,UAAA,oBAAC,UAAD;GACE,MAAK;GACL,cAAY,UAAU,MAAM;GAC5B,eAAe,cAAc,GAAG,IAAI,MAAM,GAAG,QAAQ,IAAI,GAAG;GAC5D,WAAW,GACT,uHACA,qGACF;GAEA,UAAA,oBAAC,oBAAD;IAAoB,WAAU;IAAW,QAAQ;IAAK,eAAA;GAAa,CAAA;EAC7D,CAAA;CACD,CAAA;AAEb"}
@@ -2,7 +2,7 @@
2
2
  * Expanded editing (CPO D49), owned by the engine: rich text, code and tables open in the ONE shared
3
3
  * ExpandedEditorModal (ui/expanded-editor-modal.tsx). V2 did this per control (RichTextControl + RichTextExpandAction,
4
4
  * TableControl + TableFullScreenAction); the engine opens the modal around WHATEVER control the field has: the kit
5
- * control from CONTROLS, or the host's when a control hands a stored value off (LegacyFallback). The modal body is that same control on the same value and the same onChange, so the field underneath
5
+ * control from CONTROLS. The modal body is that same control on the same value and the same onChange, so the field underneath
6
6
  * and the expanded one stay in sync and every write keeps the exact stored shape the inline control writes.
7
7
  *
8
8
  * Ways in (V2): the ⤢ button in the field's label row (shown on hover, always on touch), and ⌘↵ / Ctrl+↵ while the
@@ -12,7 +12,7 @@ import { IconArrowsMaximize } from "@tabler/icons-react";
12
12
  * Expanded editing (CPO D49), owned by the engine: rich text, code and tables open in the ONE shared
13
13
  * ExpandedEditorModal (ui/expanded-editor-modal.tsx). V2 did this per control (RichTextControl + RichTextExpandAction,
14
14
  * TableControl + TableFullScreenAction); the engine opens the modal around WHATEVER control the field has: the kit
15
- * control from CONTROLS, or the host's when a control hands a stored value off (LegacyFallback). The modal body is that same control on the same value and the same onChange, so the field underneath
15
+ * control from CONTROLS. The modal body is that same control on the same value and the same onChange, so the field underneath
16
16
  * and the expanded one stay in sync and every write keeps the exact stored shape the inline control writes.
17
17
  *
18
18
  * Ways in (V2): the ⤢ button in the field's label row (shown on hover, always on touch), and ⌘↵ / Ctrl+↵ while the
@@ -1 +1 @@
1
- {"version":3,"file":"expand.js","names":[],"sources":["../../src/engine/expand.tsx"],"sourcesContent":["/**\n * Expanded editing (CPO D49), owned by the engine: rich text, code and tables open in the ONE shared\n * ExpandedEditorModal (ui/expanded-editor-modal.tsx). V2 did this per control (RichTextControl + RichTextExpandAction,\n * TableControl + TableFullScreenAction); the engine opens the modal around WHATEVER control the field has: the kit\n * control from CONTROLS, or the host's when a control hands a stored value off (LegacyFallback). The modal body is that same control on the same value and the same onChange, so the field underneath\n * and the expanded one stay in sync and every write keeps the exact stored shape the inline control writes.\n *\n * Ways in (V2): the ⤢ button in the field's label row (shown on hover, always on touch), and ⌘↵ / Ctrl+↵ while the\n * field's control has focus. Inside the modal ⌘↵ or Esc closes it (menus and popovers inside close first) and focus\n * returns to whatever opened it. A control lane may open or close it from its own toolbar with `openExpanded`.\n *\n * Offered only where expanding edits something: never read-only, never a type whose control behind it cannot edit\n * (code and tables expand only once a kit control is registered for them; the host draws those read-only today).\n */\nimport * as React from \"react\";\nimport type { ComponentType } from \"react\";\nimport { IconArrowsMaximize } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { resolveFrames } from \"../lib/frames\";\nimport { isObj, pathKey } from \"../lib/path\";\nimport type { FieldPath, FieldSchema, SchemaType } from \"../schema/types\";\nimport type { ControlProps } from \"../types\";\nimport { useForm, useKitEnv } from \"../context\";\nimport { Tooltip } from \"../ui/overlay\";\nimport { ExpandedEditorModal } from \"../ui/expanded-editor-modal\";\n\nexport interface ExpandSpec {\n /** \"reading\" centres a ~720px writing column; \"wide\" uses the whole dialog (tables, code) */\n layout: \"reading\" | \"wide\";\n /** the header's quiet meta line for this value (\"12 lines\", \"6 rows · 4 columns\") */\n meta?: (value: unknown) => string;\n /** the label-row button's name and tooltip */\n label: \"Expand editor\" | \"Edit in full screen\";\n /** V2: the document variant already draws the full editor in its column, so writing types offer no ⤢ there */\n panelOnly?: boolean;\n /** expanding needs a kit control: the host's control for this type cannot edit it (read-only card) */\n needsKitControl?: boolean;\n}\n\nconst count = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;\nfunction codeLines(v: unknown) {\n const src = typeof v === \"string\" ? v : isObj(v) && typeof v.code === \"string\" ? v.code : \"\";\n return count(src ? src.split(\"\\n\").length : 0, \"line\");\n}\nfunction tableSize(v: unknown) {\n const rows = isObj(v) && Array.isArray(v.rows) ? v.rows.length : 0;\n const cols = isObj(v) && Array.isArray(v.columns) ? v.columns.length : 0;\n return `${count(rows, \"row\")} · ${count(cols, \"column\")}`;\n}\n\n/** Type → how it expands. Additive like CONTROLS: one entry per type. Plain long text (`text`) has none: V2's\n * TextControl is a bare textarea that grows to its value, so an extra ⤢ would only add a tab stop V2 lacks. */\nexport const EXPANDABLE: Partial<Record<SchemaType, ExpandSpec>> = {\n richtext: { layout: \"reading\", label: \"Expand editor\", panelOnly: true },\n code: { layout: \"wide\", meta: codeLines, label: \"Expand editor\", needsKitControl: true },\n table: { layout: \"wide\", meta: tableSize, label: \"Edit in full screen\", needsKitControl: true },\n};\n\n/** The spec when this field can expand here, else null. */\nexport function expandSpecFor(field: FieldSchema, opts: { readOnly: boolean; hasKitControl: boolean; variant: string }): ExpandSpec | null {\n const spec = EXPANDABLE[field.type];\n if (!spec || opts.readOnly) return null;\n if (spec.needsKitControl && !opts.hasKitControl) return null;\n if (spec.panelOnly && opts.variant === \"document\") return null;\n return spec;\n}\n\n/* ── which field (docId:pathKey) has its expanded editor open: one at a time, shared with toolbar buttons ── */\nlet openKey: string | null = null;\nconst subs = new Set<() => void>();\nexport function openExpanded(key: string | null) {\n if (openKey === key) return;\n openKey = key;\n subs.forEach((s) => s());\n}\nexport const expandKey = (docId: string, path: FieldPath) => `${docId}:${pathKey(path)}`;\nexport function useExpandedKey() {\n return React.useSyncExternalStore(\n (cb) => {\n subs.add(cb);\n return () => subs.delete(cb);\n },\n () => openKey,\n () => openKey,\n );\n}\n\n/** ⌘↵ / Ctrl+↵ (no Shift or Alt): the expand shortcut. */\nexport const isExpandShortcut = (e: React.KeyboardEvent | KeyboardEvent) => e.key === \"Enter\" && (e.metaKey || e.ctrlKey) && !e.shiftKey && !e.altKey;\n\n/** The label-row ⤢ (V2 RichTextExpandAction / TableFullScreenButton): hidden at rest until hover, always on touch. */\nexport function ExpandAction({ field, path, spec }: { field: FieldSchema; path: FieldPath; spec: ExpandSpec }) {\n const env = useKitEnv();\n const wide = spec.label === \"Edit in full screen\";\n return (\n <Tooltip content={spec.label} shortcut=\"⌘↵\">\n <button\n type=\"button\"\n aria-label={wide ? `Edit ${field.title} in full screen` : `Expand ${field.title}`}\n aria-haspopup=\"dialog\"\n data-kit-expand=\"\"\n onClick={() => openExpanded(expandKey(env.docId, path))}\n className={cn(\n \"-my-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-kit-md text-kit-fg-3 outline-none hover:bg-kit-hover hover:text-kit-fg\",\n \"focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-kit-focus-ring focus-visible:[outline-style:solid]\",\n // V2: quiet at rest (hover / touch shows it). Keyboard focus keeps it visible, so Tab never lands on nothing.\n \"opacity-0 group-hover/field:opacity-100 focus-visible:opacity-100 [@media(pointer:coarse)]:opacity-100\",\n )}\n >\n <IconArrowsMaximize aria-hidden className=\"size-3.5\" stroke={1.5} />\n </button>\n </Tooltip>\n );\n}\n\n/** The modal's breadcrumb: the document, the frames down to this field's parent, then the field. */\nfunction useCrumbs(field: FieldSchema, path: FieldPath): string[] {\n const form = useForm();\n const env = useKitEnv();\n if (!form) return [env.docTitle, field.title].filter(Boolean) as string[];\n const { frames } = resolveFrames(form.schema, form.value, path.slice(0, -1), form.resolveSchema);\n const titles = frames.filter((f) => f.kind !== \"history\").map((f, i) => (i === 0 ? env.docTitle || f.title : f.title));\n return [...titles, field.title].filter(Boolean);\n}\n\n/**\n * The field's expanded editor: the same control, value and onChange in the modal. Mounted only while open, so the\n * inline control and this one never fight over the same DOM id (the modal one gets `${id}-expanded`).\n */\nexport function ExpandedField({\n field,\n path,\n spec,\n Control,\n value,\n onChange,\n onBlur,\n invalid,\n id,\n parent,\n}: {\n field: FieldSchema;\n path: FieldPath;\n spec: ExpandSpec;\n Control: ComponentType<ControlProps>;\n value: unknown;\n onChange: (v: unknown) => void;\n onBlur?: () => void;\n invalid?: boolean;\n id: string;\n parent?: Record<string, unknown>;\n}) {\n const env = useKitEnv();\n const key = expandKey(env.docId, path);\n const open = useExpandedKey() === key;\n const crumbs = useCrumbs(field, path);\n // close when this field goes away (block deselected, drilled elsewhere, schema changed)\n React.useEffect(\n () => () => {\n if (openKey === key) openExpanded(null);\n },\n [key],\n );\n return (\n <ExpandedEditorModal\n open={open}\n onOpenChange={(o) => openExpanded(o ? key : null)}\n crumbs={crumbs}\n meta={spec.meta?.(value)}\n layout={spec.layout}\n returnFocus={() =>\n document.querySelector<HTMLElement>(`[data-field-key=\"${CSS.escape(pathKey(path))}\"] [data-kit-expand]`) ??\n document.getElementById(id)\n }\n >\n {open ? (\n <div\n data-kit-expanded={field.type}\n className={cn(\"min-w-0\", spec.layout === \"wide\" && \"flex min-h-0 flex-1 flex-col\")}\n onBlur={onBlur}\n onKeyDown={(e) => {\n if (!isExpandShortcut(e)) return;\n e.preventDefault();\n openExpanded(null);\n }}\n >\n <Control field={field} value={value} onChange={onChange} id={`${id}-expanded`} invalid={invalid} path={path} parent={parent} onBlur={onBlur} />\n </div>\n ) : null}\n </ExpandedEditorModal>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,SAAS,GAAW,KAAa,OAAO,GAAG,IAAI,OAAO,GAAG,EAAE,GAAG,MAAM,IAAI,MAAM;AACpF,SAAS,UAAU,GAAY;CAC7B,MAAM,MAAM,OAAO,MAAM,WAAW,IAAI,MAAM,CAAC,K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AAa,IAAI;CACxC,GACA,CAAC,GAAG,CACN;CACA,OACE,oBAAC,qBAAD;EACQ;EACN,eAAe,MAAM,aAAa,IAAI,MAAM,IAAI;EACxC;EACR,MAAM,KAAK,OAAO,KAAK;EACvB,QAAQ,KAAK;EACb,mBACE,SAAS,cAA2B,oBAAoB,IAAI,OAAO,QAAQ,IAAI,CAAC,EAAE,qBAAqB,KACvG,SAAS,eAAe,EAAE;EAG3B,UAAA,OACC,oBAAC,OAAD;GACE,qBAAmB,MAAM;GACzB,WAAW,GAAG,WAAW,KAAK,WAAW,UAAU,8BAA8B;GACzE;GACR,YAAY,MAAM;IAChB,IAAI,CAAC,iBAAiB,CAAC,GAAG;IAC1B,EAAE,eAAe;IACjB,aAAa,IAAI;GACnB;GAEA,UAAA,oBAAC,SAAD;IAAgB;IAAc;IAAiB;IAAU,IAAI,GAAG,GAAG;IAAqB;IAAe;IAAc;IAAgB;GAAS,CAAA;EAC3I,CAAA,IACH;CACe,CAAA;AAEzB"}
1
+ {"version":3,"file":"expand.js","names":[],"sources":["../../src/engine/expand.tsx"],"sourcesContent":["/**\n * Expanded editing (CPO D49), owned by the engine: rich text, code and tables open in the ONE shared\n * ExpandedEditorModal (ui/expanded-editor-modal.tsx). V2 did this per control (RichTextControl + RichTextExpandAction,\n * TableControl + TableFullScreenAction); the engine opens the modal around WHATEVER control the field has: the kit\n * control from CONTROLS. The modal body is that same control on the same value and the same onChange, so the field underneath\n * and the expanded one stay in sync and every write keeps the exact stored shape the inline control writes.\n *\n * Ways in (V2): the ⤢ button in the field's label row (shown on hover, always on touch), and ⌘↵ / Ctrl+↵ while the\n * field's control has focus. Inside the modal ⌘↵ or Esc closes it (menus and popovers inside close first) and focus\n * returns to whatever opened it. A control lane may open or close it from its own toolbar with `openExpanded`.\n *\n * Offered only where expanding edits something: never read-only, never a type whose control behind it cannot edit\n * (code and tables expand only once a kit control is registered for them; the host draws those read-only today).\n */\nimport * as React from \"react\";\nimport type { ComponentType } from \"react\";\nimport { IconArrowsMaximize } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { resolveFrames } from \"../lib/frames\";\nimport { isObj, pathKey } from \"../lib/path\";\nimport type { FieldPath, FieldSchema, SchemaType } from \"../schema/types\";\nimport type { ControlProps } from \"../types\";\nimport { useForm, useKitEnv } from \"../context\";\nimport { Tooltip } from \"../ui/overlay\";\nimport { ExpandedEditorModal } from \"../ui/expanded-editor-modal\";\n\nexport interface ExpandSpec {\n /** \"reading\" centres a ~720px writing column; \"wide\" uses the whole dialog (tables, code) */\n layout: \"reading\" | \"wide\";\n /** the header's quiet meta line for this value (\"12 lines\", \"6 rows · 4 columns\") */\n meta?: (value: unknown) => string;\n /** the label-row button's name and tooltip */\n label: \"Expand editor\" | \"Edit in full screen\";\n /** V2: the document variant already draws the full editor in its column, so writing types offer no ⤢ there */\n panelOnly?: boolean;\n /** expanding needs a kit control: the host's control for this type cannot edit it (read-only card) */\n needsKitControl?: boolean;\n}\n\nconst count = (n: number, one: string, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;\nfunction codeLines(v: unknown) {\n const src = typeof v === \"string\" ? v : isObj(v) && typeof v.code === \"string\" ? v.code : \"\";\n return count(src ? src.split(\"\\n\").length : 0, \"line\");\n}\nfunction tableSize(v: unknown) {\n const rows = isObj(v) && Array.isArray(v.rows) ? v.rows.length : 0;\n const cols = isObj(v) && Array.isArray(v.columns) ? v.columns.length : 0;\n return `${count(rows, \"row\")} · ${count(cols, \"column\")}`;\n}\n\n/** Type → how it expands. Additive like CONTROLS: one entry per type. Plain long text (`text`) has none: V2's\n * TextControl is a bare textarea that grows to its value, so an extra ⤢ would only add a tab stop V2 lacks. */\nexport const EXPANDABLE: Partial<Record<SchemaType, ExpandSpec>> = {\n richtext: { layout: \"reading\", label: \"Expand editor\", panelOnly: true },\n code: { layout: \"wide\", meta: codeLines, label: \"Expand editor\", needsKitControl: true },\n table: { layout: \"wide\", meta: tableSize, label: \"Edit in full screen\", needsKitControl: true },\n};\n\n/** The spec when this field can expand here, else null. */\nexport function expandSpecFor(field: FieldSchema, opts: { readOnly: boolean; hasKitControl: boolean; variant: string }): ExpandSpec | null {\n const spec = EXPANDABLE[field.type];\n if (!spec || opts.readOnly) return null;\n if (spec.needsKitControl && !opts.hasKitControl) return null;\n if (spec.panelOnly && opts.variant === \"document\") return null;\n return spec;\n}\n\n/* ── which field (docId:pathKey) has its expanded editor open: one at a time, shared with toolbar buttons ── */\nlet openKey: string | null = null;\nconst subs = new Set<() => void>();\nexport function openExpanded(key: string | null) {\n if (openKey === key) return;\n openKey = key;\n subs.forEach((s) => s());\n}\nexport const expandKey = (docId: string, path: FieldPath) => `${docId}:${pathKey(path)}`;\nexport function useExpandedKey() {\n return React.useSyncExternalStore(\n (cb) => {\n subs.add(cb);\n return () => subs.delete(cb);\n },\n () => openKey,\n () => openKey,\n );\n}\n\n/** ⌘↵ / Ctrl+↵ (no Shift or Alt): the expand shortcut. */\nexport const isExpandShortcut = (e: React.KeyboardEvent | KeyboardEvent) => e.key === \"Enter\" && (e.metaKey || e.ctrlKey) && !e.shiftKey && !e.altKey;\n\n/** The label-row ⤢ (V2 RichTextExpandAction / TableFullScreenButton): hidden at rest until hover, always on touch. */\nexport function ExpandAction({ field, path, spec }: { field: FieldSchema; path: FieldPath; spec: ExpandSpec }) {\n const env = useKitEnv();\n const wide = spec.label === \"Edit in full screen\";\n return (\n <Tooltip content={spec.label} shortcut=\"⌘↵\">\n <button\n type=\"button\"\n aria-label={wide ? `Edit ${field.title} in full screen` : `Expand ${field.title}`}\n aria-haspopup=\"dialog\"\n data-kit-expand=\"\"\n onClick={() => openExpanded(expandKey(env.docId, path))}\n className={cn(\n \"-my-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-kit-md text-kit-fg-3 outline-none hover:bg-kit-hover hover:text-kit-fg\",\n \"focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-kit-focus-ring focus-visible:[outline-style:solid]\",\n // V2: quiet at rest (hover / touch shows it). Keyboard focus keeps it visible, so Tab never lands on nothing.\n \"opacity-0 group-hover/field:opacity-100 focus-visible:opacity-100 [@media(pointer:coarse)]:opacity-100\",\n )}\n >\n <IconArrowsMaximize aria-hidden className=\"size-3.5\" stroke={1.5} />\n </button>\n </Tooltip>\n );\n}\n\n/** The modal's breadcrumb: the document, the frames down to this field's parent, then the field. */\nfunction useCrumbs(field: FieldSchema, path: FieldPath): string[] {\n const form = useForm();\n const env = useKitEnv();\n if (!form) return [env.docTitle, field.title].filter(Boolean) as string[];\n const { frames } = resolveFrames(form.schema, form.value, path.slice(0, -1), form.resolveSchema);\n const titles = frames.filter((f) => f.kind !== \"history\").map((f, i) => (i === 0 ? env.docTitle || f.title : f.title));\n return [...titles, field.title].filter(Boolean);\n}\n\n/**\n * The field's expanded editor: the same control, value and onChange in the modal. Mounted only while open, so the\n * inline control and this one never fight over the same DOM id (the modal one gets `${id}-expanded`).\n */\nexport function ExpandedField({\n field,\n path,\n spec,\n Control,\n value,\n onChange,\n onBlur,\n invalid,\n id,\n parent,\n}: {\n field: FieldSchema;\n path: FieldPath;\n spec: ExpandSpec;\n Control: ComponentType<ControlProps>;\n value: unknown;\n onChange: (v: unknown) => void;\n onBlur?: () => void;\n invalid?: boolean;\n id: string;\n parent?: Record<string, unknown>;\n}) {\n const env = useKitEnv();\n const key = expandKey(env.docId, path);\n const open = useExpandedKey() === key;\n const crumbs = useCrumbs(field, path);\n // close when this field goes away (block deselected, drilled elsewhere, schema changed)\n React.useEffect(\n () => () => {\n if (openKey === key) openExpanded(null);\n },\n [key],\n );\n return (\n <ExpandedEditorModal\n open={open}\n onOpenChange={(o) => openExpanded(o ? key : null)}\n crumbs={crumbs}\n meta={spec.meta?.(value)}\n layout={spec.layout}\n returnFocus={() =>\n document.querySelector<HTMLElement>(`[data-field-key=\"${CSS.escape(pathKey(path))}\"] [data-kit-expand]`) ??\n document.getElementById(id)\n }\n >\n {open ? (\n <div\n data-kit-expanded={field.type}\n className={cn(\"min-w-0\", spec.layout === \"wide\" && \"flex min-h-0 flex-1 flex-col\")}\n onBlur={onBlur}\n onKeyDown={(e) => {\n if (!isExpandShortcut(e)) return;\n e.preventDefault();\n openExpanded(null);\n }}\n >\n <Control field={field} value={value} onChange={onChange} id={`${id}-expanded`} invalid={invalid} path={path} parent={parent} onBlur={onBlur} />\n </div>\n ) : null}\n </ExpandedEditorModal>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,SAAS,GAAW,KAAa,OAAO,GAAG,IAAI,OAAO,GAAG,EAAE,GAAG,MAAM,IAAI,MAAM;AACpF,SAAS,UAAU,GAAY;CAC7B,MAAM,MAAM,OAAO,MAAM,WAAW,IAAI,MAAM,CAAC,KAAK,OAAO,EAAE,SAAS,WAAW,EAAE,OAAO;CAC1F,OAAO,MAAM,MAAM,IAAI,MAAM,IAAI,CAAC,CAAC,SAAS,GAAG,MAAM;AACvD;AACA,SAAS,UAAU,GAAY;CAC7B,MAAM,OAAO,MAAM,CAAC,KAAK,MAAM,QAAQ,EAAE,IAAI,IAAI,EAAE,KAAK,SAAS;CACjE,MAAM,OAAO,MAAM,CAAC,KAAK,MAAM,QAAQ,EAAE,OAAO,IAAI,EAAE,QAAQ,SAAS;CACvE,OAAO,GAAG,MAAM,MAAM,KAAK,EAAE,KAAK,MAAM,MAAM,QAAQ;AACxD;;;AAIA,IAAa,aAAsD;CACjE,UAAU;EAAE,QAAQ;EAAW,OAAO;EAAiB,WAAW;CAAK;CACvE,MAAM;EAAE,QAAQ;EAAQ,MAAM;EAAW,OAAO;EAAiB,iBAAiB;CAAK;CACvF,OAAO;EAAE,QAAQ;EAAQ,MAAM;EAAW,OAAO;EAAuB,iBAAiB;CAAK;AAChG;;AAGA,SAAgB,cAAc,OAAoB,MAAyF;CACzI,MAAM,OAAO,WAAW,MAAM;CAC9B,IAAI,CAAC,QAAQ,KAAK,UAAU,OAAO;CACnC,IAAI,KAAK,mBAAmB,CAAC,KAAK,eAAe,OAAO;C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E,GAAG,KAAK,aAAa;CAE/F,OAAO,CAAC,GADO,OAAO,QAAQ,MAAM,EAAE,SAAS,SAAS,CAAC,CAAC,KAAK,GAAG,MAAO,MAAM,IAAI,IAAI,YAAY,EAAE,QAAQ,EAAE,KACpG,GAAQ,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;AAChD;;;;;AAMA,SAAgB,cAAc,EAC5B,OACA,MACA,MACA,SACA,OACA,UACA,QACA,SACA,IACA,UAYC;CAED,MAAM,MAAM,UADA,UACU,CAAA,CAAI,OAAO,IAAI;CACrC,MAAM,OAAO,eAAe,MAAM;CAClC,MAAM,SAAS,UAAU,OAAO,IAAI;CAEpC,MAAM,sBACQ;EACV,IAAI,YAAY,KAAK,aAAa,IAAI;CACxC,GACA,CAAC,GAAG,CACN;CACA,OACE,oBAAC,qBAAD;EACQ;EACN,eAAe,MAAM,aAAa,IAAI,MAAM,IAAI;EACxC;EACR,MAAM,KAAK,OAAO,KAAK;EACvB,QAAQ,KAAK;EACb,mBACE,SAAS,cAA2B,oBAAoB,IAAI,OAAO,QAAQ,IAAI,CAAC,EAAE,qBAAqB,KACvG,SAAS,eAAe,EAAE;EAG3B,UAAA,OACC,oBAAC,OAAD;GACE,qBAAmB,MAAM;GACzB,WAAW,GAAG,WAAW,KAAK,WAAW,UAAU,8BAA8B;GACzE;GACR,YAAY,MAAM;IAChB,IAAI,CAAC,iBAAiB,CAAC,GAAG;IAC1B,EAAE,eAAe;IACjB,aAAa,IAAI;GACnB;GAEA,UAAA,oBAAC,SAAD;IAAgB;IAAc;IAAiB;IAAU,IAAI,GAAG,GAAG;IAAqB;IAAe;IAAc;IAAgB;GAAS,CAAA;EAC3I,CAAA,IACH;CACe,CAAA;AAEzB"}
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * A held field is one the form cannot edit without changing what is stored: it renders read-only inside the usual
5
5
  * FieldShell (label, help), shows the stored value as faithfully as the kit can (rich text as its HTML, scalars as text,
6
- * objects and lists as a short readable summary), names why in one line, and never writes. It replaces handing the
7
- * value to the host's old control (LegacyFallback, removed in 4.0.0).
6
+ * objects and lists as a short readable summary), names why in one line, and never writes. Kit 4.0.0 removed the
7
+ * host-control hand-off it replaced.
8
8
  *
9
9
  * - `FieldSchema.held` / `KitServices.heldReason`: the host holds a field (KitField checks both before anything else)
10
10
  * - a control that refuses a value (rich text the codec cannot carry) draws `HeldValue` in its place
@@ -14,8 +14,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
14
14
  *
15
15
  * A held field is one the form cannot edit without changing what is stored: it renders read-only inside the usual
16
16
  * FieldShell (label, help), shows the stored value as faithfully as the kit can (rich text as its HTML, scalars as text,
17
- * objects and lists as a short readable summary), names why in one line, and never writes. It replaces handing the
18
- * value to the host's old control (LegacyFallback, removed in 4.0.0).
17
+ * objects and lists as a short readable summary), names why in one line, and never writes. Kit 4.0.0 removed the
18
+ * host-control hand-off it replaced.
19
19
  *
20
20
  * - `FieldSchema.held` / `KitServices.heldReason`: the host holds a field (KitField checks both before anything else)
21
21
  * - a control that refuses a value (rich text the codec cannot carry) draws `HeldValue` in its place
@@ -1 +1 @@
1
- {"version":3,"file":"held.js","names":[],"sources":["../../src/engine/held.tsx"],"sourcesContent":["/**\n * HELD fields and the kit's error surfaces (kit 3.2.0).\n *\n * A held field is one the form cannot edit without changing what is stored: it renders read-only inside the usual\n * FieldShell (label, help), shows the stored value as faithfully as the kit can (rich text as its HTML, scalars as text,\n * objects and lists as a short readable summary), names why in one line, and never writes. It replaces handing the\n * value to the host's old control (LegacyFallback, removed in 4.0.0).\n *\n * - `FieldSchema.held` / `KitServices.heldReason`: the host holds a field (KitField checks both before anything else)\n * - a control that refuses a value (rich text the codec cannot carry) draws `HeldValue` in its place\n * - a control that throws while rendering: `FieldBoundary` holds that one field; the rest of the form keeps working\n * - a whole form that throws: the host draws `KitErrorCard` (reason, \"Nothing was changed.\", Retry)\n *\n * Markers: the value box carries `data-kit-held=\"<type>\"`, its reason line `data-slot=\"kit-held-reason\"`, the error card\n * `data-kit-error`.\n */\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport { plainText } from \"../lib/schema\";\nimport type { FieldPath, FieldSchema } from \"../schema/types\";\nimport { useForm } from \"../context\";\nimport { Button } from \"../ui/button\";\nimport { sanitize } from \"../controls/rich-text/dom\";\nimport { FieldShell } from \"./field-shell\";\nimport { plainOf } from \"./kit-field\";\n\nconst sentence = (s: string) => s.trim().replace(/[.\\s]*$/, \".\");\nconst noop = () => {};\n\n/** The HTML a stored rich-text value carries (an HTML string, a `{ html }` / `{ format: \"html\", value }` envelope), or null. */\nfunction storedHtml(value: unknown): string | null {\n if (typeof value === \"string\") return /<[a-z!/]/i.test(value) ? value : null;\n if (!isObj(value)) return null;\n if (typeof value.html === \"string\" && value.html) return value.html;\n if (value.format === \"html\" && typeof value.value === \"string\") return value.value;\n return null;\n}\n\n/** One list item in a few words: its own text (title, label, name, block text) or a plain count of what it holds. */\nfunction itemText(v: unknown): string {\n if (v == null || v === \"\") return \"Empty\";\n if (typeof v !== \"object\") return String(v);\n const t = plainText(v);\n if (t) return t;\n if (Array.isArray(v)) return `${v.length} ${v.length === 1 ? \"item\" : \"items\"}`;\n const n = Object.keys(v).filter((k) => !k.startsWith(\"_\")).length;\n return `${n} ${n === 1 ? \"field\" : \"fields\"}`;\n}\n\nconst clip = (s: string, n = 120) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);\nconst MAX_LINES = 6;\n\n/**\n * A stored value as readable lines (never a JSON dump unless nothing else reads): a scalar is its text, a list is its\n * count and its first items, an object its set keys by their field titles.\n */\nexport function heldLines(field: FieldSchema, value: unknown): string[] {\n if (value == null || value === \"\" || (Array.isArray(value) && !value.length)) return [];\n if (Array.isArray(value)) {\n const head = `${value.length} ${value.length === 1 ? \"item\" : \"items\"}`;\n const items = value.slice(0, MAX_LINES).map((v) => clip(itemText(v)));\n return [head, ...items, ...(value.length > MAX_LINES ? [`and ${value.length - MAX_LINES} more`] : [])];\n }\n if (isObj(value)) {\n if (field.type === \"richtext\") {\n const t = plainText(value);\n return t ? [t] : [];\n }\n const titleOf = (k: string) => field.fields?.find((f) => f.name === k)?.title ?? k;\n const lines = Object.entries(value)\n .filter(([k, v]) => !k.startsWith(\"_\") && v != null && v !== \"\" && !(Array.isArray(v) && !v.length))\n .map(([k, v]) => `${titleOf(k)}: ${clip(itemText(v), 80)}`);\n if (lines.length) return lines.length > MAX_LINES ? [...lines.slice(0, MAX_LINES), `and ${lines.length - MAX_LINES} more`] : lines;\n const raw = JSON.stringify(value);\n return raw && raw !== \"{}\" ? [clip(raw, 200)] : [];\n }\n const t = field.type === \"richtext\" ? plainText(value) : plainOf(field, value) || String(value);\n return t ? [t] : [];\n}\n\nexport interface HeldValueProps {\n field: FieldSchema;\n value: unknown;\n /** the FieldShell id: the shell's label names this box */\n id: string;\n /** why the field is held, as a clause or a sentence (\"it holds formatting this editor cannot keep\") */\n reason: string;\n /** rich text: the HTML the codec read for the value, when it could read it (shown read-only, sanitized) */\n html?: string;\n}\n\n/**\n * The body of a held field (inside a FieldShell): the reason line, then the stored value read-only. Takes no onChange,\n * so it cannot write.\n */\nexport function HeldValue({ field, value, id, reason, html }: HeldValueProps) {\n const rich = field.type === \"richtext\" ? (html ?? storedHtml(value)) : null;\n const lines = rich == null ? heldLines(field, value) : [];\n return (\n <div data-kit-held={field.type} className=\"flex min-w-0 flex-col gap-1.5\">\n <p role=\"note\" data-slot=\"kit-held-reason\" className=\"rounded-kit-md bg-kit-subtle px-2.5 py-1.5 text-kit-xs text-kit-fg-2\">\n Shown read-only: {sentence(reason)}\n </p>\n <div\n id={id}\n tabIndex={0}\n role=\"group\"\n aria-labelledby={`${id}-label ${id}`}\n aria-readonly=\"true\"\n data-slot=\"kit-held-value\"\n className={cn(\n \"min-w-0 break-words rounded-kit-sm text-kit-sm leading-6 text-kit-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kit-focus-ring focus-visible:[outline-style:solid] [html[data-input-modality=pointer]_&]:focus-visible:outline-0\",\n rich == null && \"whitespace-pre-wrap\",\n )}\n >\n {rich != null ? (\n <div data-slot=\"kit-held-html\" className=\"[&_a]:underline [&_ol]:list-decimal [&_ol]:pl-5 [&_ul]:list-disc [&_ul]:pl-5\" dangerouslySetInnerHTML={{ __html: sanitize(rich) }} />\n ) : lines.length ? (\n lines.length === 1 ? (\n lines[0]\n ) : (\n <ul className=\"flex flex-col\">\n {lines.map((l, i) => (\n <li key={i} className={cn(i === 0 && Array.isArray(value) ? \"text-kit-xs text-kit-fg-3\" : undefined)}>\n {l}\n </li>\n ))}\n </ul>\n )\n ) : (\n <span className=\"text-kit-fg-3\">Empty</span>\n )}\n </div>\n </div>\n );\n}\n\n/** A whole held field: the kit FieldShell (label, help, read-only) around HeldValue. Must be inside <SchemaForm>. */\nexport function HeldField({ field, path, reason, html }: { field: FieldSchema; path: FieldPath; reason: string; html?: string }) {\n const form = useForm();\n const id = React.useId();\n const value = form?.getAt(path);\n return (\n <FieldShell field={field} path={path} id={id} value={value} onChange={noop} readOnly>\n <HeldValue field={field} value={value} id={id} reason={reason} html={html} />\n </FieldShell>\n );\n}\n\n/**\n * One field's error boundary: a control that throws while rendering holds that field (\"this field could not be drawn:\n * <message>\") and the rest of the form keeps working. Retried once the field's schema or value changes (a schema edit,\n * a save from elsewhere, an undo).\n */\nexport class FieldBoundary extends React.Component<\n { field: FieldSchema; path: FieldPath; value: unknown; children: React.ReactNode },\n { reason: string | null }\n> {\n state = { reason: null as string | null };\n static getDerivedStateFromError(error: unknown) {\n return { reason: error instanceof Error ? error.message : String(error) };\n }\n componentDidUpdate(prev: { field: FieldSchema; value: unknown }) {\n if (this.state.reason === null) return;\n if (prev.value !== this.props.value || JSON.stringify(prev.field) !== JSON.stringify(this.props.field)) this.setState({ reason: null });\n }\n render() {\n if (this.state.reason === null) return this.props.children;\n return <HeldField field={this.props.field} path={this.props.path} reason={`this field could not be drawn: ${this.state.reason}`} />;\n }\n}\n\nexport interface KitErrorCardProps {\n /** what failed, as a sentence or a clause (\"The form could not be drawn: x is undefined\") */\n reason: string;\n /** draws the form again */\n onRetry: () => void;\n className?: string;\n}\n\n/**\n * For a form that throws as a whole: the reason, \"Nothing was changed.\", and Retry. Carries `data-kit-error`. The host\n * reports the error itself; this card only shows it.\n */\nexport function KitErrorCard({ reason, onRetry, className }: KitErrorCardProps) {\n return (\n <div role=\"alert\" data-kit-error=\"\" className={cn(\"flex flex-col items-start gap-2 rounded-kit-lg border border-kit-line bg-kit-subtle p-3\", className)}>\n <p data-slot=\"kit-error-reason\" className=\"text-kit-sm text-kit-fg\">\n {sentence(reason)}\n </p>\n <p className=\"text-kit-xs text-kit-fg-2\">Nothing was changed.</p>\n <Button variant=\"secondary\" size=\"sm\" onClick={onRetry}>\n Retry\n </Button>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAM,YAAY,MAAc,EAAE,KAAK,CAAC,CAAC,QAAQ,WAAW,GAAG;AAC/D,IAAM,aAAa,CAAC;;AAGpB,SAAS,WAAW,OAA+B;CACjD,IAAI,OAAO,UAAU,UAAU,OAAO,YAAY,KAAK,KAAK,IAAI,QAAQ;CACxE,IAAI,CAAC,MAAM,KAAK,GAAG,OAAO;CAC1B,IAAI,OAAO,MAAM,SAAS,YAAY,MAAM,MAAM,OAAO,MAAM;CAC/D,IAAI,MAAM,WAAW,UAAU,OAAO,MAAM,UAAU,UAAU,OAAO,MAAM;CAC7E,OAAO;AACT;;AAGA,SAAS,SAAS,GAAoB;CACpC,IAAI,KAAK,QAAQ,MAAM,IAAI,OAAO;CAClC,IAAI,OAAO,MAAM,UAAU,OAAO,OAAO,CAAC;CAC1C,MAAM,IAAI,UAAU,CAAC;CACrB,IAAI,GAAG,OAAO;CACd,IAAI,MAAM,QAAQ,CAAC,GAAG,OAAO,GAAG,EAAE,OAAO,GAAG,EAAE,WAAW,IAAI,SAAS;CACtE,MAAM,IAAI,OAAO,KAAK,CAAC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C,QAAD;IAAQ,SAAQ;IAAY,MAAK;IAAK,SAAS;IAAS,UAAA;GAEhD,CAAA;EACL;;AAET"}
1
+ {"version":3,"file":"held.js","names":[],"sources":["../../src/engine/held.tsx"],"sourcesContent":["/**\n * HELD fields and the kit's error surfaces (kit 3.2.0).\n *\n * A held field is one the form cannot edit without changing what is stored: it renders read-only inside the usual\n * FieldShell (label, help), shows the stored value as faithfully as the kit can (rich text as its HTML, scalars as text,\n * objects and lists as a short readable summary), names why in one line, and never writes. Kit 4.0.0 removed the\n * host-control hand-off it replaced.\n *\n * - `FieldSchema.held` / `KitServices.heldReason`: the host holds a field (KitField checks both before anything else)\n * - a control that refuses a value (rich text the codec cannot carry) draws `HeldValue` in its place\n * - a control that throws while rendering: `FieldBoundary` holds that one field; the rest of the form keeps working\n * - a whole form that throws: the host draws `KitErrorCard` (reason, \"Nothing was changed.\", Retry)\n *\n * Markers: the value box carries `data-kit-held=\"<type>\"`, its reason line `data-slot=\"kit-held-reason\"`, the error card\n * `data-kit-error`.\n */\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport { plainText } from \"../lib/schema\";\nimport type { FieldPath, FieldSchema } from \"../schema/types\";\nimport { useForm } from \"../context\";\nimport { Button } from \"../ui/button\";\nimport { sanitize } from \"../controls/rich-text/dom\";\nimport { FieldShell } from \"./field-shell\";\nimport { plainOf } from \"./kit-field\";\n\nconst sentence = (s: string) => s.trim().replace(/[.\\s]*$/, \".\");\nconst noop = () => {};\n\n/** The HTML a stored rich-text value carries (an HTML string, a `{ html }` / `{ format: \"html\", value }` envelope), or null. */\nfunction storedHtml(value: unknown): string | null {\n if (typeof value === \"string\") return /<[a-z!/]/i.test(value) ? value : null;\n if (!isObj(value)) return null;\n if (typeof value.html === \"string\" && value.html) return value.html;\n if (value.format === \"html\" && typeof value.value === \"string\") return value.value;\n return null;\n}\n\n/** One list item in a few words: its own text (title, label, name, block text) or a plain count of what it holds. */\nfunction itemText(v: unknown): string {\n if (v == null || v === \"\") return \"Empty\";\n if (typeof v !== \"object\") return String(v);\n const t = plainText(v);\n if (t) return t;\n if (Array.isArray(v)) return `${v.length} ${v.length === 1 ? \"item\" : \"items\"}`;\n const n = Object.keys(v).filter((k) => !k.startsWith(\"_\")).length;\n return `${n} ${n === 1 ? \"field\" : \"fields\"}`;\n}\n\nconst clip = (s: string, n = 120) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);\nconst MAX_LINES = 6;\n\n/**\n * A stored value as readable lines (never a JSON dump unless nothing else reads): a scalar is its text, a list is its\n * count and its first items, an object its set keys by their field titles.\n */\nexport function heldLines(field: FieldSchema, value: unknown): string[] {\n if (value == null || value === \"\" || (Array.isArray(value) && !value.length)) return [];\n if (Array.isArray(value)) {\n const head = `${value.length} ${value.length === 1 ? \"item\" : \"items\"}`;\n const items = value.slice(0, MAX_LINES).map((v) => clip(itemText(v)));\n return [head, ...items, ...(value.length > MAX_LINES ? [`and ${value.length - MAX_LINES} more`] : [])];\n }\n if (isObj(value)) {\n if (field.type === \"richtext\") {\n const t = plainText(value);\n return t ? [t] : [];\n }\n const titleOf = (k: string) => field.fields?.find((f) => f.name === k)?.title ?? k;\n const lines = Object.entries(value)\n .filter(([k, v]) => !k.startsWith(\"_\") && v != null && v !== \"\" && !(Array.isArray(v) && !v.length))\n .map(([k, v]) => `${titleOf(k)}: ${clip(itemText(v), 80)}`);\n if (lines.length) return lines.length > MAX_LINES ? [...lines.slice(0, MAX_LINES), `and ${lines.length - MAX_LINES} more`] : lines;\n const raw = JSON.stringify(value);\n return raw && raw !== \"{}\" ? [clip(raw, 200)] : [];\n }\n const t = field.type === \"richtext\" ? plainText(value) : plainOf(field, value) || String(value);\n return t ? [t] : [];\n}\n\nexport interface HeldValueProps {\n field: FieldSchema;\n value: unknown;\n /** the FieldShell id: the shell's label names this box */\n id: string;\n /** why the field is held, as a clause or a sentence (\"it holds formatting this editor cannot keep\") */\n reason: string;\n /** rich text: the HTML the codec read for the value, when it could read it (shown read-only, sanitized) */\n html?: string;\n}\n\n/**\n * The body of a held field (inside a FieldShell): the reason line, then the stored value read-only. Takes no onChange,\n * so it cannot write.\n */\nexport function HeldValue({ field, value, id, reason, html }: HeldValueProps) {\n const rich = field.type === \"richtext\" ? (html ?? storedHtml(value)) : null;\n const lines = rich == null ? heldLines(field, value) : [];\n return (\n <div data-kit-held={field.type} className=\"flex min-w-0 flex-col gap-1.5\">\n <p role=\"note\" data-slot=\"kit-held-reason\" className=\"rounded-kit-md bg-kit-subtle px-2.5 py-1.5 text-kit-xs text-kit-fg-2\">\n Shown read-only: {sentence(reason)}\n </p>\n <div\n id={id}\n tabIndex={0}\n role=\"group\"\n aria-labelledby={`${id}-label ${id}`}\n aria-readonly=\"true\"\n data-slot=\"kit-held-value\"\n className={cn(\n \"min-w-0 break-words rounded-kit-sm text-kit-sm leading-6 text-kit-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kit-focus-ring focus-visible:[outline-style:solid] [html[data-input-modality=pointer]_&]:focus-visible:outline-0\",\n rich == null && \"whitespace-pre-wrap\",\n )}\n >\n {rich != null ? (\n <div data-slot=\"kit-held-html\" className=\"[&_a]:underline [&_ol]:list-decimal [&_ol]:pl-5 [&_ul]:list-disc [&_ul]:pl-5\" dangerouslySetInnerHTML={{ __html: sanitize(rich) }} />\n ) : lines.length ? (\n lines.length === 1 ? (\n lines[0]\n ) : (\n <ul className=\"flex flex-col\">\n {lines.map((l, i) => (\n <li key={i} className={cn(i === 0 && Array.isArray(value) ? \"text-kit-xs text-kit-fg-3\" : undefined)}>\n {l}\n </li>\n ))}\n </ul>\n )\n ) : (\n <span className=\"text-kit-fg-3\">Empty</span>\n )}\n </div>\n </div>\n );\n}\n\n/** A whole held field: the kit FieldShell (label, help, read-only) around HeldValue. Must be inside <SchemaForm>. */\nexport function HeldField({ field, path, reason, html }: { field: FieldSchema; path: FieldPath; reason: string; html?: string }) {\n const form = useForm();\n const id = React.useId();\n const value = form?.getAt(path);\n return (\n <FieldShell field={field} path={path} id={id} value={value} onChange={noop} readOnly>\n <HeldValue field={field} value={value} id={id} reason={reason} html={html} />\n </FieldShell>\n );\n}\n\n/**\n * One field's error boundary: a control that throws while rendering holds that field (\"this field could not be drawn:\n * <message>\") and the rest of the form keeps working. Retried once the field's schema or value changes (a schema edit,\n * a save from elsewhere, an undo).\n */\nexport class FieldBoundary extends React.Component<\n { field: FieldSchema; path: FieldPath; value: unknown; children: React.ReactNode },\n { reason: string | null }\n> {\n state = { reason: null as string | null };\n static getDerivedStateFromError(error: unknown) {\n return { reason: error instanceof Error ? error.message : String(error) };\n }\n componentDidUpdate(prev: { field: FieldSchema; value: unknown }) {\n if (this.state.reason === null) return;\n if (prev.value !== this.props.value || JSON.stringify(prev.field) !== JSON.stringify(this.props.field)) this.setState({ reason: null });\n }\n render() {\n if (this.state.reason === null) return this.props.children;\n return <HeldField field={this.props.field} path={this.props.path} reason={`this field could not be drawn: ${this.state.reason}`} />;\n }\n}\n\nexport interface KitErrorCardProps {\n /** what failed, as a sentence or a clause (\"The form could not be drawn: x is undefined\") */\n reason: string;\n /** draws the form again */\n onRetry: () => void;\n className?: string;\n}\n\n/**\n * For a form that throws as a whole: the reason, \"Nothing was changed.\", and Retry. Carries `data-kit-error`. The host\n * reports the error itself; this card only shows it.\n */\nexport function KitErrorCard({ reason, onRetry, className }: KitErrorCardProps) {\n return (\n <div role=\"alert\" data-kit-error=\"\" className={cn(\"flex flex-col items-start gap-2 rounded-kit-lg border border-kit-line bg-kit-subtle p-3\", className)}>\n <p data-slot=\"kit-error-reason\" className=\"text-kit-sm text-kit-fg\">\n {sentence(reason)}\n </p>\n <p className=\"text-kit-xs text-kit-fg-2\">Nothing was changed.</p>\n <Button variant=\"secondary\" size=\"sm\" onClick={onRetry}>\n Retry\n </Button>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAM,YAAY,MAAc,EAAE,KAAK,CAAC,CAAC,QAAQ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AAU,KAAK,MAAM,SAAS,KAAK,UAAU,KAAK,KAAK,MAAM,KAAK,UAAU,KAAK,MAAM,KAAK,GAAG,KAAK,SAAS,EAAE,QAAQ,KAAK,CAAC;CACxI;CACA,SAAS;EACP,IAAI,KAAK,MAAM,WAAW,MAAM,OAAO,KAAK,MAAM;EAClD,OAAO,oBAAC,WAAD;GAAW,OAAO,KAAK,MAAM;GAAO,MAAM,KAAK,MAAM;GAAM,QAAQ,kCAAkC,KAAK,MAAM;EAAW,CAAA;CACpI;AACF;;;;;AAcA,SAAgB,aAAa,EAAE,QAAQ,SAAS,aAAgC;CAC9E,OACE,qBAAC,OAAD;EAAK,MAAK;EAAQ,kBAAe;EAAG,WAAW,GAAG,2FAA2F,SAAS;EAAtJ,UAAA;GACE,oBAAC,KAAD;IAAG,aAAU;IAAmB,WAAU;IACvC,UAAA,SAAS,MAAM;GACf,CAAA;GACH,oBAAC,KAAD;IAAG,WAAU;IAA4B,UAAA;GAAuB,CAAA;GAChE,oBAAC,QAAD;IAAQ,SAAQ;IAAY,MAAK;IAAK,SAAS;IAAS,UAAA;GAEhD,CAAA;EACL;;AAET"}
@@ -66,13 +66,3 @@ export declare function plainOf(field: FieldSchema, value: unknown): string;
66
66
  * value is shown and kept, and an edit is written only once it parses.
67
67
  */
68
68
  export declare function FallbackControl(props: ControlProps): import("react/jsx-runtime").JSX.Element;
69
- /**
70
- * A control that cannot carry a stored value unchanged (rich text holding formatting its editor would drop) hands that
71
- * value to the host's control for the type (KitServices.LegacyControl: the dashboard's FieldRenderer arm), bare inside
72
- * the kit FieldShell, which owns the label and the help; the control names its reason above it. The box carries
73
- * `data-kit-legacy="<type>"`, so the parity harness counts it (mismatch class `legacy-control`). A control that throws
74
- * while rendering says why in words; the form around it keeps working.
75
- * Kit 3.2.0: a host with no LegacyControl gets a HELD field instead (held.tsx: the value read-only, with the reason, no
76
- * `data-kit-legacy`). LegacyControl, this hand-off and `data-kit-legacy` are removed in 4.0.0.
77
- */
78
- export declare function LegacyFallback(props: ControlProps): import("react/jsx-runtime").JSX.Element;
@@ -17,7 +17,7 @@ import { ExpandAction, ExpandedField, expandKey, expandSpecFor, isExpandShortcut
17
17
  import { SchemaForm } from "./schema-form.js";
18
18
  import { SlotField } from "./slot.js";
19
19
  import { JsonControl } from "../controls/json.js";
20
- import { FieldBoundary, HeldField, HeldValue } from "./held.js";
20
+ import { FieldBoundary, HeldField } from "./held.js";
21
21
  import * as React from "react";
22
22
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
23
23
  import { IconChevronRight } from "@tabler/icons-react";
@@ -510,73 +510,7 @@ function FallbackControl(props) {
510
510
  children: /* @__PURE__ */ jsx(JsonControl, { ...props })
511
511
  });
512
512
  }
513
- /**
514
- * A control that cannot carry a stored value unchanged (rich text holding formatting its editor would drop) hands that
515
- * value to the host's control for the type (KitServices.LegacyControl: the dashboard's FieldRenderer arm), bare inside
516
- * the kit FieldShell, which owns the label and the help; the control names its reason above it. The box carries
517
- * `data-kit-legacy="<type>"`, so the parity harness counts it (mismatch class `legacy-control`). A control that throws
518
- * while rendering says why in words; the form around it keeps working.
519
- * Kit 3.2.0: a host with no LegacyControl gets a HELD field instead (held.tsx: the value read-only, with the reason, no
520
- * `data-kit-legacy`). LegacyControl, this hand-off and `data-kit-legacy` are removed in 4.0.0.
521
- */
522
- function LegacyFallback(props) {
523
- const { LegacyControl } = useKitServices();
524
- const { field, id } = props;
525
- if (!LegacyControl) return /* @__PURE__ */ jsx(HeldValue, {
526
- field,
527
- value: props.value,
528
- id,
529
- reason: `this view has no control for ${field.type} fields`
530
- });
531
- return /* @__PURE__ */ jsx("div", {
532
- "data-kit-legacy": field.type,
533
- className: "min-w-0",
534
- children: /* @__PURE__ */ jsx(LegacyBoundary, {
535
- field,
536
- id,
537
- value: props.value,
538
- children: /* @__PURE__ */ jsx(LegacyControl, { ...props })
539
- }, JSON.stringify(field))
540
- });
541
- }
542
- /**
543
- * An `<output>`: a labelable element, so the FieldShell label's `for` lands on it, and focusable, so a keyboard user
544
- * reaches the reason. The neutral focus ring shows under keyboard modality only.
545
- */
546
- function LegacyRefusal({ id, children }) {
547
- return /* @__PURE__ */ jsx("output", {
548
- id,
549
- role: "note",
550
- tabIndex: 0,
551
- "data-slot": "kit-legacy-refusal",
552
- className: "block rounded-kit-sm text-kit-xs text-kit-fg-3 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kit-focus-ring focus-visible:[outline-style:solid] [html[data-input-modality=pointer]_&]:focus-visible:outline-0",
553
- children
554
- });
555
- }
556
- /** Retries the control once its field or value changes (a schema edit, a save from elsewhere, an undo). */
557
- var LegacyBoundary = class extends React.Component {
558
- state = { reason: null };
559
- static getDerivedStateFromError(error) {
560
- return { reason: error instanceof Error ? error.message : String(error) };
561
- }
562
- componentDidUpdate(prev) {
563
- if (this.state.reason === null) return;
564
- if (prev.value !== this.props.value || JSON.stringify(prev.field) !== JSON.stringify(this.props.field)) this.setState({ reason: null });
565
- }
566
- render() {
567
- if (this.state.reason === null) return this.props.children;
568
- return /* @__PURE__ */ jsxs(LegacyRefusal, {
569
- id: this.props.id,
570
- children: [
571
- "The ",
572
- this.props.field.title,
573
- " control could not load: ",
574
- this.state.reason
575
- ]
576
- });
577
- }
578
- };
579
513
  //#endregion
580
- export { ACTIONS, ACTION_WHEN_READ_ONLY, CONTROLS, FallbackControl, KitField, LegacyFallback, NavRow, NestedForm, plainOf, useFieldAccess, withDefaultHelp };
514
+ export { ACTIONS, ACTION_WHEN_READ_ONLY, CONTROLS, FallbackControl, KitField, NavRow, NestedForm, plainOf, useFieldAccess, withDefaultHelp };
581
515
 
582
516
  //# sourceMappingURL=kit-field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"kit-field.js","names":[],"sources":["../../src/engine/kit-field.tsx"],"sourcesContent":["/**\n * KitField — renders ONE field of the schema at `path` (must be inside <SchemaForm>): the shell + the control for its\n * type (V2 HEAD 9829bf1 kit/engine/kit-field.tsx).\n *\n * Arrays (array.tsx) and slots (slot.tsx) get their rows; objects open inline (FieldInset), drill (NavRow -> a frame),\n * popover or dialog (NestedForm: its own navigation stack). Primitive types dispatch through the CONTROLS table, which\n * the controls lanes fill. Every SchemaType has a control there; a type that is none of them (a schema newer than this\n * kit) edits its raw value in the JSON control (FallbackControl), never nothing and never a stand-in.\n */\nimport * as React from \"react\";\nimport type { ComponentType } from \"react\";\nimport { IconChevronRight } from \"@tabler/icons-react\";\nimport { KitIcon } from \"../lib/icons\";\nimport { cn } from \"../lib/cn\";\nimport type { FieldPath, FieldSchema, PrimitiveType, SchemaType } from \"../schema/types\";\nimport { resolveHelp } from \"../schema/help\";\nimport type { ControlProps } from \"../types\";\nimport { resolveFieldAccess, useForm, useKitEnv, useKitServices, type KitPeer } from \"../context\";\nimport { Button } from \"../ui/button\";\nimport { Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, Popover, PopoverContent, PopoverTrigger } from \"../ui/overlay\";\nimport { isObj, pathKey } from \"../lib/path\";\nimport { condCtx, isHidden, objectOpenMode, plainText, summarize } from \"../lib/schema\";\nimport { isIconImage } from \"../lib/icon-image\";\nimport { ArrayField, type NestedFormProps } from \"./array\";\nimport { ExpandAction, ExpandedField, expandKey, expandSpecFor, isExpandShortcut, openExpanded } from \"./expand\";\nimport { FieldShell } from \"./field-shell\";\nimport { FieldList } from \"./field-list\";\nimport { IssueDot, RowChrome } from \"./bits\";\nimport { FieldInset, FieldRun, groupSummary, useInsetDepth } from \"./grouping\";\nimport { SchemaForm } from \"./schema-form\";\nimport { SlotField } from \"./slot\";\nimport { JsonControl } from \"../controls/json\";\nimport { FieldBoundary, HeldField, HeldValue } from \"./held\";\n\nexport interface KitFieldProps {\n field: FieldSchema;\n path: (string | number)[];\n parent?: Record<string, unknown>;\n}\n\n/** Type → control. Registered by the controls lane; a type with no entry edits its raw value (FallbackControl). */\nexport const CONTROLS: Partial<Record<SchemaType, ComponentType<ControlProps>>> = {};\n\n/**\n * Type → label-row action (DESIGN 4.4: slug Generate, rich text expand, table Edit in full screen), registered by the\n * controls lane next to its control. It gets the control's props. V2 draws it only while the field is editable, except\n * the types in ACTION_WHEN_READ_ONLY, whose action takes `readOnly` and decides for itself (slug Generate).\n */\nexport const ACTIONS: Partial<Record<SchemaType, ComponentType<ControlProps>>> = {};\nexport const ACTION_WHEN_READ_ONLY = new Set<SchemaType>([\"slug\"]);\n\n/** D58: the field for the lens: read-only (plain text) when it can't edit it. Hidden fields never reach here\n * (SchemaForm drops them from the schema). */\nexport function useFieldAccess(field: FieldSchema) {\n const env = useKitEnv();\n return { readOnly: resolveFieldAccess(field, env).readOnly };\n}\n\n/** CPO D39: the field's help line — schema text first, then a line computed from its settings, then the house convention. */\nexport function withDefaultHelp(field: FieldSchema, isPublished?: boolean, readOnly?: boolean): FieldSchema {\n let computed: string | undefined;\n /* a value set elsewhere says where, in one plain line (never a lock or a key) */\n if (readOnly && field.lockReason) return { ...field, description: field.lockReason.replace(/\\.?$/, \".\") };\n if (field.type === \"slug\" && !isPublished) computed = \"Follows the title until you change it or publish.\";\n else if (field.type === \"number\" && !field.scale && field.layout !== \"slider\" && field.numeric?.unit) {\n /* D63: the unit sits in the input (\"/ 5\", \"min\"), so a line that only restates it or its range is noise. A range\n still earns a line when the unit does not already say it (\"Between 1 and 12 items.\"). */\n const { min, max, unit } = field.numeric;\n const said = unit.startsWith(\"/\") || (max != null && unit.includes(String(max)));\n computed = said || (min == null && max == null) ? \"\" : min != null && max != null ? `Between ${min} and ${max} ${unit}.` : min != null ? `${min} ${unit} or more.` : `Up to ${max} ${unit}.`;\n } else if (field.type === \"number\" && !field.scale && field.layout !== \"slider\" && (field.numeric?.min != null || field.numeric?.max != null)) {\n const { min, max } = field.numeric ?? {};\n computed = min != null && max != null ? `Between ${min} and ${max}.` : min != null ? `${min} or more.` : `Up to ${max}.`;\n }\n /* resolve here so the computed line wins over the house convention; \"\" survives as \"deliberately none\" */\n const help = resolveHelp(field, computed) ?? \"\";\n return help === field.description ? field : { ...field, description: help };\n}\n\n/**\n * One field. A held field (FieldSchema.held, or a reason from KitServices.heldReason) renders read-only with its reason\n * and is never written; a control that throws while rendering holds that one field (FieldBoundary).\n */\nexport function KitField(props: KitFieldProps) {\n const form = useForm();\n return (\n <FieldBoundary field={props.field} path={props.path} value={form?.getAt(props.path)}>\n <KitFieldBody {...props} />\n </FieldBoundary>\n );\n}\n\nfunction KitFieldBody({ field, path, parent }: KitFieldProps) {\n const form = useForm();\n const env = useKitEnv();\n const services = useKitServices();\n const id = React.useId();\n const { readOnly } = useFieldAccess(field);\n if (!form) return null;\n\n const heldReason = field.held?.reason || services.heldReason?.({ field, path, value: form.getAt(path) });\n if (heldReason) return <HeldField field={withDefaultHelp(field, env.isPublished, true)} path={path} reason={heldReason} />;\n\n /* a host's own control for this field (KitEnv.controls), inside the usual shell */\n const Custom = env.controls?.[pathKey(path)];\n if (Custom) {\n const ck = pathKey(path);\n const cissue = form.visibleIssue(ck);\n const cf = withDefaultHelp(field, env.isPublished, readOnly);\n return (\n <FieldShell field={cf} path={path} id={id} value={form.getAt(path)} onChange={(v) => form.setAt(path, v)} readOnly={readOnly} issue={cissue}>\n <div onBlur={() => form.touch(ck)} className=\"min-w-0\">\n <Custom field={cf} value={form.getAt(path)} onChange={(v) => form.setAt(path, v)} id={id} invalid={cissue?.level === \"error\"} readOnly={readOnly} path={path} parent={parent} onBlur={() => form.touch(ck)} />\n </div>\n </FieldShell>\n );\n }\n\n if (field.type === \"array\") return <ArrayField field={field} path={path} parent={parent} />;\n if (field.type === \"slot\") return <SlotField field={field} path={path} />;\n if (field.type === \"object\") return <ObjectField field={field} path={path} />;\n\n const key = pathKey(path);\n const value = form.getAt(path);\n const onChange = (v: unknown) => form.setAt(path, v);\n const onBlur = () => form.touch(key);\n const issue = form.visibleIssue(key);\n const Control = CONTROLS[field.type] ?? FallbackControl;\n const Action = ACTIONS[field.type];\n const f = withDefaultHelp(field, env.isPublished, readOnly);\n const plain = readOnly && PLAIN_TYPES.has(field.type as PrimitiveType);\n const card = field.type === \"boolean\" && field.layout !== \"checkbox\";\n /* an icon's row carries its own name (controls/media.tsx IconImageRow): no label above it as well */\n const iconRow = isIconImage(field, value);\n /* D49: rich text, code and tables open the shared expanded editor (expand.tsx). A lane that registers its\n own ACTIONS[type] owns its expansion too (rich text's editor modal, the table's spreadsheet): the engine draws no\n second modal and binds no second ⌘↵ for it. */\n const expand = plain || Action ? null : expandSpecFor(field, { readOnly, hasKitControl: !!CONTROLS[field.type], variant: env.variant });\n const action =\n Action && (!readOnly || ACTION_WHEN_READ_ONLY.has(field.type)) ? (\n <Action field={f} value={value} onChange={onChange} id={id} readOnly={readOnly} path={path} parent={parent} />\n ) : expand ? (\n <ExpandAction field={f} path={path} spec={expand} />\n ) : undefined;\n return (\n <FieldShell field={f} path={path} id={id} value={value} onChange={onChange} readOnly={readOnly} issue={issue} layout={card ? \"card\" : iconRow ? \"row\" : \"stack\"} action={action}>\n {plain ? (\n card ? null /* the switch card already reads On / Off */ : <PlainValue field={f} value={value} id={id} />\n ) : (\n <div\n onBlur={onBlur}\n onKeyDown={\n expand\n ? (e) => {\n if (!isExpandShortcut(e)) return;\n e.preventDefault();\n openExpanded(expandKey(env.docId, path));\n }\n : undefined\n }\n className=\"min-w-0\"\n >\n <Control field={f} value={value} onChange={onChange} id={id} invalid={issue?.level === \"error\"} readOnly={readOnly} path={path} parent={parent} onBlur={onBlur} />\n </div>\n )}\n {expand ? (\n <ExpandedField field={f} path={path} spec={expand} Control={Control} value={value} onChange={onChange} onBlur={onBlur} invalid={issue?.level === \"error\"} id={id} parent={parent} />\n ) : null}\n </FieldShell>\n );\n}\n\n/**\n * A row that opens something (V2 NavRow): type tile, title over a summary line, the field's chrome (from RowChrome),\n * the issue rollup and a chevron.\n * Like V2 it always draws its button and chevron, also with no `onClick` (a popover trigger around it opens on the\n * click). Only `inert` (the form draws no frames, so nothing can open) leaves both out.\n */\nexport function NavRow({\n icon,\n title,\n subtitle,\n path,\n onClick,\n inert,\n className,\n trailing,\n}: {\n icon?: string;\n title: string;\n subtitle?: string;\n path?: FieldPath;\n onClick?: () => void;\n inert?: boolean;\n className?: string;\n trailing?: React.ReactNode;\n}) {\n const form = useForm();\n const roll = path && form ? form.rollup(path) : { errors: 0, warnings: 0 };\n const subId = React.useId();\n const chrome = React.useContext(RowChrome);\n const text = (\n <>\n <span className=\"block truncate text-kit-sm text-kit-fg\">{title}</span>\n <span id={subId} className=\"block truncate text-kit-xs text-kit-fg-3\">\n {subtitle || \"Nothing set yet\"}\n </span>\n </>\n );\n return (\n <div\n className={cn(\n \"group/nav relative flex min-h-11 w-full min-w-0 items-center gap-2.5 rounded-kit-lg border border-kit-line-strong bg-kit-control-bg py-1.5 pl-2 pr-2 text-left transition-colors hover:border-[var(--kit-emphasis-line)] hover:bg-kit-subtle\",\n className,\n )}\n >\n <span className=\"flex size-7 shrink-0 items-center justify-center rounded-kit-md bg-kit-muted text-kit-fg-2\">\n <KitIcon name={icon} fallback=\"folder\" className=\"size-4\" />\n </span>\n {!inert ? (\n <button\n type=\"button\"\n data-nav-main\n onClick={onClick}\n aria-label={`Open ${title}${roll.errors ? `, ${roll.errors} ${roll.errors === 1 ? \"issue\" : \"issues\"}` : \"\"}`}\n aria-describedby={subId}\n className=\"min-w-0 flex-1 text-left outline-none after:absolute after:inset-0 after:rounded-kit-lg after:content-[''] focus-visible:after:outline-2 focus-visible:after:outline-offset-2 focus-visible:after:outline-kit-focus-ring focus-visible:after:[outline-style:solid] [html[data-input-modality=pointer]_&]:focus-visible:after:outline-none\"\n >\n {text}\n </button>\n ) : (\n <div data-nav-main className=\"min-w-0 flex-1 text-left\">\n {text}\n </div>\n )}\n <IssueDot errors={roll.errors} warnings={roll.warnings} className=\"relative\" />\n {chrome ? <span className=\"relative z-[1] flex shrink-0 items-center gap-0.5 empty:hidden\">{chrome}</span> : null}\n {trailing}\n {!inert ? <IconChevronRight aria-hidden className=\"pointer-events-none size-4 shrink-0 text-kit-fg-3 transition-transform group-hover/nav:translate-x-0.5\" stroke={1.5} /> : null}\n </div>\n );\n}\n\n/* ── Object: inline · drill · popover · dialog (V2 ObjectField) ───── */\n\nfunction ObjectField({ field, path }: { field: FieldSchema; path: FieldPath }) {\n const form = useForm()!;\n const id = React.useId();\n const { readOnly } = useFieldAccess(field);\n const depth = useInsetDepth();\n const value = form.getAt(path);\n const obj = isObj(value) ? value : {};\n const fields = field.fields ?? [];\n /* D45 nesting rule: one container per level. Inside an inset (or an expanded row) an \"inline\" object would be a box in a\n box, so it drills instead — level 3+ is always a new frame, never more indentation. */\n const wanted = objectOpenMode(field);\n const mode = wanted === \"inline\" && depth > 0 ? \"drill\" : wanted;\n const [open, setOpen] = React.useState(false);\n const sum = groupSummary(fields, obj) || summarize(fields, obj);\n const nav = React.useRef<{ back: () => boolean }>(null);\n const shell = (control: React.ReactNode, layout?: \"row\") => (\n <FieldShell field={field} path={path} id={id} value={value} onChange={(v) => form.setAt(path, v)} readOnly={readOnly} issue={form.visibleIssue(pathKey(path))} layout={layout}>\n {control}\n </FieldShell>\n );\n if (mode === \"inline\") {\n const cc = condCtx(form, path);\n const visible = fields.filter((f) => !isHidden(f, obj, cc));\n /* D63: label, then the children behind one inset line; short neighbours pair up only on a wide form */\n return shell(\n <FieldInset label={field.title}>\n <FieldRun fields={visible} values={obj} render={(f) => <KitField field={f} path={[...path, f.name]} parent={obj} />} />\n </FieldInset>,\n );\n }\n const help = resolveHelp(field) ?? \"\";\n if (mode === \"popover\")\n /* V2: Radix <PopoverTrigger asChild><div> — the whole row is the trigger (aria-expanded, aria-haspopup=\"dialog\");\n NavRow gets no onClick but still draws its button (\"Open <title>\") and chevron, whose click opens the popover. */\n return shell(\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger nativeButton={false} render={<div />}>\n <NavRow icon={field.icon} title={field.title} subtitle={sum || help} path={path} />\n </PopoverTrigger>\n <PopoverContent className=\"w-[340px] p-3\" align=\"start\">\n <FieldList fields={fields} basePath={path} memoryKey={`pop:${pathKey(path)}`} />\n </PopoverContent>\n </Popover>,\n \"row\",\n );\n if (mode === \"dialog\")\n return shell(\n <>\n <NavRow icon={field.icon} title={field.title} subtitle={sum || help} path={path} onClick={() => setOpen(true)} />\n <Modal\n open={open}\n onOpenChange={(o, d) => {\n // Escape steps back inside the dialog's own frames first (V2: onEscapeKeyDown + nav.back())\n if (!o && d.reason === \"escape-key\" && nav.current?.back()) return d.cancel();\n setOpen(o);\n }}\n >\n <ModalContent size=\"lg\">\n <ModalHeader title={field.title} description={field.description} />\n <ModalBody className=\"flex min-h-[320px] flex-col gap-5\">\n <NestedForm fields={fields} title={field.title} icon={field.icon} path={path} navRef={nav} />\n </ModalBody>\n <ModalFooter>\n <span className=\"mr-auto text-kit-xs text-kit-fg-3\">Changes save as you type</span>\n <Button variant=\"primary\" onClick={() => setOpen(false)}>\n Done\n </Button>\n </ModalFooter>\n </ModalContent>\n </Modal>\n </>,\n \"row\",\n );\n return shell(<NavRow icon={field.icon} title={field.title} subtitle={sum || help} path={path} onClick={() => form.navigate(path)} inert={!form.canNavigate} />, \"row\");\n}\n\n/**\n * A dialog gets its OWN navigation stack: lists inside it drill inside the dialog (breadcrumb, Esc, stepper), never the\n * panel behind. Writes go straight into the parent form at `path`.\n */\nexport function NestedForm({ fields, title, icon, path, navRef }: NestedFormProps) {\n const form = useForm()!;\n const env = useKitEnv();\n const key = pathKey(path);\n const schema = React.useMemo(() => ({ name: key || \"nested\", title, icon, kind: \"object\" as const, fields }), [key, title, icon, fields]);\n const raw = form.getAt(path);\n const pub = form.hasPublished ? form.publishedAt(path) : undefined;\n const presence = React.useMemo(() => {\n const out: Record<string, KitPeer[]> = {};\n for (const [k, v] of Object.entries(env.presence)) if (k.startsWith(`${key}.`)) out[k.slice(key.length + 1)] = v;\n return out;\n }, [env.presence, key]);\n return (\n <SchemaForm\n schema={schema}\n value={isObj(raw) ? raw : {}}\n onChange={(v) => form.setAt(path, v)}\n variant=\"document\"\n scroll={false}\n navRef={navRef}\n resolveSchema={form.resolveSchema}\n blockLibrary={form.blockLibrary}\n published={isObj(pub) ? pub : undefined}\n presence={presence}\n readOnly={env.readOnly}\n showErrors={form.showAllErrors}\n onOpenReference={env.onOpenReference}\n env={{ docId: `${env.docId}:${key}`, docTitle: env.docTitle, urlPrefix: env.urlPrefix, isPublished: env.isPublished, palette: env.palette, helpDisplay: env.helpDisplay }}\n />\n );\n}\n\n/* ── Read-only as plain text (D58 §0): no greyed input, just the value ── */\nconst PLAIN_TYPES = new Set<PrimitiveType>([\"string\", \"text\", \"richtext\", \"number\", \"slug\", \"url\", \"email\", \"date\", \"datetime\", \"select\", \"multiselect\", \"tags\", \"boolean\", \"rating\"]);\nexport function plainOf(field: FieldSchema, value: unknown): string {\n if (value == null || value === \"\") return \"\";\n const label = (v: unknown) => field.options?.find((o) => o.value === v)?.label ?? String(v);\n if (field.type === \"boolean\") return value ? \"On\" : \"Off\";\n if (field.type === \"select\") return label(value);\n // before the list arm: stored rich text may be a Portable Text block array\n if (field.type === \"richtext\") return plainText(value);\n if (Array.isArray(value)) return value.map(label).join(\", \");\n if (field.type === \"date\" || field.type === \"datetime\") {\n const d = new Date(String(value).replace(/\\[.*\\]$/, \"\"));\n return Number.isNaN(+d) ? String(value) : d.toLocaleString(\"en-US\", field.type === \"date\" ? { month: \"short\", day: \"numeric\", year: \"numeric\" } : { month: \"short\", day: \"numeric\", year: \"numeric\", hour: \"numeric\", minute: \"2-digit\" });\n }\n if (field.type === \"number\" && isObj(value)) return String((value as { value?: unknown }).value ?? \"\");\n return typeof value === \"object\" ? \"\" : String(value);\n}\nfunction PlainValue({ field, value, id }: { field: FieldSchema; value: unknown; id: string }) {\n const text = plainOf(field, value);\n return (\n // NEW-Q48-PLAINLABEL: a <p> is not labelable, so label[for] named nothing; the group is named \"<field> <value>\"\n <p id={id} tabIndex={0} role=\"group\" aria-labelledby={`${id}-label ${id}`} data-slot=\"kit-plain\" className={cn(\"min-w-0 whitespace-pre-wrap break-words text-kit-sm leading-6 text-kit-fg outline-none\", (field.type === \"slug\" || field.type === \"url\") && \"font-kit-mono text-kit-xs leading-6\")}>\n {text || <span className=\"text-kit-fg-3\">Empty</span>}\n </p>\n );\n}\n\n/* ── Unknown type: the raw value, in the JSON control ── */\n/**\n * Every SchemaType has a kit control (kit-field.test checks CONTROLS against the type list in schema/types.ts). A field\n * whose type is none of them edits its raw stored value in the JSON control, tagged `data-kit-fallback=\"<type>\"`: the\n * value is shown and kept, and an edit is written only once it parses.\n */\nexport function FallbackControl(props: ControlProps) {\n return (\n <div data-kit-fallback={props.field.type} className=\"min-w-0\">\n <JsonControl {...props} />\n </div>\n );\n}\n\n/* ── Hand-off: the host's own control for a value the kit refuses ── */\n/**\n * A control that cannot carry a stored value unchanged (rich text holding formatting its editor would drop) hands that\n * value to the host's control for the type (KitServices.LegacyControl: the dashboard's FieldRenderer arm), bare inside\n * the kit FieldShell, which owns the label and the help; the control names its reason above it. The box carries\n * `data-kit-legacy=\"<type>\"`, so the parity harness counts it (mismatch class `legacy-control`). A control that throws\n * while rendering says why in words; the form around it keeps working.\n * Kit 3.2.0: a host with no LegacyControl gets a HELD field instead (held.tsx: the value read-only, with the reason, no\n * `data-kit-legacy`). LegacyControl, this hand-off and `data-kit-legacy` are removed in 4.0.0.\n */\nexport function LegacyFallback(props: ControlProps) {\n const { LegacyControl } = useKitServices();\n const { field, id } = props;\n if (!LegacyControl) return <HeldValue field={field} value={props.value} id={id} reason={`this view has no control for ${field.type} fields`} />;\n return (\n <div data-kit-legacy={field.type} className=\"min-w-0\">\n {/* keyed by the schema's content: a schema edit remounts the control (KitField hands over a fresh field object on\n every render, so identity would remount on every keystroke). A value change retries in place (componentDidUpdate). */}\n <LegacyBoundary key={JSON.stringify(field)} field={field} id={id} value={props.value}>\n <LegacyControl {...props} />\n </LegacyBoundary>\n </div>\n );\n}\n\n/**\n * An `<output>`: a labelable element, so the FieldShell label's `for` lands on it, and focusable, so a keyboard user\n * reaches the reason. The neutral focus ring shows under keyboard modality only.\n */\nfunction LegacyRefusal({ id, children }: { id: string; children: React.ReactNode }) {\n return (\n <output\n id={id}\n role=\"note\"\n tabIndex={0}\n data-slot=\"kit-legacy-refusal\"\n className=\"block rounded-kit-sm text-kit-xs text-kit-fg-3 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kit-focus-ring focus-visible:[outline-style:solid] [html[data-input-modality=pointer]_&]:focus-visible:outline-0\"\n >\n {children}\n </output>\n );\n}\n\n/** Retries the control once its field or value changes (a schema edit, a save from elsewhere, an undo). */\nclass LegacyBoundary extends React.Component<{ field: FieldSchema; id: string; value: unknown; children: React.ReactNode }, { reason: string | null }> {\n state = { reason: null as string | null };\n static getDerivedStateFromError(error: unknown) {\n return { reason: error instanceof Error ? error.message : String(error) };\n }\n componentDidUpdate(prev: { field: FieldSchema; value: unknown }) {\n if (this.state.reason === null) return;\n // by content: KitField hands over a fresh field object (withDefaultHelp) on every render\n if (prev.value !== this.props.value || JSON.stringify(prev.field) !== JSON.stringify(this.props.field)) this.setState({ reason: null });\n }\n render() {\n if (this.state.reason === null) return this.props.children;\n return (\n <LegacyRefusal id={this.props.id}>\n The {this.props.field.title} control could not load: {this.state.reason}\n </LegacyRefusal>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,WAAqE,CAAC;;;;;;AAOnF,IAAa,UAAoE,CAAC;AAClF,IAAa,wCAAwB,IAAI,IAAgB,CAAC,MAAM,CAAC;;;AAIjE,SAAgB,eAAe,OAAoB;CACjD,MAAM,MAAM,UAAU;CACtB,OAAO,EAAE,UAAU,mBAAmB,OAAO,GAAG,CAAC,CAAC,SAAS;AAC7D;;AAGA,SAAgB,gBAAgB,OAAoB,aAAuB,UAAiC;CAC1G,IAAI;CAEJ,IAAI,YAAY,MAAM,YAAY,OAAO;EAAE,GAAG;EAAO,aAAa,MAAM,WAAW,QAAQ,QAAQ,GAAG;CAAE;CACxG,IAAI,MAAM,SAAS,UAAU,CAAC,aAAa,WAAW;MACjD,IAA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O,KAAK,MAAM;EAClD,OACE,qBAAC,eAAD;GAAe,IAAI,KAAK,MAAM;GAA9B,UAAA;IAAkC;IAC3B,KAAK,MAAM,MAAM;IAAM;IAA0B,KAAK,MAAM;GACpD;;CAEnB;AACF"}
1
+ {"version":3,"file":"kit-field.js","names":[],"sources":["../../src/engine/kit-field.tsx"],"sourcesContent":["/**\n * KitField — renders ONE field of the schema at `path` (must be inside <SchemaForm>): the shell + the control for its\n * type (V2 HEAD 9829bf1 kit/engine/kit-field.tsx).\n *\n * Arrays (array.tsx) and slots (slot.tsx) get their rows; objects open inline (FieldInset), drill (NavRow -> a frame),\n * popover or dialog (NestedForm: its own navigation stack). Primitive types dispatch through the CONTROLS table, which\n * the controls lanes fill. Every SchemaType has a control there; a type that is none of them (a schema newer than this\n * kit) edits its raw value in the JSON control (FallbackControl), never nothing and never a stand-in.\n */\nimport * as React from \"react\";\nimport type { ComponentType } from \"react\";\nimport { IconChevronRight } from \"@tabler/icons-react\";\nimport { KitIcon } from \"../lib/icons\";\nimport { cn } from \"../lib/cn\";\nimport type { FieldPath, FieldSchema, PrimitiveType, SchemaType } from \"../schema/types\";\nimport { resolveHelp } from \"../schema/help\";\nimport type { ControlProps } from \"../types\";\nimport { resolveFieldAccess, useForm, useKitEnv, useKitServices, type KitPeer } from \"../context\";\nimport { Button } from \"../ui/button\";\nimport { Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, Popover, PopoverContent, PopoverTrigger } from \"../ui/overlay\";\nimport { isObj, pathKey } from \"../lib/path\";\nimport { condCtx, isHidden, objectOpenMode, plainText, summarize } from \"../lib/schema\";\nimport { isIconImage } from \"../lib/icon-image\";\nimport { ArrayField, type NestedFormProps } from \"./array\";\nimport { ExpandAction, ExpandedField, expandKey, expandSpecFor, isExpandShortcut, openExpanded } from \"./expand\";\nimport { FieldShell } from \"./field-shell\";\nimport { FieldList } from \"./field-list\";\nimport { IssueDot, RowChrome } from \"./bits\";\nimport { FieldInset, FieldRun, groupSummary, useInsetDepth } from \"./grouping\";\nimport { SchemaForm } from \"./schema-form\";\nimport { SlotField } from \"./slot\";\nimport { JsonControl } from \"../controls/json\";\nimport { FieldBoundary, HeldField } from \"./held\";\n\nexport interface KitFieldProps {\n field: FieldSchema;\n path: (string | number)[];\n parent?: Record<string, unknown>;\n}\n\n/** Type → control. Registered by the controls lane; a type with no entry edits its raw value (FallbackControl). */\nexport const CONTROLS: Partial<Record<SchemaType, ComponentType<ControlProps>>> = {};\n\n/**\n * Type → label-row action (DESIGN 4.4: slug Generate, rich text expand, table Edit in full screen), registered by the\n * controls lane next to its control. It gets the control's props. V2 draws it only while the field is editable, except\n * the types in ACTION_WHEN_READ_ONLY, whose action takes `readOnly` and decides for itself (slug Generate).\n */\nexport const ACTIONS: Partial<Record<SchemaType, ComponentType<ControlProps>>> = {};\nexport const ACTION_WHEN_READ_ONLY = new Set<SchemaType>([\"slug\"]);\n\n/** D58: the field for the lens: read-only (plain text) when it can't edit it. Hidden fields never reach here\n * (SchemaForm drops them from the schema). */\nexport function useFieldAccess(field: FieldSchema) {\n const env = useKitEnv();\n return { readOnly: resolveFieldAccess(field, env).readOnly };\n}\n\n/** CPO D39: the field's help line — schema text first, then a line computed from its settings, then the house convention. */\nexport function withDefaultHelp(field: FieldSchema, isPublished?: boolean, readOnly?: boolean): FieldSchema {\n let computed: string | undefined;\n /* a value set elsewhere says where, in one plain line (never a lock or a key) */\n if (readOnly && field.lockReason) return { ...field, description: field.lockReason.replace(/\\.?$/, \".\") };\n if (field.type === \"slug\" && !isPublished) computed = \"Follows the title until you change it or publish.\";\n else if (field.type === \"number\" && !field.scale && field.layout !== \"slider\" && field.numeric?.unit) {\n /* D63: the unit sits in the input (\"/ 5\", \"min\"), so a line that only restates it or its range is noise. A range\n still earns a line when the unit does not already say it (\"Between 1 and 12 items.\"). */\n const { min, max, unit } = field.numeric;\n const said = unit.startsWith(\"/\") || (max != null && unit.includes(String(max)));\n computed = said || (min == null && max == null) ? \"\" : min != null && max != null ? `Between ${min} and ${max} ${unit}.` : min != null ? `${min} ${unit} or more.` : `Up to ${max} ${unit}.`;\n } else if (field.type === \"number\" && !field.scale && field.layout !== \"slider\" && (field.numeric?.min != null || field.numeric?.max != null)) {\n const { min, max } = field.numeric ?? {};\n computed = min != null && max != null ? `Between ${min} and ${max}.` : min != null ? `${min} or more.` : `Up to ${max}.`;\n }\n /* resolve here so the computed line wins over the house convention; \"\" survives as \"deliberately none\" */\n const help = resolveHelp(field, computed) ?? \"\";\n return help === field.description ? field : { ...field, description: help };\n}\n\n/**\n * One field. A held field (FieldSchema.held, or a reason from KitServices.heldReason) renders read-only with its reason\n * and is never written; a control that throws while rendering holds that one field (FieldBoundary).\n */\nexport function KitField(props: KitFieldProps) {\n const form = useForm();\n return (\n <FieldBoundary field={props.field} path={props.path} value={form?.getAt(props.path)}>\n <KitFieldBody {...props} />\n </FieldBoundary>\n );\n}\n\nfunction KitFieldBody({ field, path, parent }: KitFieldProps) {\n const form = useForm();\n const env = useKitEnv();\n const services = useKitServices();\n const id = React.useId();\n const { readOnly } = useFieldAccess(field);\n if (!form) return null;\n\n const heldReason = field.held?.reason || services.heldReason?.({ field, path, value: form.getAt(path) });\n if (heldReason) return <HeldField field={withDefaultHelp(field, env.isPublished, true)} path={path} reason={heldReason} />;\n\n /* a host's own control for this field (KitEnv.controls), inside the usual shell */\n const Custom = env.controls?.[pathKey(path)];\n if (Custom) {\n const ck = pathKey(path);\n const cissue = form.visibleIssue(ck);\n const cf = withDefaultHelp(field, env.isPublished, readOnly);\n return (\n <FieldShell field={cf} path={path} id={id} value={form.getAt(path)} onChange={(v) => form.setAt(path, v)} readOnly={readOnly} issue={cissue}>\n <div onBlur={() => form.touch(ck)} className=\"min-w-0\">\n <Custom field={cf} value={form.getAt(path)} onChange={(v) => form.setAt(path, v)} id={id} invalid={cissue?.level === \"error\"} readOnly={readOnly} path={path} parent={parent} onBlur={() => form.touch(ck)} />\n </div>\n </FieldShell>\n );\n }\n\n if (field.type === \"array\") return <ArrayField field={field} path={path} parent={parent} />;\n if (field.type === \"slot\") return <SlotField field={field} path={path} />;\n if (field.type === \"object\") return <ObjectField field={field} path={path} />;\n\n const key = pathKey(path);\n const value = form.getAt(path);\n const onChange = (v: unknown) => form.setAt(path, v);\n const onBlur = () => form.touch(key);\n const issue = form.visibleIssue(key);\n const Control = CONTROLS[field.type] ?? FallbackControl;\n const Action = ACTIONS[field.type];\n const f = withDefaultHelp(field, env.isPublished, readOnly);\n const plain = readOnly && PLAIN_TYPES.has(field.type as PrimitiveType);\n const card = field.type === \"boolean\" && field.layout !== \"checkbox\";\n /* an icon's row carries its own name (controls/media.tsx IconImageRow): no label above it as well */\n const iconRow = isIconImage(field, value);\n /* D49: rich text, code and tables open the shared expanded editor (expand.tsx). A lane that registers its\n own ACTIONS[type] owns its expansion too (rich text's editor modal, the table's spreadsheet): the engine draws no\n second modal and binds no second ⌘↵ for it. */\n const expand = plain || Action ? null : expandSpecFor(field, { readOnly, hasKitControl: !!CONTROLS[field.type], variant: env.variant });\n const action =\n Action && (!readOnly || ACTION_WHEN_READ_ONLY.has(field.type)) ? (\n <Action field={f} value={value} onChange={onChange} id={id} readOnly={readOnly} path={path} parent={parent} />\n ) : expand ? (\n <ExpandAction field={f} path={path} spec={expand} />\n ) : undefined;\n return (\n <FieldShell field={f} path={path} id={id} value={value} onChange={onChange} readOnly={readOnly} issue={issue} layout={card ? \"card\" : iconRow ? \"row\" : \"stack\"} action={action}>\n {plain ? (\n card ? null /* the switch card already reads On / Off */ : <PlainValue field={f} value={value} id={id} />\n ) : (\n <div\n onBlur={onBlur}\n onKeyDown={\n expand\n ? (e) => {\n if (!isExpandShortcut(e)) return;\n e.preventDefault();\n openExpanded(expandKey(env.docId, path));\n }\n : undefined\n }\n className=\"min-w-0\"\n >\n <Control field={f} value={value} onChange={onChange} id={id} invalid={issue?.level === \"error\"} readOnly={readOnly} path={path} parent={parent} onBlur={onBlur} />\n </div>\n )}\n {expand ? (\n <ExpandedField field={f} path={path} spec={expand} Control={Control} value={value} onChange={onChange} onBlur={onBlur} invalid={issue?.level === \"error\"} id={id} parent={parent} />\n ) : null}\n </FieldShell>\n );\n}\n\n/**\n * A row that opens something (V2 NavRow): type tile, title over a summary line, the field's chrome (from RowChrome),\n * the issue rollup and a chevron.\n * Like V2 it always draws its button and chevron, also with no `onClick` (a popover trigger around it opens on the\n * click). Only `inert` (the form draws no frames, so nothing can open) leaves both out.\n */\nexport function NavRow({\n icon,\n title,\n subtitle,\n path,\n onClick,\n inert,\n className,\n trailing,\n}: {\n icon?: string;\n title: string;\n subtitle?: string;\n path?: FieldPath;\n onClick?: () => void;\n inert?: boolean;\n className?: string;\n trailing?: React.ReactNode;\n}) {\n const form = useForm();\n const roll = path && form ? form.rollup(path) : { errors: 0, warnings: 0 };\n const subId = React.useId();\n const chrome = React.useContext(RowChrome);\n const text = (\n <>\n <span className=\"block truncate text-kit-sm text-kit-fg\">{title}</span>\n <span id={subId} className=\"block truncate text-kit-xs text-kit-fg-3\">\n {subtitle || \"Nothing set yet\"}\n </span>\n </>\n );\n return (\n <div\n className={cn(\n \"group/nav relative flex min-h-11 w-full min-w-0 items-center gap-2.5 rounded-kit-lg border border-kit-line-strong bg-kit-control-bg py-1.5 pl-2 pr-2 text-left transition-colors hover:border-[var(--kit-emphasis-line)] hover:bg-kit-subtle\",\n className,\n )}\n >\n <span className=\"flex size-7 shrink-0 items-center justify-center rounded-kit-md bg-kit-muted text-kit-fg-2\">\n <KitIcon name={icon} fallback=\"folder\" className=\"size-4\" />\n </span>\n {!inert ? (\n <button\n type=\"button\"\n data-nav-main\n onClick={onClick}\n aria-label={`Open ${title}${roll.errors ? `, ${roll.errors} ${roll.errors === 1 ? \"issue\" : \"issues\"}` : \"\"}`}\n aria-describedby={subId}\n className=\"min-w-0 flex-1 text-left outline-none after:absolute after:inset-0 after:rounded-kit-lg after:content-[''] focus-visible:after:outline-2 focus-visible:after:outline-offset-2 focus-visible:after:outline-kit-focus-ring focus-visible:after:[outline-style:solid] [html[data-input-modality=pointer]_&]:focus-visible:after:outline-none\"\n >\n {text}\n </button>\n ) : (\n <div data-nav-main className=\"min-w-0 flex-1 text-left\">\n {text}\n </div>\n )}\n <IssueDot errors={roll.errors} warnings={roll.warnings} className=\"relative\" />\n {chrome ? <span className=\"relative z-[1] flex shrink-0 items-center gap-0.5 empty:hidden\">{chrome}</span> : null}\n {trailing}\n {!inert ? <IconChevronRight aria-hidden className=\"pointer-events-none size-4 shrink-0 text-kit-fg-3 transition-transform group-hover/nav:translate-x-0.5\" stroke={1.5} /> : null}\n </div>\n );\n}\n\n/* ── Object: inline · drill · popover · dialog (V2 ObjectField) ───── */\n\nfunction ObjectField({ field, path }: { field: FieldSchema; path: FieldPath }) {\n const form = useForm()!;\n const id = React.useId();\n const { readOnly } = useFieldAccess(field);\n const depth = useInsetDepth();\n const value = form.getAt(path);\n const obj = isObj(value) ? value : {};\n const fields = field.fields ?? [];\n /* D45 nesting rule: one container per level. Inside an inset (or an expanded row) an \"inline\" object would be a box in a\n box, so it drills instead — level 3+ is always a new frame, never more indentation. */\n const wanted = objectOpenMode(field);\n const mode = wanted === \"inline\" && depth > 0 ? \"drill\" : wanted;\n const [open, setOpen] = React.useState(false);\n const sum = groupSummary(fields, obj) || summarize(fields, obj);\n const nav = React.useRef<{ back: () => boolean }>(null);\n const shell = (control: React.ReactNode, layout?: \"row\") => (\n <FieldShell field={field} path={path} id={id} value={value} onChange={(v) => form.setAt(path, v)} readOnly={readOnly} issue={form.visibleIssue(pathKey(path))} layout={layout}>\n {control}\n </FieldShell>\n );\n if (mode === \"inline\") {\n const cc = condCtx(form, path);\n const visible = fields.filter((f) => !isHidden(f, obj, cc));\n /* D63: label, then the children behind one inset line; short neighbours pair up only on a wide form */\n return shell(\n <FieldInset label={field.title}>\n <FieldRun fields={visible} values={obj} render={(f) => <KitField field={f} path={[...path, f.name]} parent={obj} />} />\n </FieldInset>,\n );\n }\n const help = resolveHelp(field) ?? \"\";\n if (mode === \"popover\")\n /* V2: Radix <PopoverTrigger asChild><div> — the whole row is the trigger (aria-expanded, aria-haspopup=\"dialog\");\n NavRow gets no onClick but still draws its button (\"Open <title>\") and chevron, whose click opens the popover. */\n return shell(\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger nativeButton={false} render={<div />}>\n <NavRow icon={field.icon} title={field.title} subtitle={sum || help} path={path} />\n </PopoverTrigger>\n <PopoverContent className=\"w-[340px] p-3\" align=\"start\">\n <FieldList fields={fields} basePath={path} memoryKey={`pop:${pathKey(path)}`} />\n </PopoverContent>\n </Popover>,\n \"row\",\n );\n if (mode === \"dialog\")\n return shell(\n <>\n <NavRow icon={field.icon} title={field.title} subtitle={sum || help} path={path} onClick={() => setOpen(true)} />\n <Modal\n open={open}\n onOpenChange={(o, d) => {\n // Escape steps back inside the dialog's own frames first (V2: onEscapeKeyDown + nav.back())\n if (!o && d.reason === \"escape-key\" && nav.current?.back()) return d.cancel();\n setOpen(o);\n }}\n >\n <ModalContent size=\"lg\">\n <ModalHeader title={field.title} description={field.description} />\n <ModalBody className=\"flex min-h-[320px] flex-col gap-5\">\n <NestedForm fields={fields} title={field.title} icon={field.icon} path={path} navRef={nav} />\n </ModalBody>\n <ModalFooter>\n <span className=\"mr-auto text-kit-xs text-kit-fg-3\">Changes save as you type</span>\n <Button variant=\"primary\" onClick={() => setOpen(false)}>\n Done\n </Button>\n </ModalFooter>\n </ModalContent>\n </Modal>\n </>,\n \"row\",\n );\n return shell(<NavRow icon={field.icon} title={field.title} subtitle={sum || help} path={path} onClick={() => form.navigate(path)} inert={!form.canNavigate} />, \"row\");\n}\n\n/**\n * A dialog gets its OWN navigation stack: lists inside it drill inside the dialog (breadcrumb, Esc, stepper), never the\n * panel behind. Writes go straight into the parent form at `path`.\n */\nexport function NestedForm({ fields, title, icon, path, navRef }: NestedFormProps) {\n const form = useForm()!;\n const env = useKitEnv();\n const key = pathKey(path);\n const schema = React.useMemo(() => ({ name: key || \"nested\", title, icon, kind: \"object\" as const, fields }), [key, title, icon, fields]);\n const raw = form.getAt(path);\n const pub = form.hasPublished ? form.publishedAt(path) : undefined;\n const presence = React.useMemo(() => {\n const out: Record<string, KitPeer[]> = {};\n for (const [k, v] of Object.entries(env.presence)) if (k.startsWith(`${key}.`)) out[k.slice(key.length + 1)] = v;\n return out;\n }, [env.presence, key]);\n return (\n <SchemaForm\n schema={schema}\n value={isObj(raw) ? raw : {}}\n onChange={(v) => form.setAt(path, v)}\n variant=\"document\"\n scroll={false}\n navRef={navRef}\n resolveSchema={form.resolveSchema}\n blockLibrary={form.blockLibrary}\n published={isObj(pub) ? pub : undefined}\n presence={presence}\n readOnly={env.readOnly}\n showErrors={form.showAllErrors}\n onOpenReference={env.onOpenReference}\n env={{ docId: `${env.docId}:${key}`, docTitle: env.docTitle, urlPrefix: env.urlPrefix, isPublished: env.isPublished, palette: env.palette, helpDisplay: env.helpDisplay }}\n />\n );\n}\n\n/* ── Read-only as plain text (D58 §0): no greyed input, just the value ── */\nconst PLAIN_TYPES = new Set<PrimitiveType>([\"string\", \"text\", \"richtext\", \"number\", \"slug\", \"url\", \"email\", \"date\", \"datetime\", \"select\", \"multiselect\", \"tags\", \"boolean\", \"rating\"]);\nexport function plainOf(field: FieldSchema, value: unknown): string {\n if (value == null || value === \"\") return \"\";\n const label = (v: unknown) => field.options?.find((o) => o.value === v)?.label ?? String(v);\n if (field.type === \"boolean\") return value ? \"On\" : \"Off\";\n if (field.type === \"select\") return label(value);\n // before the list arm: stored rich text may be a Portable Text block array\n if (field.type === \"richtext\") return plainText(value);\n if (Array.isArray(value)) return value.map(label).join(\", \");\n if (field.type === \"date\" || field.type === \"datetime\") {\n const d = new Date(String(value).replace(/\\[.*\\]$/, \"\"));\n return Number.isNaN(+d) ? String(value) : d.toLocaleString(\"en-US\", field.type === \"date\" ? { month: \"short\", day: \"numeric\", year: \"numeric\" } : { month: \"short\", day: \"numeric\", year: \"numeric\", hour: \"numeric\", minute: \"2-digit\" });\n }\n if (field.type === \"number\" && isObj(value)) return String((value as { value?: unknown }).value ?? \"\");\n return typeof value === \"object\" ? \"\" : String(value);\n}\nfunction PlainValue({ field, value, id }: { field: FieldSchema; value: unknown; id: string }) {\n const text = plainOf(field, value);\n return (\n // NEW-Q48-PLAINLABEL: a <p> is not labelable, so label[for] named nothing; the group is named \"<field> <value>\"\n <p id={id} tabIndex={0} role=\"group\" aria-labelledby={`${id}-label ${id}`} data-slot=\"kit-plain\" className={cn(\"min-w-0 whitespace-pre-wrap break-words text-kit-sm leading-6 text-kit-fg outline-none\", (field.type === \"slug\" || field.type === \"url\") && \"font-kit-mono text-kit-xs leading-6\")}>\n {text || <span className=\"text-kit-fg-3\">Empty</span>}\n </p>\n );\n}\n\n/* ── Unknown type: the raw value, in the JSON control ── */\n/**\n * Every SchemaType has a kit control (kit-field.test checks CONTROLS against the type list in schema/types.ts). A field\n * whose type is none of them edits its raw stored value in the JSON control, tagged `data-kit-fallback=\"<type>\"`: the\n * value is shown and kept, and an edit is written only once it parses.\n */\nexport function FallbackControl(props: ControlProps) {\n return (\n <div data-kit-fallback={props.field.type} className=\"min-w-0\">\n <JsonControl {...props} />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,WAAqE,CAAC;;;;;;AAOnF,IAAa,UAAoE,CAAC;AAClF,IAAa,wCAAwB,IAAI,IAAgB,CAAC,MAAM,CAAC;;;AAIjE,SAAgB,eAAe,OAAoB;CACjD,MAAM,MAAM,UAAU;CACtB,OAAO,EAAE,UAAU,mBAAmB,OAAO,GAAG,CAAC,CAAC,SAAS;AAC7D;;AAGA,SAAgB,gBAAgB,OAAoB,aAAuB,UAAiC;CAC1G,IAAI;CAEJ,IAAI,YAAY,MAAM,YAAY,OAAO;EAAE,GAAG;EAAO,aAAa,MAAM,WAAW,QAAQ,QAAQ,GAAG;CAAE;CACxG,IAAI,MAAM,SAAS,UAAU,CAAC,aAAa,WAAW;MACjD,IAAI,MAAM,SAAS,YAAY,CA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AAA;CACnD,CAAA;AAEP;;;;;;AAQA,SAAgB,gBAAgB,OAAqB;CACnD,OACE,oBAAC,OAAD;EAAK,qBAAmB,MAAM,MAAM;EAAM,WAAU;EAClD,UAAA,oBAAC,aAAD,EAAa,GAAI,MAAQ,CAAA;CACtB,CAAA;AAET"}
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ import { BlockPicker, SlotField, useAvailableBlocks, useUnavailableBlocks } from
40
40
  import { CodeControl, CodeDialogField, CodeSurface, UnreadableValue, jsonProblem } from "./controls/code.js";
41
41
  import { JsonControl } from "./controls/json.js";
42
42
  import { FieldBoundary, HeldField, HeldValue, KitErrorCard, heldLines } from "./engine/held.js";
43
- import { ACTIONS, ACTION_WHEN_READ_ONLY, CONTROLS, FallbackControl, KitField, LegacyFallback, NavRow, NestedForm, plainOf, useFieldAccess, withDefaultHelp } from "./engine/kit-field.js";
43
+ import { ACTIONS, ACTION_WHEN_READ_ONLY, CONTROLS, FallbackControl, KitField, NavRow, NestedForm, plainOf, useFieldAccess, withDefaultHelp } from "./engine/kit-field.js";
44
44
  import { EmailControl, SlugControl, SlugGenerate, StringControl, TEXT_FOCUS, TextControl, UrlControl, slugSource, slugTidy, slugTyping, str } from "./controls/text.js";
45
45
  import { ColorControl, HEX_COLOR, pickerHex } from "./controls/color.js";
46
46
  import { NUMBER_SCALE, NumberControl, PlainNumber, RatingControl, ratingScale, snapRating, toNum, ungroupNumber } from "./controls/number.js";
@@ -80,6 +80,6 @@ import "./kit.css";
80
80
  //#region src/index.ts
81
81
  registerKitControls();
82
82
  //#endregion
83
- export { ACTIONS, ACTION_WHEN_READ_ONLY, ADD_SEARCH_AT, AGENT_PRESENCE, AI_PRESETS, ARRAY_CONTROLS, ActionTray, AnimatedFields, Appear, ArrayField, Autocomplete, Avatar, AvatarStack, BUTTON_ICONS, Badge, BlockPicker, BooleanControl, BreakpointGroup, Button, ButtonControl, ButtonIconPicker, ButtonLinkEditor, ButtonPreview, ButtonScreen, ButtonStyleGrid, C1_ACTIONS, C1_CONTROLS, C2_CONTROLS, CAP_IDS, CATEGORY_TO_PROD, COALESCE_MS, CONTROLS, Card, CardHeader, Checkbox, ChoiceCard, ChoiceList, ChoiceSwitch, CodeControl, CodeDialogField, CodeSurface, ColorControl, ComponentSlotControl, DEFAULT_ENV, DEV_FIELD, DEV_ONLY_FIELD, DateControl, Dot, EmailControl, EmptyState, ExpandedEditorModal, FLOATING_LAYER, FallbackControl, Field, FieldBoundary, FieldCommentRequest, FieldDescribedByContext, FieldHeaderSlot, FieldInset, FieldLabelledByContext, FieldList, FieldSection, FieldShell, FieldUnit, FieldUnitRow, FieldsetSection, FileControl, FlowBody, FlowClose, FlowFooter, FlowHeader, FlowLabel, FlowModal, FormPickerControl, FormProvider, FrameCrumbs, FrameHeader, FrameSlotsProvider, FrameStage, FrameView, GalleryControl, GroupTabs, HELP_STRINGS, HEX_COLOR, HISTORY_SEGMENT, HeaderStatus, HeldField, HeldValue, HelpMore, Highlight, HintTooltip, HoverCard, HoverCardContent, HoverCardTrigger, IconButton, IconControl, IconPicker, IconValueGlyph, ImageControl, ImageDetails, Input, InsetScope, IssueDot, ItemList, JsonControl, KIT_ICONS, Kbd, Kbdish, KitAddressContext, KitBreadcrumb, KitEnvProvider, KitErrorCard, KitField, KitIcon, KitSectionTitle, KitServicesProvider, KitToaster, LABEL_HINT_AT, LINK_TYPES, Label, LegacyFallback, LinkControl, LinkField, LinkForm, LinkLine, LinkOptions, LinkPicker, LinkPopoverBody, LinkQuickEdit, LocationControl, MediaPicker, Menu, MenuCheckItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, MiniCalendar, Modal, ModalBody, ModalClose, ModalContent, ModalFooter, ModalHeader, ModalTrigger, ModeBar, ModeBarDot, ModeBarLink, MoreOptions, MultiSelectControl, NO_CROP_OUTSIDE_LIBRARY, NUMBER_SCALE, NavRow, NestedForm, NumberControl, OptionRow, OrderLockSlot, PageHeader, PeerStack, PlainNumber, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, REL_ITEMS, RHYTHM, RT_PROSE, Radio, RadioGroup, RatingControl, RefThumb, ReferenceControl, ReferencesControl, RevealLink, RichTextControl, RichTextEditor, RichTextExpandAction, RowChrome, RowList, RowsHostContext, SEARCH_THRESHOLD, SEGMENTED_MAX, SEGMENTED_MAX_LABEL, SHOPIFY_REF_LOCK, SITE_PALETTE, STYLE_ITEMS, ScaleControl, ScaleSlider, SchemaForm, SearchInput, SectionAnchorsProvider, Segmented, Select, SelectControl, Separator, SettingsSection, SharedSortProvider, Sheet, SheetClose, SheetContent, SheetTrigger, ShortcutHint, ShortcutHintsProvider, Skeleton, Slider, SlotDepthContext, SlotField, SlotPicker, SlugControl, SlugGenerate, Sparkle, Spinner, Stat, StatusMark, StatusPill, StringControl, StyleGlyph, Switch, TARGET_KEYS, TEXT_FOCUS, Tab, TabList, TabPanel, Table, TableControl, TableFrame, TableFullScreenAction, Tabs, TagsControl, Td, TextControl, Textarea, Th, Thumb, ToggleGroup, ToggleItem, Tooltip, TooltipProvider, TooltipScope, Tr, TrayMeta, TrayMore, UNDO_STEPS, UnknownValueNote, UnreadableValue, UrlControl, VideoControl, VideoPreview, acceptsFile, actionTrayClass, apiName, arrangeFields, arrayMove, avatarRingSpread, badgeVariants, belowMin, blockDefToSchema, buttonFromProd, buttonToProd, buttonVariants, cn, codeFromProd, codeToProd, collectIssues, colorFor, conventionalHelp, cropChoice, cropPreset, cropRect, crumbSignature, dateFromProd, dateToProd, datetimeFromProd, datetimeToProd, defaultGroup, describeLink, detectType, ensureKeys, failingRules, fieldAccessOf, fieldDefToSchema, fieldDefsToSchema, fileNameFromUrl, fileTarget, filterOptions, finalizeLink, findTarget, fitsSegmented, formatBytes, frameContext, frameDirection, framesToCrumbs, fromAsset, fromTypeSchema, getIn, groupSummary, hasLink, heldLines, hrefOf, iconButtonVariants, iconKey, imageFromProd, imageToProd, inferField, isBreakpointName, isCropRect, isDockIcon, isDrillable, isFormOnly, isHidden, isShort, isVideoUrl, jsonProblem, kitPathItems, kitToast, kitToastManager, leafValuePlan, linkFromProd, linkIcon, linkProblem, linkShapeOf, linkText, linkToProd, listFromProd, listMeta, listToProd, locationFromDraft, lookLabel, lookOf, matchPositions, matchScore, newBlock, newItem, nextButton, nodeText, normImage, normLink, optionIcons, parentTitleOf, parseTargetTag, pathKey, pickerHex, plainOf, plainText, planFromProd, planToProd, platformKeys, presenceColor, presenceSlot, previewOf, prod_types_exports as prod, propDefToField, propsToTypeSchema, ratingFromProd, ratingScale, ratingToProd, refFilterText, referenceFromProd, referenceNoun, referenceToProd, registerC1Controls, registerC2Controls, registerKitControls, registerKitServices, registerPresenceRoster, resetFieldClipboard, resolveFieldAccess, resolveFrames, resolveHelp, rootFrame, rowToggleField, scaleFromProd, scaleToProd, schemaSlugOf, seesDevSurfaces, selectTriggerClass, setIn, shortcutHintsOn, slugSource, slugTidy, slugTyping, snapRating, statusMap, storedLink, str, summarize, tableFromProd, tableToProd, tagRefusal, tagsFromProd, tagsToProd, targetTag, textLength, titleFromKey, toNum, toTypeSchema, typedRowsFromProd, typedRowsToProd, ungroupNumber, uniqueKey, useAvailableBlocks, useDragReorder, useDrill, useFieldAccess, useFieldDescribedBy, useFieldId, useFieldLabelledBy, useFocusReturn, useForm, useFrameNavigation, useFrameSlots, useGroupStatus, useInsetDepth, useKitEnv, useKitServices, useLinkTargets, useListOps, useLoadedFit, useOwnDescription, useReferenceRecords, useRhythm, useRichTextRefs, useSharedSort, useShortcutHints, useUnavailableBlocks, useUpload, validateValue, variantFamilyFromTypeSchema, variantFamilyToTypeSchema, variantGroupV2, videoFromProd, videoProvider, videoToProd, visibleFields, visibleSchema, withCrop, withDefaultHelp, withTarget, withText, youTubeId, zoneListFromProd, zoneListToProd };
83
+ export { ACTIONS, ACTION_WHEN_READ_ONLY, ADD_SEARCH_AT, AGENT_PRESENCE, AI_PRESETS, ARRAY_CONTROLS, ActionTray, AnimatedFields, Appear, ArrayField, Autocomplete, Avatar, AvatarStack, BUTTON_ICONS, Badge, BlockPicker, BooleanControl, BreakpointGroup, Button, ButtonControl, ButtonIconPicker, ButtonLinkEditor, ButtonPreview, ButtonScreen, ButtonStyleGrid, C1_ACTIONS, C1_CONTROLS, C2_CONTROLS, CAP_IDS, CATEGORY_TO_PROD, COALESCE_MS, CONTROLS, Card, CardHeader, Checkbox, ChoiceCard, ChoiceList, ChoiceSwitch, CodeControl, CodeDialogField, CodeSurface, ColorControl, ComponentSlotControl, DEFAULT_ENV, DEV_FIELD, DEV_ONLY_FIELD, DateControl, Dot, EmailControl, EmptyState, ExpandedEditorModal, FLOATING_LAYER, FallbackControl, Field, FieldBoundary, FieldCommentRequest, FieldDescribedByContext, FieldHeaderSlot, FieldInset, FieldLabelledByContext, FieldList, FieldSection, FieldShell, FieldUnit, FieldUnitRow, FieldsetSection, FileControl, FlowBody, FlowClose, FlowFooter, FlowHeader, FlowLabel, FlowModal, FormPickerControl, FormProvider, FrameCrumbs, FrameHeader, FrameSlotsProvider, FrameStage, FrameView, GalleryControl, GroupTabs, HELP_STRINGS, HEX_COLOR, HISTORY_SEGMENT, HeaderStatus, HeldField, HeldValue, HelpMore, Highlight, HintTooltip, HoverCard, HoverCardContent, HoverCardTrigger, IconButton, IconControl, IconPicker, IconValueGlyph, ImageControl, ImageDetails, Input, InsetScope, IssueDot, ItemList, JsonControl, KIT_ICONS, Kbd, Kbdish, KitAddressContext, KitBreadcrumb, KitEnvProvider, KitErrorCard, KitField, KitIcon, KitSectionTitle, KitServicesProvider, KitToaster, LABEL_HINT_AT, LINK_TYPES, Label, LinkControl, LinkField, LinkForm, LinkLine, LinkOptions, LinkPicker, LinkPopoverBody, LinkQuickEdit, LocationControl, MediaPicker, Menu, MenuCheckItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, MiniCalendar, Modal, ModalBody, ModalClose, ModalContent, ModalFooter, ModalHeader, ModalTrigger, ModeBar, ModeBarDot, ModeBarLink, MoreOptions, MultiSelectControl, NO_CROP_OUTSIDE_LIBRARY, NUMBER_SCALE, NavRow, NestedForm, NumberControl, OptionRow, OrderLockSlot, PageHeader, PeerStack, PlainNumber, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, REL_ITEMS, RHYTHM, RT_PROSE, Radio, RadioGroup, RatingControl, RefThumb, ReferenceControl, ReferencesControl, RevealLink, RichTextControl, RichTextEditor, RichTextExpandAction, RowChrome, RowList, RowsHostContext, SEARCH_THRESHOLD, SEGMENTED_MAX, SEGMENTED_MAX_LABEL, SHOPIFY_REF_LOCK, SITE_PALETTE, STYLE_ITEMS, ScaleControl, ScaleSlider, SchemaForm, SearchInput, SectionAnchorsProvider, Segmented, Select, SelectControl, Separator, SettingsSection, SharedSortProvider, Sheet, SheetClose, SheetContent, SheetTrigger, ShortcutHint, ShortcutHintsProvider, Skeleton, Slider, SlotDepthContext, SlotField, SlotPicker, SlugControl, SlugGenerate, Sparkle, Spinner, Stat, StatusMark, StatusPill, StringControl, StyleGlyph, Switch, TARGET_KEYS, TEXT_FOCUS, Tab, TabList, TabPanel, Table, TableControl, TableFrame, TableFullScreenAction, Tabs, TagsControl, Td, TextControl, Textarea, Th, Thumb, ToggleGroup, ToggleItem, Tooltip, TooltipProvider, TooltipScope, Tr, TrayMeta, TrayMore, UNDO_STEPS, UnknownValueNote, UnreadableValue, UrlControl, VideoControl, VideoPreview, acceptsFile, actionTrayClass, apiName, arrangeFields, arrayMove, avatarRingSpread, badgeVariants, belowMin, blockDefToSchema, buttonFromProd, buttonToProd, buttonVariants, cn, codeFromProd, codeToProd, collectIssues, colorFor, conventionalHelp, cropChoice, cropPreset, cropRect, crumbSignature, dateFromProd, dateToProd, datetimeFromProd, datetimeToProd, defaultGroup, describeLink, detectType, ensureKeys, failingRules, fieldAccessOf, fieldDefToSchema, fieldDefsToSchema, fileNameFromUrl, fileTarget, filterOptions, finalizeLink, findTarget, fitsSegmented, formatBytes, frameContext, frameDirection, framesToCrumbs, fromAsset, fromTypeSchema, getIn, groupSummary, hasLink, heldLines, hrefOf, iconButtonVariants, iconKey, imageFromProd, imageToProd, inferField, isBreakpointName, isCropRect, isDockIcon, isDrillable, isFormOnly, isHidden, isShort, isVideoUrl, jsonProblem, kitPathItems, kitToast, kitToastManager, leafValuePlan, linkFromProd, linkIcon, linkProblem, linkShapeOf, linkText, linkToProd, listFromProd, listMeta, listToProd, locationFromDraft, lookLabel, lookOf, matchPositions, matchScore, newBlock, newItem, nextButton, nodeText, normImage, normLink, optionIcons, parentTitleOf, parseTargetTag, pathKey, pickerHex, plainOf, plainText, planFromProd, planToProd, platformKeys, presenceColor, presenceSlot, previewOf, prod_types_exports as prod, propDefToField, propsToTypeSchema, ratingFromProd, ratingScale, ratingToProd, refFilterText, referenceFromProd, referenceNoun, referenceToProd, registerC1Controls, registerC2Controls, registerKitControls, registerKitServices, registerPresenceRoster, resetFieldClipboard, resolveFieldAccess, resolveFrames, resolveHelp, rootFrame, rowToggleField, scaleFromProd, scaleToProd, schemaSlugOf, seesDevSurfaces, selectTriggerClass, setIn, shortcutHintsOn, slugSource, slugTidy, slugTyping, snapRating, statusMap, storedLink, str, summarize, tableFromProd, tableToProd, tagRefusal, tagsFromProd, tagsToProd, targetTag, textLength, titleFromKey, toNum, toTypeSchema, typedRowsFromProd, typedRowsToProd, ungroupNumber, uniqueKey, useAvailableBlocks, useDragReorder, useDrill, useFieldAccess, useFieldDescribedBy, useFieldId, useFieldLabelledBy, useFocusReturn, useForm, useFrameNavigation, useFrameSlots, useGroupStatus, useInsetDepth, useKitEnv, useKitServices, useLinkTargets, useListOps, useLoadedFit, useOwnDescription, useReferenceRecords, useRhythm, useRichTextRefs, useSharedSort, useShortcutHints, useUnavailableBlocks, useUpload, validateValue, variantFamilyFromTypeSchema, variantFamilyToTypeSchema, variantGroupV2, videoFromProd, videoProvider, videoToProd, visibleFields, visibleSchema, withCrop, withDefaultHelp, withTarget, withText, youTubeId, zoneListFromProd, zoneListToProd };
84
84
 
85
85
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bettercms-ai/kit",
3
- "version": "3.2.0",
3
+ "version": "4.0.0",
4
4
  "description": "The BetterCMS V2 Block Kit: schema language, form engine, controls and design tokens.",
5
5
  "license": "MIT",
6
6
  "type": "module",