@bettercms-ai/kit 2.0.10 → 3.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/README.md +1 -2
- package/dist/adapters/schema.js +45 -5
- package/dist/adapters/schema.js.map +1 -1
- package/dist/brand/logo.js.map +1 -1
- package/dist/context.d.ts +7 -0
- package/dist/context.js +6 -1
- package/dist/context.js.map +1 -1
- package/dist/controls/button.js +1 -1
- package/dist/controls/code.d.ts +24 -1
- package/dist/controls/code.js +36 -20
- package/dist/controls/code.js.map +1 -1
- package/dist/controls/icon.d.ts +28 -0
- package/dist/controls/icon.js +205 -61
- package/dist/controls/icon.js.map +1 -1
- package/dist/controls/index.d.ts +20 -2
- package/dist/controls/index.js +21 -20
- package/dist/controls/index.js.map +1 -1
- package/dist/controls/link.js +4 -4
- package/dist/controls/link.js.map +1 -1
- package/dist/controls/location.js +1 -1
- package/dist/controls/media.js +2 -2
- package/dist/controls/reference.js +3 -2
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/blocks.js +2 -2
- package/dist/controls/rich-text/control.js +1 -1
- package/dist/controls/rich-text/editor.js +5 -5
- package/dist/controls/rich-text/embed.js +1 -1
- package/dist/controls/rich-text/toc.js +1 -1
- package/dist/controls/slot-register.js +1 -1
- package/dist/controls/table/table.js +1 -1
- package/dist/controls/text.js +5 -4
- package/dist/controls/text.js.map +1 -1
- package/dist/core/core.js +1 -1
- package/dist/engine/array.js +4 -8
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/bits.js +1 -1
- package/dist/engine/breadcrumb.js +1 -1
- package/dist/engine/expand.js +1 -1
- package/dist/engine/field-shell.js +8 -7
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.d.ts +1 -12
- package/dist/engine/frame.js +7 -149
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/group-summary.js +7 -4
- package/dist/engine/group-summary.js.map +1 -1
- package/dist/engine/grouping.js +2 -2
- package/dist/engine/item-list.js +2 -2
- package/dist/engine/kit-field.js +3 -7
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/engine/schema-form.d.ts +10 -5
- package/dist/engine/schema-form.js +18 -10
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/engine/slot.js +2 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.js +32 -6
- package/dist/index.js.map +1 -1
- package/dist/kit.css +3 -11
- package/dist/lib/cn.js.map +1 -1
- package/dist/lib/frames.js +1 -1
- package/dist/lib/schema.d.ts +8 -1
- package/dist/lib/schema.js +18 -2
- package/dist/lib/schema.js.map +1 -1
- package/dist/lib/utils.d.ts +1 -4
- package/dist/lib/utils.js +4 -14
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/validate.d.ts +14 -1
- package/dist/lib/validate.js +26 -10
- package/dist/lib/validate.js.map +1 -1
- package/dist/library/coreNotes.d.ts +1 -1
- package/dist/library/coreNotes.js.map +1 -1
- package/dist/library/entries/advanced.entries.js +2 -2
- package/dist/library/entries/advanced.entries.js.map +1 -1
- package/dist/library/entries/commerce.entries.js +1 -1
- package/dist/library/entries/commerce.entries.js.map +1 -1
- package/dist/library/entries/company.entries.js +1 -1
- package/dist/library/entries/company.entries.js.map +1 -1
- package/dist/library/entries/conversion.entries.js +8 -0
- package/dist/library/entries/conversion.entries.js.map +1 -1
- package/dist/library/entries/features.entries.js +7 -2
- package/dist/library/entries/features.entries.js.map +1 -1
- package/dist/library/entries/heroes.entries.js +1 -1
- package/dist/library/entries/heroes.entries.js.map +1 -1
- package/dist/library/entries/listings.entries.js +1 -1
- package/dist/library/entries/listings.entries.js.map +1 -1
- package/dist/library/entries/media.entries.js +5 -5
- package/dist/library/entries/media.entries.js.map +1 -1
- package/dist/library/entries/navigation.entries.js +4 -4
- package/dist/library/entries/navigation.entries.js.map +1 -1
- package/dist/library/examples/faq.js +1 -0
- package/dist/library/examples/faq.js.map +1 -1
- package/dist/library/examples/journalStory.js +1 -2
- package/dist/library/examples/journalStory.js.map +1 -1
- package/dist/library/kit-catalog.json +17 -17
- package/dist/schema/adapters.js +17 -3
- package/dist/schema/adapters.js.map +1 -1
- package/dist/schema/sources.d.ts +9 -1
- package/dist/schema/sources.js +1 -1
- package/dist/schema/sources.js.map +1 -1
- package/dist/schema/types.d.ts +31 -3
- package/dist/schema/types.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/table/table.css +1 -1
- package/dist/theme.css +18 -9
- package/dist/tokens.css +32 -60
- package/dist/ui/action-tray.d.ts +1 -3
- package/dist/ui/action-tray.js +3 -20
- package/dist/ui/action-tray.js.map +1 -1
- package/dist/ui/display.d.ts +1 -4
- package/dist/ui/display.js +4 -6
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/index.js +3 -3
- package/dist/ui/overlay.d.ts +2 -5
- package/dist/ui/overlay.js +3 -4
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/path-crumbs.d.ts +0 -2
- package/dist/ui/path-crumbs.js.map +1 -1
- package/dist/ui/surfaces.d.ts +2 -18
- package/dist/ui/surfaces.js +3 -19
- package/dist/ui/surfaces.js.map +1 -1
- package/dist/ui/toast.js +1 -1
- package/dist/ui/toast.js.map +1 -1
- package/package.json +2 -2
package/dist/engine/frame.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","names":[],"sources":["../../src/engine/frame.tsx"],"sourcesContent":["/**\n * FrameView — what the panel shows for the current breadcrumb: the root fields, a drilled object / array item /\n * slot block (with \"2 of 4\" stepper, variant switcher and per-slot layout settings), the one button screen,\n * or a field's history as a stacked panel. Port of V2 engine/frame.tsx.\n *\n * FrameStage + useFrameNavigation — V2 schema-form's drill-in stage (direction-aware slide, scroll memory per frame,\n * focus on the entering frame, Esc / ⌥↑↓). Exported here so SchemaForm wires them without re-deriving the motion.\n *\n * FrameSlots — the frame draws other lanes' pieces (FieldList / FieldSection from grouping, ButtonScreen from link,\n * TableFrame from table). They arrive through context so this file never imports a module that does not exist yet;\n * a missing slot falls back to a plain field list (FieldList), the raw value (ButtonScreen, through\n * FallbackControl), a named note (TableFrame) or nothing (FieldSection). SchemaForm always hands ButtonScreen and TableFrame.\n */\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { IconArrowBackUp, IconArrowDown, IconArrowUp, IconCopy, IconDots, IconTrash } from \"@tabler/icons-react\";\nimport { Button, IconButton } from \"../ui/button\";\nimport { Avatar } from \"../ui/display\";\nimport { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Tooltip } from \"../ui/overlay\";\nimport { Segmented } from \"../ui/controls\";\nimport { fitsSegmented } from \"../ui/choice-switch\";\nimport { Select } from \"../ui/select\";\nimport { resolveFieldAccess, seesDevSurfaces, useForm, useKitEnv, useKitServices } from \"../context\";\nimport { cn } from \"../lib/cn\";\nimport { relTime } from \"../lib/utils\";\nimport { HISTORY_SEGMENT, type FieldGroup, type FieldPath, type FieldSchema, type Fieldset } from \"../schema/types\";\nimport type { Frame } from \"../lib/frames\";\nimport { frameKeyOf, isObj, newKey, pathKey, same } from \"../lib/path\";\nimport { condCtx, isHidden, isTextual, plainText, previewOf, summarize } from \"../lib/schema\";\nimport { Thumb } from \"./bits\";\nimport { FallbackControl, KitField } from \"./kit-field\";\nimport { apiName } from \"./field-shell\";\n\n/* ── Slots (other lanes) ───────────────────────────────────────────── */\nexport interface FrameFieldListProps {\n fields: FieldSchema[];\n fieldsets?: Fieldset[];\n groups?: FieldGroup[];\n basePath: FieldPath;\n memoryKey: string;\n}\nexport interface FrameSlots {\n /** grouping lane: engine/field-list.tsx `FieldList` */\n FieldList?: React.ComponentType<FrameFieldListProps>;\n /** grouping lane: engine/grouping.tsx `FieldSection` (the slot-settings section of a slot block) */\n FieldSection?: React.ComponentType<{ title: string; description?: string; collapsible?: boolean; children: React.ReactNode }>;\n /** link lane: controls/link.tsx `ButtonScreen` + `normLink` (the \"button\" frame) */\n ButtonScreen?: React.ComponentType<{ value: unknown; onChange: (v: unknown) => void; title: string; readOnly?: boolean }>;\n normLink?: (v: unknown) => { label?: string };\n /** table lane: controls/table.tsx `TableFrame` (tableRow / tableColumn frames) */\n TableFrame?: React.ComponentType<{ frame: Frame }>;\n}\nconst SlotsCtx = React.createContext<FrameSlots>({});\nexport const FrameSlotsProvider = SlotsCtx.Provider;\nexport const useFrameSlots = () => React.useContext(SlotsCtx);\n\n/** Stand-in until the grouping lane's FieldList lands: the frame's visible fields in schema order. */\nfunction PlainFieldList({ fields, basePath }: FrameFieldListProps) {\n const form = useForm()!;\n const raw = basePath.length ? form.getAt(basePath) : form.value;\n const parent = isObj(raw) ? raw : {};\n const cc = condCtx(form, basePath);\n const shown = fields.filter((f) => !isHidden(f, parent, cc));\n return (\n <div className=\"flex flex-col gap-5\">\n {shown.map((f) => (\n <div key={f.name} className=\"min-w-0\">\n <KitField field={f} path={[...basePath, f.name]} parent={parent} />\n </div>\n ))}\n {shown.length === 0 ? <p className=\"py-6 text-center text-kit-sm text-kit-fg-3\">No fields here yet.</p> : null}\n </div>\n );\n}\n\n/** A button frame outside SchemaForm (no ButtonScreen slot) edits the button's raw value (FallbackControl), never an empty body. */\nfunction RawButtonScreen({ frame }: { frame: Frame }) {\n const form = useForm()!;\n const id = React.useId();\n const field = frame.field ?? { name: String(frame.path.at(-1) ?? \"button\"), title: frame.title, type: \"button\" as const };\n return <FallbackControl field={field} value={form.getAt(frame.path)} onChange={(n) => form.setAt(frame.path, n)} id={id} path={frame.path} />;\n}\n\n/** The button frame: header (the button's label) + the kit ButtonScreen, read-only when the lens can't edit the field. */\nfunction ButtonFrame({ frame, parentTitle }: { frame: Frame; parentTitle?: string }) {\n const form = useForm()!;\n const env = useKitEnv();\n const slots = useFrameSlots();\n const v = form.getAt(frame.path);\n const ButtonScreen = slots.ButtonScreen;\n const readOnly = frame.field ? resolveFieldAccess(frame.field, env).readOnly : !!env.readOnly;\n return (\n <div className=\"flex flex-col gap-5\">\n <FrameHeader frame={frame} context={parentTitle ? `${frame.title} in ${parentTitle}` : frame.title} title={slots.normLink?.(v).label || frame.title} />\n {ButtonScreen ? <ButtonScreen value={v} onChange={(n) => form.setAt(frame.path, n)} title={frame.title} readOnly={readOnly} /> : <RawButtonScreen frame={frame} />}\n </div>\n );\n}\n\n/* ── FrameView ─────────────────────────────────────────────────────── */\nexport function FrameView({ frame, parentTitle }: { frame: Frame; parentTitle?: string }) {\n const form = useForm()!;\n const slots = useFrameSlots();\n const FieldList = slots.FieldList ?? PlainFieldList;\n if (frame.kind === \"history\") return <HistoryView field={frame.field!} path={frame.path.slice(0, -1)} />;\n if (frame.kind === \"button\") return <ButtonFrame frame={frame} parentTitle={parentTitle} />;\n // D50: a table row or column drills exactly like an array item: the same header (title, n of N, ↑ ↓ ⋯), its cells below\n if (frame.kind === \"tableRow\" || frame.kind === \"tableColumn\") {\n const it = frame.item!;\n const TableFrame = slots.TableFrame;\n return (\n <div className=\"flex flex-col gap-5\">\n <FrameHeader frame={frame} context={`${it.itemSchema?.title} ${it.index + 1} of ${it.count} in ${frame.field?.title ?? \"the table\"}`} title={frame.title} />\n {TableFrame ? (\n <TableFrame frame={frame} />\n ) : (\n /* Only the kit table control opens a row or column frame; until it is ported the table is the host's control,\n which edits rows in place. A path restored into one says so instead of drawing an empty body. */\n <p role=\"note\" data-kit-legacy=\"table\" className=\"text-kit-sm text-kit-fg-3\">\n This table's rows and columns are edited in the table itself.\n </p>\n )}\n </div>\n );\n }\n if (frame.kind === \"root\") return <FieldList fields={frame.fields} fieldsets={frame.fieldsets} groups={frame.groups} basePath={[]} memoryKey=\"root\" />;\n const it = frame.item;\n const block = it?.block;\n const variants = block?.variants ?? [];\n const raw = form.getAt(frame.path);\n const cur = isObj(raw) ? raw : {};\n const FieldSection = slots.FieldSection;\n return (\n <div className=\"flex flex-col gap-5\">\n <FrameHeader frame={frame} context={frameContext(frame, parentTitle)} title={frame.title} />\n {block && variants.length > 1 ? (\n <div className=\"flex flex-col gap-1.5\">\n <span className=\"text-kit-sm font-medium text-kit-fg-2\">Layout</span>\n {fitsSegmented(variants.map((v) => v.name)) ? (\n <Segmented\n aria-label=\"Layout\"\n value={String(cur._variant ?? variants[0].id)}\n onChange={(v) => form.setAt([...frame.path, \"_variant\"], v)}\n items={variants.map((v) => ({ value: v.id, label: v.name }))}\n className=\"w-full [&>button]:flex-1\"\n />\n ) : (\n <Select\n aria-label=\"Variant\"\n value={String(cur._variant ?? variants[0].id)}\n onValueChange={(v) => form.setAt([...frame.path, \"_variant\"], v)}\n options={variants.map((v) => ({ value: v.id, label: v.name, description: v.description }))}\n />\n )}\n </div>\n ) : null}\n <FieldList fields={frame.fields} fieldsets={frame.fieldsets} groups={frame.groups} basePath={frame.path} memoryKey={`f:${frame.kind}:${it?.block?.name ?? it?.itemSchema?.name ?? frame.field?.name ?? \"\"}`} />\n {it?.slotField?.slotSettings?.length && FieldSection ? (\n <FieldSection title={`Layout in ${it.slotField.title.toLowerCase()}`} description=\"How this block sits in its parent. The block's own content is above.\" collapsible={false}>\n <FieldList fields={it.slotField.slotSettings} basePath={[...frame.path, \"_settings\"]} memoryKey={`slotset:${it.slotField.name}`} />\n </FieldSection>\n ) : null}\n </div>\n );\n}\n\n/**\n * The context line under a drilled frame's title: \"Tier 1 of 3 in Tiers\" for an item (the item noun is the item\n * schema's title, which the adapter reads back from prod `ui.itemLabel`), \"Address in Author\" for an object.\n */\nexport function frameContext(frame: Frame, parentTitle?: string): string {\n const it = frame.item;\n if (it) {\n const noun = (frame.kind === \"block\" ? it.block?.title : it.itemSchema?.title) ?? \"Item\";\n const owner = (frame.kind === \"block\" ? it.slotField?.title : frame.field?.title) ?? \"the list\";\n return `${noun} ${it.index + 1} of ${it.count} in ${owner}`;\n }\n return parentTitle ? `${frame.field?.title ?? \"Group\"} in ${parentTitle}` : \"Group\";\n}\n\n/**\n * CPO D43 — the drilled frame's header answers \"what am I editing, and where does it live?\":\n * [media?] Starter [↑] [↓] [⋯]\n * Tier 1 of 3 in Tiers\n * The big title lives HERE only; the breadcrumb above is the path (its current crumb is small, D38). Prev / next are\n * labelled icon buttons whose tooltips name the sibling (\"Previous tier: Starter\"). No eyebrow, no duplicate counter.\n * Title 14/24 semibold (owner call). The native title= on the truncating h2 is V2 parity (kit-engine deviation from\n * the dashboard's no-title rule, see run ledger #32).\n */\nexport function FrameHeader({ frame, context, title }: { frame: Frame; context: string; title: string }) {\n const form = useForm()!;\n const { toast } = useKitServices();\n const it = frame.item;\n const media = it ? previewOf(it.block ?? it.itemSchema, form.getAt(frame.path), it.index).media : undefined;\n const step = (d: -1 | 1) => {\n if (!it) return;\n const n = it.index + d;\n if (n < 0 || n >= it.count) return;\n form.navigate([...it.arrayPath, n]);\n };\n const listRaw = it ? form.getAt(it.arrayPath) : undefined;\n const list = Array.isArray(listRaw) ? listRaw : [];\n const noun = (it?.block?.title ?? it?.itemSchema?.title ?? \"item\").toLowerCase();\n const sibling = (i: number) =>\n it && i >= 0 && i < it.count ? (it.titleAt ? it.titleAt(i) : previewOf(it.block ?? it.itemSchema, list[i], i, it.block?.title ?? it.itemSchema?.title).title) : \"\";\n const prev = it ? sibling(it.index - 1) : \"\";\n const next = it ? sibling(it.index + 1) : \"\";\n /* Duplicate / Remove move to another frame: the menu must not hand focus back to its trigger in the exiting frame\n (it unmounts, focus would drop to <body>); the stage focuses the entering frame instead */\n const moved = React.useRef(false);\n return (\n <div className=\"flex items-start gap-2.5 outline-none\" data-frame-header tabIndex={-1}>\n {media ? <Thumb media={media} size={36} /> : null}\n <div className=\"min-w-0 flex-1\">\n <h2 className=\"truncate text-kit-base font-semibold leading-6 text-kit-fg\" title={title}>\n {title}\n </h2>\n <p className=\"truncate text-kit-xs leading-4 text-kit-fg-3\">{context}</p>\n </div>\n {it ? (\n <div className=\"-mr-1 flex shrink-0 items-center gap-0.5 pt-0.5\">\n <IconButton\n label={prev ? `Previous ${noun}: ${prev}` : `No previous ${noun}`}\n tooltip={prev ? `Previous ${noun}: ${prev}` : `First ${noun}`}\n size=\"sm\"\n disabled={it.index === 0}\n onClick={() => step(-1)}\n >\n <IconArrowUp stroke={1.5} />\n </IconButton>\n <IconButton\n label={next ? `Next ${noun}: ${next}` : `No next ${noun}`}\n tooltip={next ? `Next ${noun}: ${next}` : `Last ${noun}`}\n size=\"sm\"\n disabled={it.index >= it.count - 1}\n onClick={() => step(1)}\n >\n <IconArrowDown stroke={1.5} />\n </IconButton>\n <Menu>\n <Tooltip content={`${title} actions`}>\n <MenuTrigger\n render={\n <IconButton label={`${title} actions`} tooltip={false} size=\"sm\">\n <IconDots stroke={1.5} />\n </IconButton>\n }\n />\n </Tooltip>\n <MenuContent align=\"end\" className=\"w-48\" finalFocus={() => !moved.current}>\n <MenuItem\n icon={<IconCopy stroke={1.5} />}\n onClick={() => {\n moved.current = true;\n const copy = isObj(list[it.index]) ? { ...(structuredClone(list[it.index]) as object), _key: newKey() } : list[it.index];\n form.setAt(it.arrayPath, [...list.slice(0, it.index + 1), copy, ...list.slice(it.index + 1)]);\n form.navigate([...it.arrayPath, it.index + 1]);\n toast?.success(\"Duplicated\", { description: \"You're now editing the copy.\" });\n }}\n >\n Duplicate\n </MenuItem>\n <MenuSeparator />\n <MenuItem\n danger\n icon={<IconTrash stroke={1.5} />}\n onClick={() => {\n moved.current = true;\n const prevList = list;\n form.navigate(parentFramePath(it.arrayPath));\n form.setAt(it.arrayPath, list.filter((_, j) => j !== it.index));\n toast?.(`“${title}” removed`, { action: { label: \"Undo\", onClick: () => form.setAt(it.arrayPath, prevList) }, duration: 10_000 });\n }}\n >\n Remove\n </MenuItem>\n </MenuContent>\n </Menu>\n </div>\n ) : null}\n </div>\n );\n}\n/** The frame that owns an array: drop the array field name (and the item index above it, if any). */\nconst parentFramePath = (arrayPath: FieldPath): FieldPath => arrayPath.slice(0, -1);\n\n/* ── History (stacked panel) ───────────────────────────────────────── */\n/**\n * V2 drew demo people (seed `currentUser` / `members`, a fixed \"26 hours ago\" / \"3 days ago\"). The kit has no seed:\n * session versions carry their own `by` and `at`; the opened and published baselines have no author or time here, so\n * their row says only what they are.\n */\nexport function HistoryView({ field, path }: { field: FieldSchema; path: FieldPath }) {\n const env = useKitEnv();\n const form = useForm()!;\n const { toast } = useKitServices();\n const key = pathKey(path);\n const now = form.getAt(path);\n const session = form.history(key);\n const baseline = form.baselineAt(path);\n const published = form.hasPublished ? form.publishedAt(path) : undefined;\n type V = { id: string; label: string; by?: string; at?: number; value: unknown; current?: boolean };\n const versions: V[] = [];\n versions.push({ id: \"now\", label: \"Current draft\", by: session[0]?.by ?? \"You\", at: Date.now(), value: now, current: true });\n session.slice(1).forEach((h, i) => versions.push({ id: `s${i}`, label: h.label ?? \"Edit\", by: h.by, at: h.at, value: h.value }));\n if (!same(baseline, now) && !session.some((h) => same(h.value, baseline))) versions.push({ id: \"open\", label: \"When you opened it\", value: baseline });\n if (published !== undefined) versions.push({ id: \"pub\", label: \"Published\", value: published });\n const show = (v: unknown) => {\n if (isTextual(field.type)) return plainText(v) || \"Empty\";\n if (Array.isArray(v)) return `${v.length} ${v.length === 1 ? \"item\" : \"items\"}`;\n if (isObj(v)) return summarize(field.fields ?? [], v) || plainText(v) || \"Set\";\n if (typeof v === \"boolean\") return v ? \"On\" : \"Off\";\n return v == null || v === \"\" ? \"Empty\" : String(v);\n };\n const meta = (v: V) => {\n if (v.current) return `Now · ${v.by}`;\n if (v.at === undefined) return v.label;\n return `${relTime(v.at)}${v.by ? ` · ${v.by}` : \"\"}${v.label ? ` · ${v.label}` : \"\"}`;\n };\n return (\n <div className=\"flex flex-col gap-4\">\n <div>\n {seesDevSurfaces(env) ? <div className=\"text-kit-2xs font-medium text-kit-fg-3\">{apiName(form.schema.name, path)}</div> : null}\n <h2 className=\"text-kit-base font-semibold text-kit-fg\">History of {field.title.toLowerCase()}</h2>\n <p className=\"mt-1 text-kit-xs text-kit-fg-3\">Restoring lands in the draft and doesn't publish. Publish afterwards to go live.</p>\n </div>\n <ul className=\"overflow-hidden rounded-kit-lg border border-kit-line\">\n {versions.map((v, i) => (\n <li key={v.id} data-version={v.id} className=\"group/ver flex items-start gap-2.5 border-b border-kit-line-subtle px-3 py-2.5 last:border-b-0\">\n {v.by ? <Avatar name={v.by} size={22} /> : <span aria-hidden className=\"size-[22px] shrink-0 rounded-full bg-kit-muted\" />}\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-center gap-1.5 text-kit-sm\">\n <span className=\"font-medium text-kit-fg\">{v.current ? \"Current draft\" : `Version ${versions.length - i}`}</span>\n {v.id === \"pub\" ? <span className=\"rounded-kit-md bg-kit-success-soft px-1 text-kit-2xs text-kit-success-fg\">Published</span> : null}\n </div>\n <div className=\"text-kit-xs text-kit-fg-3\">{meta(v)}</div>\n <div className={cn(\"mt-1 line-clamp-2 rounded-kit-md bg-kit-subtle px-2 py-1 text-kit-xs text-kit-fg-2\", field.type === \"color\" && \"flex items-center gap-1.5\")}>\n {field.type === \"color\" && typeof v.value === \"string\" ? <span className=\"size-3 rounded-kit-md\" style={{ background: v.value }} /> : null}\n {show(v.value)}\n </div>\n </div>\n {v.current ? null : (\n <Button\n size=\"xs\"\n variant=\"secondary\"\n className=\"opacity-0 transition-opacity focus-visible:opacity-100 group-hover/ver:opacity-100 [@media(pointer:coarse)]:opacity-100\"\n leftIcon={<IconArrowBackUp stroke={1.5} />}\n onClick={() => {\n const prev = now;\n form.setAt(path, v.value, { label: \"Restored\" });\n form.navigate(parentOfField(path));\n toast?.(\"Restored as a draft\", { description: field.title, action: { label: \"Undo\", onClick: () => form.setAt(path, prev) }, duration: 10_000 });\n }}\n >\n Restore\n </Button>\n )}\n </li>\n ))}\n </ul>\n </div>\n );\n}\n/** Navigate back from a field's history to the frame that shows the field. */\nexport function parentOfField(path: FieldPath): FieldPath {\n // walk up to the nearest drillable frame boundary: an array index or the root\n for (let i = path.length - 1; i >= 0; i--) if (typeof path[i] === \"number\") return path.slice(0, i + 1);\n return path.length > 1 ? path.slice(0, -1) : [];\n}\n\n/* ── Stage: direction-aware slide, scroll memory, focus, keys (V2 schema-form) ───────────────── */\n/** The title shown as `parentTitle` for the current frame (the root crumb's label for depth 1). */\nexport function parentTitleOf(frames: Frame[], rootLabel: string): string | undefined {\n if (frames.length < 2) return undefined;\n return frames.length === 2 ? rootLabel : frames[frames.length - 2].title;\n}\n\n/** Floating layers (Base UI popups carry these roles); keys and focus coming from one belong to that layer. */\nconst LAYER = \"[role=dialog],[role=menu],[role=listbox]\";\n\n/** Slide direction for a frame change: deeper → 1, shallower → −1, a sibling step → by index. */\nexport function frameDirection(prev: { depth: number; index: number; key: string }, frames: Frame[], key: string): 0 | 1 | -1 {\n if (prev.key === key) return 0;\n const cur = frames[frames.length - 1];\n if (frames.length > prev.depth) return 1;\n if (frames.length < prev.depth) return -1;\n return (cur.item?.index ?? 0) >= prev.index ? 1 : -1;\n}\n\n/**\n * The drill-in stack's behaviour. `root` wraps the form (keys bubble to it), `scroller` is the scrolling element (or\n * null when the host scrolls). Returns the current frame, its key, the slide direction and the form's onKeyDown.\n */\nexport function useFrameNavigation({\n frames,\n navigate,\n root,\n scroller,\n}: {\n frames: Frame[];\n navigate: (path: FieldPath) => void;\n root: React.RefObject<HTMLElement | null>;\n scroller: React.RefObject<HTMLElement | null>;\n}) {\n const current = frames[frames.length - 1];\n const frameKey = frameKeyOf(current.path);\n const prev = React.useRef({ depth: frames.length, index: current.item?.index ?? 0, key: frameKey });\n const dir = frameDirection(prev.current, frames, frameKey);\n const dirRef = React.useRef<number>(1);\n if (dir) dirRef.current = dir;\n\n const scrollMem = React.useRef(new Map<string, number>());\n React.useLayoutEffect(() => {\n const was = prev.current.key;\n if (was === frameKey) return;\n if (scroller.current) scrollMem.current.set(was, scroller.current.scrollTop);\n prev.current = { depth: frames.length, index: current.item?.index ?? 0, key: frameKey };\n const el = scroller.current;\n if (el) el.scrollTop = scrollMem.current.get(frameKey) ?? 0;\n const active = document.activeElement;\n /* a move started from a portalled menu (FrameHeader ⋯ → Duplicate / Remove) leaves focus in that layer, outside root */\n const layer = active && active !== document.body ? active.closest(LAYER) : null;\n const fromLayer = !!layer && !layer.contains(root.current);\n if (root.current && (active === document.body || root.current.contains(active) || fromLayer)) {\n // the exiting frame is still mounted during its exit animation — focus the ENTERING one\n const target = root.current.querySelector<HTMLElement>(`[data-frame-body=\"${CSS.escape(frameKey)}\"]`);\n target?.focus({ preventScroll: true });\n }\n });\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.defaultPrevented) return;\n const t = e.target as HTMLElement;\n // ignore keys from floating layers opened by this form; a form INSIDE a dialog still handles its own keys\n // (V2 also listed Radix's popper wrapper; Base UI popups carry these roles themselves)\n const layer = t.closest(LAYER);\n if (layer && root.current && !layer.contains(root.current)) return;\n if (e.key === \"Escape\" && frames.length > 1 && !t.isContentEditable) {\n e.preventDefault();\n e.stopPropagation();\n navigate(frames[frames.length - 2].path);\n return;\n }\n const it = current.item;\n if (it && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\")) {\n const typing = t.matches(\"input,textarea,select\") || t.isContentEditable;\n if (e.altKey || (!typing && t.matches(\"[data-frame-body],[data-frame-header]\"))) {\n const n = it.index + (e.key === \"ArrowUp\" ? -1 : 1);\n if (n >= 0 && n < it.count) {\n e.preventDefault();\n navigate([...it.arrayPath, n]);\n }\n }\n }\n };\n\n return { current, frameKey, dir: dirRef.current, onKeyDown };\n}\n\nconst EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\n\n/**\n * The frame body with V2's slide: 24px along the travel direction + fade, 220ms, ease [0.22, 1, 0.36, 1]; reduced\n * motion keeps only the fade. `before` renders inside the root frame above its fields (the synced-from note).\n */\nexport function FrameStage({\n frames,\n frameKey,\n dir,\n rootLabel,\n variant,\n before,\n review,\n}: {\n frames: Frame[];\n frameKey: string;\n dir: number;\n rootLabel: string;\n variant: \"panel\" | \"document\";\n before?: React.ReactNode;\n /** D61 Review changes is on: the clip leaves 16px on the left for the change bars */\n review?: boolean;\n}) {\n const reduce = useReducedMotion();\n const current = frames[frames.length - 1];\n return (\n // the drill slide is clipped sideways; with Review changes on (D61) the clip leaves 16px on the left for the change bars\n <div className=\"relative\" style={review ? { clipPath: \"inset(-100vh 0 -100vh -16px)\" } : { overflowX: \"clip\" }}>\n <AnimatePresence mode=\"popLayout\" initial={false} custom={dir}>\n <motion.div\n key={frameKey}\n custom={dir}\n variants={{\n enter: (d: number) => ({ x: reduce ? 0 : d * 24, opacity: 0 }),\n center: { x: 0, opacity: 1 },\n exit: (d: number) => ({ x: reduce ? 0 : d * -24, opacity: 0 }),\n }}\n initial=\"enter\"\n animate=\"center\"\n exit=\"exit\"\n transition={{ duration: 0.22, ease: EASE }}\n data-frame-body={frameKey}\n tabIndex={-1}\n className={cn(\"outline-none focus-visible:shadow-none\", variant === \"document\" ? \"py-1\" : \"px-4 py-4\")}\n >\n {current.kind === \"root\" ? before : null}\n <FrameView frame={current} parentTitle={parentTitleOf(frames, rootLabel)} />\n </motion.div>\n </AnimatePresence>\n </div>\n );\n}\n\nexport { HISTORY_SEGMENT };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAM,WAAW,MAAM,cAA0B,CAAC,CAAC;AACnD,IAAa,qBAAqB,SAAS;AAC3C,IAAa,sBAAsB,MAAM,WAAW,QAAQ;;AAG5D,SAAS,eAAe,EAAE,QAAQ,YAAiC;CACjE,MAAM,OAAO,QAAQ;CACrB,MAAM,MAAM,SAAS,SAAS,KAAK,MAAM,QAAQ,IAAI,KAAK;CAC1D,MAAM,SAAS,MAAM,GAAG,IAAI,MAAM,CAAC;CACnC,MAAM,KAAK,QAAQ,MAAM,QAAQ;CACjC,MAAM,QAAQ,OAAO,QAAQ,MAAM,CAAC,SAAS,GAAG,QAAQ,EAAE,CAAC;CAC3D,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACG,MAAM,KAAK,MACV,oBAAC,OAAD;GAAkB,WAAU;GAC1B,UAAA,oBAAC,UAAD;IAAU,OAAO;IAAG,MAAM,CAAC,GAAG,UAAU,EAAE,IAAI;IAAW;GAAS,CAA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K,SAAS;KAAE;IAC9D;IACA,SAAQ;IACR,SAAQ;IACR,MAAK;IACL,YAAY;KAAE,UAAU;KAAM,MAAM;IAAK;IACzC,mBAAiB;IACjB,UAAU;IACV,WAAW,GAAG,0CAA0C,YAAY,aAAa,SAAS,WAAW;IAdvG,UAAA,CAgBG,QAAQ,SAAS,SAAS,SAAS,MACpC,oBAAC,WAAD;KAAW,OAAO;KAAS,aAAa,cAAc,QAAQ,SAAS;IAAI,CAAA,CACjE;GAjBL,GAAA,QAiBK;EACG,CAAA;CACd,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"frame.js","names":[],"sources":["../../src/engine/frame.tsx"],"sourcesContent":["/**\n * FrameView — what the panel shows for the current breadcrumb: the root fields, a drilled object / array item /\n * slot block (with \"2 of 4\" stepper, variant switcher and per-slot layout settings), the one button screen,\n * or a field's history as a stacked panel. Port of V2 engine/frame.tsx.\n *\n * FrameStage + useFrameNavigation — V2 schema-form's drill-in stage (direction-aware slide, scroll memory per frame,\n * focus on the entering frame, Esc / ⌥↑↓). Exported here so SchemaForm wires them without re-deriving the motion.\n *\n * FrameSlots — the frame draws other lanes' pieces (FieldList / FieldSection from grouping, ButtonScreen from link,\n * TableFrame from table). They arrive through context so this file never imports a module that does not exist yet;\n * a missing slot falls back to a plain field list (FieldList), the raw value (ButtonScreen, through\n * FallbackControl), a named note (TableFrame) or nothing (FieldSection). SchemaForm always hands ButtonScreen and TableFrame.\n */\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { IconArrowDown, IconArrowUp, IconCopy, IconDots, IconTrash } from \"@tabler/icons-react\";\nimport { IconButton } from \"../ui/button\";\nimport { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Tooltip } from \"../ui/overlay\";\nimport { Segmented } from \"../ui/controls\";\nimport { fitsSegmented } from \"../ui/choice-switch\";\nimport { Select } from \"../ui/select\";\nimport { resolveFieldAccess, useForm, useKitEnv, useKitServices } from \"../context\";\nimport { cn } from \"../lib/cn\";\nimport { HISTORY_SEGMENT, type FieldGroup, type FieldPath, type FieldSchema, type Fieldset } from \"../schema/types\";\nimport type { Frame } from \"../lib/frames\";\nimport { frameKeyOf, isObj, newKey } from \"../lib/path\";\nimport { condCtx, isHidden, previewOf } from \"../lib/schema\";\nimport { Thumb } from \"./bits\";\nimport { FallbackControl, KitField } from \"./kit-field\";\n\n/* ── Slots (other lanes) ───────────────────────────────────────────── */\nexport interface FrameFieldListProps {\n fields: FieldSchema[];\n fieldsets?: Fieldset[];\n groups?: FieldGroup[];\n basePath: FieldPath;\n memoryKey: string;\n}\nexport interface FrameSlots {\n /** grouping lane: engine/field-list.tsx `FieldList` */\n FieldList?: React.ComponentType<FrameFieldListProps>;\n /** grouping lane: engine/grouping.tsx `FieldSection` (the slot-settings section of a slot block) */\n FieldSection?: React.ComponentType<{ title: string; description?: string; collapsible?: boolean; children: React.ReactNode }>;\n /** link lane: controls/link.tsx `ButtonScreen` + `normLink` (the \"button\" frame) */\n ButtonScreen?: React.ComponentType<{ value: unknown; onChange: (v: unknown) => void; title: string; readOnly?: boolean }>;\n normLink?: (v: unknown) => { label?: string };\n /** table lane: controls/table.tsx `TableFrame` (tableRow / tableColumn frames) */\n TableFrame?: React.ComponentType<{ frame: Frame }>;\n}\nconst SlotsCtx = React.createContext<FrameSlots>({});\nexport const FrameSlotsProvider = SlotsCtx.Provider;\nexport const useFrameSlots = () => React.useContext(SlotsCtx);\n\n/** Stand-in until the grouping lane's FieldList lands: the frame's visible fields in schema order. */\nfunction PlainFieldList({ fields, basePath }: FrameFieldListProps) {\n const form = useForm()!;\n const raw = basePath.length ? form.getAt(basePath) : form.value;\n const parent = isObj(raw) ? raw : {};\n const cc = condCtx(form, basePath);\n const shown = fields.filter((f) => !isHidden(f, parent, cc));\n return (\n <div className=\"flex flex-col gap-5\">\n {shown.map((f) => (\n <div key={f.name} className=\"min-w-0\">\n <KitField field={f} path={[...basePath, f.name]} parent={parent} />\n </div>\n ))}\n {shown.length === 0 ? <p className=\"py-6 text-center text-kit-sm text-kit-fg-3\">No fields here yet.</p> : null}\n </div>\n );\n}\n\n/** A button frame outside SchemaForm (no ButtonScreen slot) edits the button's raw value (FallbackControl), never an empty body. */\nfunction RawButtonScreen({ frame }: { frame: Frame }) {\n const form = useForm()!;\n const id = React.useId();\n const field = frame.field ?? { name: String(frame.path.at(-1) ?? \"button\"), title: frame.title, type: \"button\" as const };\n return <FallbackControl field={field} value={form.getAt(frame.path)} onChange={(n) => form.setAt(frame.path, n)} id={id} path={frame.path} />;\n}\n\n/** The button frame: header (the button's label) + the kit ButtonScreen, read-only when the lens can't edit the field. */\nfunction ButtonFrame({ frame, parentTitle }: { frame: Frame; parentTitle?: string }) {\n const form = useForm()!;\n const env = useKitEnv();\n const slots = useFrameSlots();\n const v = form.getAt(frame.path);\n const ButtonScreen = slots.ButtonScreen;\n const readOnly = frame.field ? resolveFieldAccess(frame.field, env).readOnly : !!env.readOnly;\n return (\n <div className=\"flex flex-col gap-5\">\n <FrameHeader frame={frame} context={parentTitle ? `${frame.title} in ${parentTitle}` : frame.title} title={slots.normLink?.(v).label || frame.title} />\n {ButtonScreen ? <ButtonScreen value={v} onChange={(n) => form.setAt(frame.path, n)} title={frame.title} readOnly={readOnly} /> : <RawButtonScreen frame={frame} />}\n </div>\n );\n}\n\n/* ── FrameView ─────────────────────────────────────────────────────── */\nexport function FrameView({ frame, parentTitle }: { frame: Frame; parentTitle?: string }) {\n const form = useForm()!;\n const slots = useFrameSlots();\n const FieldList = slots.FieldList ?? PlainFieldList;\n if (frame.kind === \"history\") return null; // D61: a field's history is the host's one History panel (onFieldHistory)\n if (frame.kind === \"button\") return <ButtonFrame frame={frame} parentTitle={parentTitle} />;\n // D50: a table row or column drills exactly like an array item: the same header (title, n of N, ↑ ↓ ⋯), its cells below\n if (frame.kind === \"tableRow\" || frame.kind === \"tableColumn\") {\n const it = frame.item!;\n const TableFrame = slots.TableFrame;\n return (\n <div className=\"flex flex-col gap-5\">\n <FrameHeader frame={frame} context={`${it.itemSchema?.title} ${it.index + 1} of ${it.count} in ${frame.field?.title ?? \"the table\"}`} title={frame.title} />\n {TableFrame ? (\n <TableFrame frame={frame} />\n ) : (\n /* Only the kit table control opens a row or column frame; until it is ported the table is the host's control,\n which edits rows in place. A path restored into one says so instead of drawing an empty body. */\n <p role=\"note\" data-kit-legacy=\"table\" className=\"text-kit-sm text-kit-fg-3\">\n This table's rows and columns are edited in the table itself.\n </p>\n )}\n </div>\n );\n }\n if (frame.kind === \"root\") return <FieldList fields={frame.fields} fieldsets={frame.fieldsets} groups={frame.groups} basePath={[]} memoryKey=\"root\" />;\n const it = frame.item;\n const block = it?.block;\n const variants = block?.variants ?? [];\n const raw = form.getAt(frame.path);\n const cur = isObj(raw) ? raw : {};\n const FieldSection = slots.FieldSection;\n return (\n <div className=\"flex flex-col gap-5\">\n <FrameHeader frame={frame} context={frameContext(frame, parentTitle)} title={frame.title} />\n {block && variants.length > 1 ? (\n <div className=\"flex flex-col gap-1.5\">\n <span className=\"text-kit-sm font-medium text-kit-fg-2\">Layout</span>\n {fitsSegmented(variants.map((v) => v.name)) ? (\n <Segmented\n aria-label=\"Layout\"\n value={String(cur._variant ?? variants[0].id)}\n onChange={(v) => form.setAt([...frame.path, \"_variant\"], v)}\n items={variants.map((v) => ({ value: v.id, label: v.name }))}\n className=\"w-full [&>button]:flex-1\"\n />\n ) : (\n <Select\n aria-label=\"Variant\"\n value={String(cur._variant ?? variants[0].id)}\n onValueChange={(v) => form.setAt([...frame.path, \"_variant\"], v)}\n options={variants.map((v) => ({ value: v.id, label: v.name, description: v.description }))}\n />\n )}\n </div>\n ) : null}\n <FieldList fields={frame.fields} fieldsets={frame.fieldsets} groups={frame.groups} basePath={frame.path} memoryKey={`f:${frame.kind}:${it?.block?.name ?? it?.itemSchema?.name ?? frame.field?.name ?? \"\"}`} />\n {it?.slotField?.slotSettings?.length && FieldSection ? (\n <FieldSection title={`Layout in ${it.slotField.title.toLowerCase()}`} description=\"How this block sits in its parent. The block's own content is above.\" collapsible={false}>\n <FieldList fields={it.slotField.slotSettings} basePath={[...frame.path, \"_settings\"]} memoryKey={`slotset:${it.slotField.name}`} />\n </FieldSection>\n ) : null}\n </div>\n );\n}\n\n/**\n * The context line under a drilled frame's title: \"Tier 1 of 3 in Tiers\" for an item (the item noun is the item\n * schema's title, which the adapter reads back from prod `ui.itemLabel`), \"Address in Author\" for an object.\n */\nexport function frameContext(frame: Frame, parentTitle?: string): string {\n const it = frame.item;\n if (it) {\n const noun = (frame.kind === \"block\" ? it.block?.title : it.itemSchema?.title) ?? \"Item\";\n const owner = (frame.kind === \"block\" ? it.slotField?.title : frame.field?.title) ?? \"the list\";\n return `${noun} ${it.index + 1} of ${it.count} in ${owner}`;\n }\n return parentTitle ? `${frame.field?.title ?? \"Group\"} in ${parentTitle}` : \"Group\";\n}\n\n/**\n * CPO D43 — the drilled frame's header answers \"what am I editing, and where does it live?\":\n * [media?] Starter [↑] [↓] [⋯]\n * Tier 1 of 3 in Tiers\n * The big title lives HERE only; the breadcrumb above is the path (its current crumb is small, D38). Prev / next are\n * labelled icon buttons whose tooltips name the sibling (\"Previous tier: Starter\"). No eyebrow, no duplicate counter.\n * Title 14/24 semibold (owner call). The native title= on the truncating h2 is V2 parity (kit-engine deviation from\n * the dashboard's no-title rule, see run ledger #32).\n */\nexport function FrameHeader({ frame, context, title }: { frame: Frame; context: string; title: string }) {\n const form = useForm()!;\n const { toast } = useKitServices();\n const it = frame.item;\n const media = it ? previewOf(it.block ?? it.itemSchema, form.getAt(frame.path), it.index).media : undefined;\n const step = (d: -1 | 1) => {\n if (!it) return;\n const n = it.index + d;\n if (n < 0 || n >= it.count) return;\n form.navigate([...it.arrayPath, n]);\n };\n const listRaw = it ? form.getAt(it.arrayPath) : undefined;\n const list = Array.isArray(listRaw) ? listRaw : [];\n const noun = (it?.block?.title ?? it?.itemSchema?.title ?? \"item\").toLowerCase();\n const sibling = (i: number) =>\n it && i >= 0 && i < it.count ? (it.titleAt ? it.titleAt(i) : previewOf(it.block ?? it.itemSchema, list[i], i, it.block?.title ?? it.itemSchema?.title).title) : \"\";\n const prev = it ? sibling(it.index - 1) : \"\";\n const next = it ? sibling(it.index + 1) : \"\";\n /* Duplicate / Remove move to another frame: the menu must not hand focus back to its trigger in the exiting frame\n (it unmounts, focus would drop to <body>); the stage focuses the entering frame instead */\n const moved = React.useRef(false);\n return (\n <div className=\"flex items-start gap-2.5 outline-none\" data-frame-header tabIndex={-1}>\n {media ? <Thumb media={media} size={36} /> : null}\n <div className=\"min-w-0 flex-1\">\n <h2 className=\"truncate text-kit-base font-semibold leading-6 text-kit-fg\" title={title}>\n {title}\n </h2>\n <p className=\"truncate text-kit-xs leading-4 text-kit-fg-3\">{context}</p>\n </div>\n {it ? (\n <div className=\"-mr-1 flex shrink-0 items-center gap-0.5 pt-0.5\">\n <IconButton\n label={prev ? `Previous ${noun}: ${prev}` : `No previous ${noun}`}\n tooltip={prev ? `Previous ${noun}: ${prev}` : `First ${noun}`}\n size=\"sm\"\n disabled={it.index === 0}\n onClick={() => step(-1)}\n >\n <IconArrowUp stroke={1.5} />\n </IconButton>\n <IconButton\n label={next ? `Next ${noun}: ${next}` : `No next ${noun}`}\n tooltip={next ? `Next ${noun}: ${next}` : `Last ${noun}`}\n size=\"sm\"\n disabled={it.index >= it.count - 1}\n onClick={() => step(1)}\n >\n <IconArrowDown stroke={1.5} />\n </IconButton>\n <Menu>\n <Tooltip content={`${title} actions`}>\n <MenuTrigger\n render={\n <IconButton label={`${title} actions`} tooltip={false} size=\"sm\">\n <IconDots stroke={1.5} />\n </IconButton>\n }\n />\n </Tooltip>\n <MenuContent align=\"end\" className=\"w-48\" finalFocus={() => !moved.current}>\n <MenuItem\n icon={<IconCopy stroke={1.5} />}\n onClick={() => {\n moved.current = true;\n const copy = isObj(list[it.index]) ? { ...(structuredClone(list[it.index]) as object), _key: newKey() } : list[it.index];\n form.setAt(it.arrayPath, [...list.slice(0, it.index + 1), copy, ...list.slice(it.index + 1)]);\n form.navigate([...it.arrayPath, it.index + 1]);\n toast?.success(\"Duplicated\", { description: \"You're now editing the copy.\" });\n }}\n >\n Duplicate\n </MenuItem>\n <MenuSeparator />\n <MenuItem\n danger\n icon={<IconTrash stroke={1.5} />}\n onClick={() => {\n moved.current = true;\n const prevList = list;\n form.navigate(parentFramePath(it.arrayPath));\n form.setAt(it.arrayPath, list.filter((_, j) => j !== it.index));\n toast?.(`“${title}” removed`, { action: { label: \"Undo\", onClick: () => form.setAt(it.arrayPath, prevList) }, duration: 10_000 });\n }}\n >\n Remove\n </MenuItem>\n </MenuContent>\n </Menu>\n </div>\n ) : null}\n </div>\n );\n}\n/** The frame that owns an array: drop the array field name (and the item index above it, if any). */\nconst parentFramePath = (arrayPath: FieldPath): FieldPath => arrayPath.slice(0, -1);\n\n/* ── Stage: direction-aware slide, scroll memory, focus, keys (V2 schema-form) ───────────────── */\n/** The title shown as `parentTitle` for the current frame (the root crumb's label for depth 1). */\nexport function parentTitleOf(frames: Frame[], rootLabel: string): string | undefined {\n if (frames.length < 2) return undefined;\n return frames.length === 2 ? rootLabel : frames[frames.length - 2].title;\n}\n\n/** Floating layers (Base UI popups carry these roles); keys and focus coming from one belong to that layer. */\nconst LAYER = \"[role=dialog],[role=menu],[role=listbox]\";\n\n/** Slide direction for a frame change: deeper → 1, shallower → −1, a sibling step → by index. */\nexport function frameDirection(prev: { depth: number; index: number; key: string }, frames: Frame[], key: string): 0 | 1 | -1 {\n if (prev.key === key) return 0;\n const cur = frames[frames.length - 1];\n if (frames.length > prev.depth) return 1;\n if (frames.length < prev.depth) return -1;\n return (cur.item?.index ?? 0) >= prev.index ? 1 : -1;\n}\n\n/**\n * The drill-in stack's behaviour. `root` wraps the form (keys bubble to it), `scroller` is the scrolling element (or\n * null when the host scrolls). Returns the current frame, its key, the slide direction and the form's onKeyDown.\n */\nexport function useFrameNavigation({\n frames,\n navigate,\n root,\n scroller,\n}: {\n frames: Frame[];\n navigate: (path: FieldPath) => void;\n root: React.RefObject<HTMLElement | null>;\n scroller: React.RefObject<HTMLElement | null>;\n}) {\n const current = frames[frames.length - 1];\n const frameKey = frameKeyOf(current.path);\n const prev = React.useRef({ depth: frames.length, index: current.item?.index ?? 0, key: frameKey });\n const dir = frameDirection(prev.current, frames, frameKey);\n const dirRef = React.useRef<number>(1);\n if (dir) dirRef.current = dir;\n\n const scrollMem = React.useRef(new Map<string, number>());\n React.useLayoutEffect(() => {\n const was = prev.current.key;\n if (was === frameKey) return;\n if (scroller.current) scrollMem.current.set(was, scroller.current.scrollTop);\n prev.current = { depth: frames.length, index: current.item?.index ?? 0, key: frameKey };\n const el = scroller.current;\n if (el) el.scrollTop = scrollMem.current.get(frameKey) ?? 0;\n const active = document.activeElement;\n /* a move started from a portalled menu (FrameHeader ⋯ → Duplicate / Remove) leaves focus in that layer, outside root */\n const layer = active && active !== document.body ? active.closest(LAYER) : null;\n const fromLayer = !!layer && !layer.contains(root.current);\n if (root.current && (active === document.body || root.current.contains(active) || fromLayer)) {\n // the exiting frame is still mounted during its exit animation — focus the ENTERING one\n const target = root.current.querySelector<HTMLElement>(`[data-frame-body=\"${CSS.escape(frameKey)}\"]`);\n target?.focus({ preventScroll: true });\n }\n });\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.defaultPrevented) return;\n const t = e.target as HTMLElement;\n // ignore keys from floating layers opened by this form; a form INSIDE a dialog still handles its own keys\n // (V2 also listed Radix's popper wrapper; Base UI popups carry these roles themselves)\n const layer = t.closest(LAYER);\n if (layer && root.current && !layer.contains(root.current)) return;\n if (e.key === \"Escape\" && frames.length > 1 && !t.isContentEditable) {\n e.preventDefault();\n e.stopPropagation();\n navigate(frames[frames.length - 2].path);\n return;\n }\n const it = current.item;\n if (it && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\")) {\n const typing = t.matches(\"input,textarea,select\") || t.isContentEditable;\n if (e.altKey || (!typing && t.matches(\"[data-frame-body],[data-frame-header]\"))) {\n const n = it.index + (e.key === \"ArrowUp\" ? -1 : 1);\n if (n >= 0 && n < it.count) {\n e.preventDefault();\n navigate([...it.arrayPath, n]);\n }\n }\n }\n };\n\n return { current, frameKey, dir: dirRef.current, onKeyDown };\n}\n\nconst EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\n\n/**\n * The frame body with V2's slide: 24px along the travel direction + fade, 220ms, ease [0.22, 1, 0.36, 1]; reduced\n * motion keeps only the fade. `before` renders inside the root frame above its fields (the synced-from note).\n */\nexport function FrameStage({\n frames,\n frameKey,\n dir,\n rootLabel,\n variant,\n before,\n review,\n}: {\n frames: Frame[];\n frameKey: string;\n dir: number;\n rootLabel: string;\n variant: \"panel\" | \"document\";\n before?: React.ReactNode;\n /** D61 Review changes is on: the clip leaves 16px on the left for the change bars */\n review?: boolean;\n}) {\n const reduce = useReducedMotion();\n const current = frames[frames.length - 1];\n return (\n // the drill slide is clipped sideways; with Review changes on (D61) the clip leaves 16px on the left for the change bars\n <div className=\"relative\" style={review ? { clipPath: \"inset(-100vh 0 -100vh -16px)\" } : { overflowX: \"clip\" }}>\n <AnimatePresence mode=\"popLayout\" initial={false} custom={dir}>\n <motion.div\n key={frameKey}\n custom={dir}\n variants={{\n enter: (d: number) => ({ x: reduce ? 0 : d * 24, opacity: 0 }),\n center: { x: 0, opacity: 1 },\n exit: (d: number) => ({ x: reduce ? 0 : d * -24, opacity: 0 }),\n }}\n initial=\"enter\"\n animate=\"center\"\n exit=\"exit\"\n transition={{ duration: 0.22, ease: EASE }}\n data-frame-body={frameKey}\n tabIndex={-1}\n className={cn(\"outline-none focus-visible:shadow-none\", variant === \"document\" ? \"py-1\" : \"px-4 py-4\")}\n >\n {current.kind === \"root\" ? before : null}\n <FrameView frame={current} parentTitle={parentTitleOf(frames, rootLabel)} />\n </motion.div>\n </AnimatePresence>\n </div>\n );\n}\n\nexport { HISTORY_SEGMENT };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAM,WAAW,MAAM,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,KAAK,KAAK,IAAI,GAAG,OAAO;KAC1B,EAAE,eAAe;KACjB,SAAS,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC;IAC/B;GACF;EACF;CACF;CAEA,OAAO;EAAE;EAAS;EAAU,KAAK,OAAO;EAAS;CAAU;AAC7D;AAEA,IAAM,OAAyC;CAAC;CAAM;CAAG;CAAM;AAAC;;;;;AAMhE,SAAgB,WAAW,EACzB,QACA,UACA,KACA,WACA,SACA,QACA,UAUC;CACD,MAAM,SAAS,iBAAiB;CAChC,MAAM,UAAU,OAAO,OAAO,SAAS;CACvC,OAEE,oBAAC,OAAD;EAAK,WAAU;EAAW,OAAO,SAAS,EAAE,UAAU,+BAA+B,IAAI,EAAE,WAAW,OAAO;EAC3G,UAAA,oBAAC,iBAAD;GAAiB,MAAK;GAAY,SAAS;GAAO,QAAQ;GACxD,UAAA,qBAAC,OAAO,KAAR;IAEE,QAAQ;IACR,UAAU;KACR,QAAQ,OAAe;MAAE,GAAG,SAAS,IAAI,IAAI;MAAI,SAAS;KAAE;KAC5D,QAAQ;MAAE,GAAG;MAAG,SAAS;KAAE;KAC3B,OAAO,OAAe;MAAE,GAAG,SAAS,IAAI,IAAI;MAAK,SAAS;KAAE;IAC9D;IACA,SAAQ;IACR,SAAQ;IACR,MAAK;IACL,YAAY;KAAE,UAAU;KAAM,MAAM;IAAK;IACzC,mBAAiB;IACjB,UAAU;IACV,WAAW,GAAG,0CAA0C,YAAY,aAAa,SAAS,WAAW;IAdvG,UAAA,CAgBG,QAAQ,SAAS,SAAS,SAAS,MACpC,oBAAC,WAAD;KAAW,OAAO;KAAS,aAAa,cAAc,QAAQ,SAAS;IAAI,CAAA,CACjE;GAjBL,GAAA,QAiBK;EACG,CAAA;CACd,CAAA;AAET"}
|
|
@@ -3,8 +3,7 @@ import { isEmptyValue, isHidden, plainText } from "../lib/schema.js";
|
|
|
3
3
|
import { resolveScale } from "../schema/scale.js";
|
|
4
4
|
//#region src/engine/group-summary.ts
|
|
5
5
|
/**
|
|
6
|
-
* groupSummary (V2
|
|
7
|
-
* until the grouping lane ports grouping.tsx, which then re-exports it from there.
|
|
6
|
+
* groupSummary (V2 kit/engine/grouping.tsx): what a collapsed group holds, in one line.
|
|
8
7
|
*/
|
|
9
8
|
/** "Top 56 · Bottom 88 · Sides M". Short values (numbers, scales, 1–4 letter options, on-switches) get their field's
|
|
10
9
|
* name in front so they mean something; text speaks for itself. Media, references and code are skipped, unless
|
|
@@ -19,6 +18,11 @@ function groupSummary(fields, value, max = 3) {
|
|
|
19
18
|
const x = value[f.name];
|
|
20
19
|
if (isEmptyValue(x)) continue;
|
|
21
20
|
switch (f.type) {
|
|
21
|
+
case "object": {
|
|
22
|
+
const inner = groupSummary(f.fields ?? [], x, max - parts.length);
|
|
23
|
+
if (inner) parts.push(inner);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
22
26
|
case "image":
|
|
23
27
|
case "file":
|
|
24
28
|
case "video":
|
|
@@ -27,7 +31,6 @@ function groupSummary(fields, value, max = 3) {
|
|
|
27
31
|
case "reference":
|
|
28
32
|
case "json":
|
|
29
33
|
case "code":
|
|
30
|
-
case "object":
|
|
31
34
|
case "slot":
|
|
32
35
|
case "geopoint": continue;
|
|
33
36
|
case "boolean":
|
|
@@ -35,7 +38,7 @@ function groupSummary(fields, value, max = 3) {
|
|
|
35
38
|
continue;
|
|
36
39
|
case "number": {
|
|
37
40
|
const label = f.scale ? resolveScale(f.scale, x).label : `${x}${f.numeric?.unit ? ` ${f.numeric.unit}` : ""}`;
|
|
38
|
-
parts.push(`${f.title} ${label}`);
|
|
41
|
+
parts.push(f.numeric?.unit?.startsWith("/") ? label : `${f.title} ${label}`);
|
|
39
42
|
continue;
|
|
40
43
|
}
|
|
41
44
|
case "rating":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-summary.js","names":[],"sources":["../../src/engine/group-summary.ts"],"sourcesContent":["/**\n * groupSummary (V2
|
|
1
|
+
{"version":3,"file":"group-summary.js","names":[],"sources":["../../src/engine/group-summary.ts"],"sourcesContent":["/**\n * groupSummary (V2 kit/engine/grouping.tsx): what a collapsed group holds, in one line.\n */\nimport { isHidden, isEmptyValue, plainText } from \"../lib/schema\";\nimport { isObj } from \"../lib/path\";\nimport { resolveScale } from \"../schema/scale\";\nimport type { FieldSchema } from \"../schema/types\";\n\n/** \"Top 56 · Bottom 88 · Sides M\". Short values (numbers, scales, 1–4 letter options, on-switches) get their field's\n * name in front so they mean something; text speaks for itself. Media, references and code are skipped, unless\n * nothing else is set: a group of set icons then reads as their names, never as \"Nothing set yet\". */\nexport function groupSummary(fields: FieldSchema[], value: unknown, max = 3): string {\n if (!isObj(value)) return \"\";\n const parts: string[] = [];\n const media: string[] = [];\n for (const f of fields) {\n if (parts.length >= max) break;\n if (isHidden(f, value)) continue;\n const x = value[f.name];\n if (isEmptyValue(x)) continue;\n switch (f.type) {\n case \"object\": {\n /* an inline object speaks through its own fields (\"4.9 / 5 · 4.9 from 2,400+ reviews\"), never \"Nothing set yet\" */\n const inner = groupSummary(f.fields ?? [], x, max - parts.length);\n if (inner) parts.push(inner);\n continue;\n }\n case \"image\": case \"file\": case \"video\":\n media.push(f.title);\n continue;\n case \"reference\": case \"json\": case \"code\": case \"slot\": case \"geopoint\":\n continue;\n case \"boolean\":\n if (x === true) parts.push(f.title);\n continue;\n case \"number\": {\n const label = f.scale ? resolveScale(f.scale, x).label : `${x}${f.numeric?.unit ? ` ${f.numeric.unit}` : \"\"}`;\n parts.push(f.numeric?.unit?.startsWith(\"/\") ? label : `${f.title} ${label}`); // \"4.9 / 5\" says what it is\n continue;\n }\n case \"rating\":\n parts.push(`${f.title} ${x} / 5`);\n continue;\n case \"select\": {\n const label = f.options?.find((o) => o.value === x)?.label ?? String(x);\n parts.push(label.length <= 4 ? `${f.title} ${label}` : label);\n continue;\n }\n case \"multiselect\": case \"tags\":\n if (Array.isArray(x)) parts.push(x.length <= 2 ? x.map((v) => f.options?.find((o) => o.value === v)?.label ?? String(v)).join(\", \") : `${x.length} ${f.title.toLowerCase()}`);\n continue;\n case \"array\":\n if (Array.isArray(x)) parts.push(`${x.length} ${f.title.toLowerCase()}`);\n continue;\n case \"color\":\n parts.push(`${f.title} ${String(x)}`);\n continue;\n default: {\n const t = plainText(x);\n if (t) parts.push(t.length > 32 ? `${t.slice(0, 30)}…` : t);\n }\n }\n }\n return (parts.length ? parts : media.slice(0, max)).join(\" · \");\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,aAAa,QAAuB,OAAgB,MAAM,GAAW;CACnF,IAAI,CAAC,MAAM,KAAK,GAAG,OAAO;CAC1B,MAAM,QAAkB,CAAC;CACzB,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,KAAK,QAAQ;EACtB,IAAI,MAAM,UAAU,KAAK;EACzB,IAAI,SAAS,GAAG,KAAK,GAAG;EACxB,MAAM,IAAI,MAAM,EAAE;EAClB,IAAI,aAAa,CAAC,GAAG;EACrB,QAAQ,EAAE,MAAV;GACE,KAAK,UAAU;IAEb,MAAM,QAAQ,aAAa,EAAE,UAAU,CAAC,GAAG,GAAG,MAAM,MAAM,MAAM;IAChE,IAAI,OAAO,MAAM,KAAK,KAAK;IAC3B;GACF;GACA,KAAK;GAAS,KAAK;GAAQ,KAAK;IAC9B,MAAM,KAAK,EAAE,KAAK;IAClB;GACF,KAAK;GAAa,KAAK;GAAQ,KAAK;GAAQ,KAAK;GAAQ,KAAK,YAC5D;GACF,KAAK;IACH,IAAI,MAAM,MAAM,MAAM,KAAK,EAAE,KAAK;IAClC;GACF,KAAK,UAAU;IACb,MAAM,QAAQ,EAAE,QAAQ,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,EAAE,SAAS,OAAO,IAAI,EAAE,QAAQ,SAAS;IACzG,MAAM,KAAK,EAAE,SAAS,MAAM,WAAW,GAAG,IAAI,QAAQ,GAAG,EAAE,MAAM,GAAG,OAAO;IAC3E;GACF;GACA,KAAK;IACH,MAAM,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE,KAAK;IAChC;GACF,KAAK,UAAU;IACb,MAAM,QAAQ,EAAE,SAAS,MAAM,MAAM,EAAE,UAAU,CAAC,CAAC,EAAE,SAAS,OAAO,CAAC;IACtE,MAAM,KAAK,MAAM,UAAU,IAAI,GAAG,EAAE,MAAM,GAAG,UAAU,KAAK;IAC5D;GACF;GACA,KAAK;GAAe,KAAK;IACvB,IAAI,MAAM,QAAQ,CAAC,GAAG,MAAM,KAAK,EAAE,UAAU,IAAI,EAAE,KAAK,MAAM,EAAE,SAAS,MAAM,MAAM,EAAE,UAAU,CAAC,CAAC,EAAE,SAAS,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,GAAG,EAAE,OAAO,GAAG,EAAE,MAAM,YAAY,GAAG;IAC5K;GACF,KAAK;IACH,IAAI,MAAM,QAAQ,CAAC,GAAG,MAAM,KAAK,GAAG,EAAE,OAAO,GAAG,EAAE,MAAM,YAAY,GAAG;IACvE;GACF,KAAK;IACH,MAAM,KAAK,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IACpC;GACF,SAAS;IACP,MAAM,IAAI,UAAU,CAAC;IACrB,IAAI,GAAG,MAAM,KAAK,EAAE,SAAS,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,CAAC;GAC5D;EACF;CACF;CACA,QAAQ,MAAM,SAAS,QAAQ,MAAM,MAAM,GAAG,GAAG,EAAA,CAAG,KAAK,KAAK;AAChE"}
|
package/dist/engine/grouping.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { isObj, keyStartsWith, pathKey } from "../lib/path.js";
|
|
2
|
+
import { condCtx, isEmptyValue, isHidden } from "../lib/schema.js";
|
|
1
3
|
import { cn } from "../lib/cn.js";
|
|
2
4
|
import { KitSectionTitle, useForm, useKitEnv } from "../context.js";
|
|
3
|
-
import { isObj, keyStartsWith, pathKey } from "../lib/path.js";
|
|
4
5
|
import { KitIcon } from "../lib/icons.js";
|
|
5
6
|
import { Segmented } from "../ui/controls.js";
|
|
6
7
|
import { Menu, MenuContent, MenuItem, MenuTrigger, Tooltip } from "../ui/overlay.js";
|
|
7
|
-
import { condCtx, isEmptyValue, isHidden } from "../lib/schema.js";
|
|
8
8
|
import { IssueDot } from "./bits.js";
|
|
9
9
|
import { PeerStack } from "./field-shell.js";
|
|
10
10
|
import { groupSummary } from "./group-summary.js";
|
package/dist/engine/item-list.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { newKey, pathKey } from "../lib/path.js";
|
|
2
|
+
import { itemNoun } from "../lib/schema.js";
|
|
1
3
|
import { cn } from "../lib/cn.js";
|
|
2
4
|
import { useForm, useKitServices } from "../context.js";
|
|
3
|
-
import { newKey, pathKey } from "../lib/path.js";
|
|
4
5
|
import { Button } from "../ui/button.js";
|
|
5
6
|
import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from "../ui/overlay.js";
|
|
6
|
-
import { itemNoun } from "../lib/schema.js";
|
|
7
7
|
import { Textarea } from "../ui/input.js";
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
package/dist/engine/kit-field.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { isObj, pathKey } from "../lib/path.js";
|
|
2
|
+
import { condCtx, isHidden, objectOpenMode, plainText, summarize } from "../lib/schema.js";
|
|
1
3
|
import { cn } from "../lib/cn.js";
|
|
2
4
|
import { resolveFieldAccess, useForm, useKitEnv, useKitServices } from "../context.js";
|
|
3
|
-
import { isObj, pathKey } from "../lib/path.js";
|
|
4
5
|
import { KitIcon } from "../lib/icons.js";
|
|
5
6
|
import { Button } from "../ui/button.js";
|
|
6
7
|
import { Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, Popover, PopoverContent, PopoverTrigger } from "../ui/overlay.js";
|
|
7
|
-
import { condCtx, isHidden, objectOpenMode, plainText, summarize } from "../lib/schema.js";
|
|
8
8
|
import { IssueDot, RowChrome } from "./bits.js";
|
|
9
9
|
import { resolveHelp } from "../schema/help.js";
|
|
10
10
|
import { FieldShell } from "./field-shell.js";
|
|
@@ -335,11 +335,7 @@ function ObjectField({ field, path }) {
|
|
|
335
335
|
children: [
|
|
336
336
|
/* @__PURE__ */ jsx(ModalHeader, {
|
|
337
337
|
title: field.title,
|
|
338
|
-
description: field.description
|
|
339
|
-
icon: /* @__PURE__ */ jsx(KitIcon, {
|
|
340
|
-
name: field.icon,
|
|
341
|
-
fallback: "folder"
|
|
342
|
-
})
|
|
338
|
+
description: field.description
|
|
343
339
|
}),
|
|
344
340
|
/* @__PURE__ */ jsx(ModalBody, {
|
|
345
341
|
className: "flex min-h-[320px] flex-col gap-5",
|
|
@@ -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\";\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\nexport function KitField({ field, path, parent }: KitFieldProps) {\n const form = useForm();\n const env = useKitEnv();\n const id = React.useId();\n const { readOnly } = useFieldAccess(field);\n if (!form) return null;\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 bg-kit-control-bg py-1.5 pl-2 pr-2 text-left transition-colors hover:border-kit-line-strong 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} icon={<KitIcon name={field.icon} fallback=\"folder\" />} />\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 <p id={id} tabIndex={0} 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 host with no legacy\n * service, or a control that throws while rendering, says why in words; the form around it keeps working.\n */\nexport function LegacyFallback(props: ControlProps) {\n const { LegacyControl } = useKitServices();\n const { field, id } = props;\n return (\n <div data-kit-legacy={field.type} className=\"min-w-0\">\n {LegacyControl ? (\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 ) : (\n <LegacyRefusal id={id}>This view has no control for {field.type} fields.</LegacyRefusal>\n )}\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,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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,OACE,oBAAC,OAAD;EAAK,mBAAiB,MAAM;EAAM,WAAU;EACzC,UAAA,gBAGC,oBAAC,gBAAD;GAAmD;GAAW;GAAI,OAAO,MAAM;GAC7E,UAAA,oBAAC,eAAD,EAAe,GAAI,MAAQ,CAAA;EACb,GAFK,KAAK,UAAU,KAAK,CAEzB,IAEhB,qBAAC,eAAD;GAAmB;GAAnB,UAAA;IAAuB;IAA8B,MAAM;IAAK;GAAuB;;CAEtF,CAAA;AAET;;;;;AAMA,SAAS,cAAc,EAAE,IAAI,YAAuD;CAClF,OACE,oBAAC,UAAD;EACM;EACJ,MAAK;EACL,UAAU;EACV,aAAU;EACV,WAAU;EAET;CACK,CAAA;AAEZ;;AAGA,IAAM,iBAAN,cAA6B,MAAM,UAAoH;CACrJ,QAAQ,EAAE,QAAQ,KAAsB;CACxC,OAAO,yBAAyB,OAAgB;EAC9C,OAAO,EAAE,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE;CAC1E;CACA,mBAAmB,MAA8C;EAC/D,IAAI,KAAK,MAAM,WAAW,MAAM;EAEhC,IAAI,KAAK,UAAU,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,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\";\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\nexport function KitField({ field, path, parent }: KitFieldProps) {\n const form = useForm();\n const env = useKitEnv();\n const id = React.useId();\n const { readOnly } = useFieldAccess(field);\n if (!form) return null;\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 bg-kit-control-bg py-1.5 pl-2 pr-2 text-left transition-colors hover:border-kit-line-strong 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 <p id={id} tabIndex={0} 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 host with no legacy\n * service, or a control that throws while rendering, says why in words; the form around it keeps working.\n */\nexport function LegacyFallback(props: ControlProps) {\n const { LegacyControl } = useKitServices();\n const { field, id } = props;\n return (\n <div data-kit-legacy={field.type} className=\"min-w-0\">\n {LegacyControl ? (\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 ) : (\n <LegacyRefusal id={id}>This view has no control for {field.type} fields.</LegacyRefusal>\n )}\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,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,CAAC,MAAM,SAAS,MAAM,WAAW,YAAY,MAAM,SAAS,MAAM;EAGpG,MAAM,EAAE,KAAK,KAAK,SAAS,MAAM;EAEjC,WADa,KAAK,WAAW,GAAG,KAAM,OAAO,QAAQ,KAAK,SAAS,OAAO,GAAG,CAAC,KAC1D,OAAO,QAAQ,OAAO,OAAQ,KAAK,OAAO,QAAQ,OAAO,OAAO,WAAW,IAAI,OAAO,IAAI,GAAG,KAAK,KAAK,OAAO,OAAO,GAAG,IAAI,GAAG,KAAK,aAAa,SAAS,IAAI,GAAG,KAAK;CAC5L,OAAO,IAAI,MAAM,SAAS,YAAY,CAAC,MAAM,SAAS,MAAM,WAAW,aAAa,MAAM,SAAS,OAAO,QAAQ,MAAM,SAAS,OAAO,OAAO;EAC7I,MAAM,EAAE,KAAK,QAAQ,MAAM,WAAW,CAAC;EACvC,WAAW,OAAO,QAAQ,OAAO,OAAO,WAAW,IAAI,OAAO,IAAI,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AAE,QAAQ,KAAK,CAAC;CACxI;CACA,SAAS;EACP,IAAI,KAAK,MAAM,WAAW,MAAM,OAAO,KAAK,MAAM;EAClD,OACE,qBAAC,eAAD;GAAe,IAAI,KAAK,MAAM;GAA9B,UAAA;IAAkC;IAC3B,KAAK,MAAM,MAAM;IAAM;IAA0B,KAAK,MAAM;GACpD;;CAEnB;AACF"}
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* dark host scope is never reset to light inside it.
|
|
14
14
|
*/
|
|
15
15
|
import * as React from "react";
|
|
16
|
-
import type { FieldPath, FieldSchema, TypeSchema } from "../schema/types";
|
|
16
|
+
import type { Condition, FieldPath, FieldSchema, TypeSchema } from "../schema/types";
|
|
17
17
|
import { type KitEnv, type KitPeer, type Swatch } from "../context";
|
|
18
|
-
import { type KitIssue } from "../lib/validate";
|
|
18
|
+
import { type KitIssue, type UniquePeers } from "../lib/validate";
|
|
19
19
|
import { type KitCrumb } from "./breadcrumb";
|
|
20
20
|
export interface SchemaFormProps {
|
|
21
21
|
schema: TypeSchema;
|
|
@@ -52,6 +52,8 @@ export interface SchemaFormProps {
|
|
|
52
52
|
onOpenReference?: KitEnv["onOpenReference"];
|
|
53
53
|
/** D61: the host's Review changes markers (while its History panel is open) */
|
|
54
54
|
review?: KitEnv["review"];
|
|
55
|
+
/** D61 field ⋯ › History: the host opens its History panel on this field (see `KitEnv.onFieldHistory`). Keep it stable. */
|
|
56
|
+
onFieldHistory?: KitEnv["onFieldHistory"];
|
|
55
57
|
/** the whole form is read-only for the lens (fields with their own `access.edit` still follow `env.can`) */
|
|
56
58
|
readOnly?: boolean;
|
|
57
59
|
/** validate everything now (after a publish attempt) */
|
|
@@ -82,15 +84,18 @@ export interface SchemaFormProps {
|
|
|
82
84
|
* path the form already flags is dropped; `live` ones show while typing; `fix` adds one action after the message.
|
|
83
85
|
*/
|
|
84
86
|
extraIssues?: KitIssue[];
|
|
87
|
+
/** Root fields with `validation.unique`: the values the model's other records hold (V2). Absent: not checked. Keep it stable. */
|
|
88
|
+
uniquePeers?: UniquePeers;
|
|
85
89
|
/** The host's access check (V2 `KitEnv.can`), the same as `env.can`; `env.can` wins when both are set. */
|
|
86
90
|
can?: KitEnv["can"];
|
|
87
91
|
/**
|
|
88
92
|
* D70 (V2 `KitEnv.hiddenLine`): keep the fields that would leave the form in place as the host's line instead. `why`
|
|
89
|
-
* says what hid it: "rule" (its condition doesn't hold for the current value) or "access" (the lens can't `view` it)
|
|
93
|
+
* says what hid it: "rule" (its condition doesn't hold for the current value) or "access" (the lens can't `view` it);
|
|
94
|
+
* `failed` holds the rules that don't hold ("Badge is not Sale"), [] for access.
|
|
90
95
|
* The schema preview draws its dashed "Hidden for Editor" / "Hidden: …" lines with it. Absent: hidden fields leave the
|
|
91
96
|
* form, as in every editor. Keep it stable (a new function re-renders the form).
|
|
92
97
|
*/
|
|
93
|
-
hiddenLine?: (field: FieldSchema, path: FieldPath, why: HiddenWhy) => React.ReactNode;
|
|
98
|
+
hiddenLine?: (field: FieldSchema, path: FieldPath, why: HiddenWhy, failed: Condition[]) => React.ReactNode;
|
|
94
99
|
/** own scroll container (default: panel yes, document no) */
|
|
95
100
|
scroll?: boolean;
|
|
96
101
|
/** rendered above the breadcrumb (e.g. a block header) */
|
|
@@ -113,4 +118,4 @@ export interface SchemaFormProps {
|
|
|
113
118
|
export declare const COALESCE_MS = 900;
|
|
114
119
|
export declare const UNDO_STEPS = 50;
|
|
115
120
|
export type HiddenWhy = "rule" | "access";
|
|
116
|
-
export declare function SchemaForm({ schema: schemaIn, value, onChange, path: controlledPath, defaultPath, onPathChange, variant, resolveSchema: resolveIn, blockLibrary, published, inherited, presence, comments, onComment, onOpenReference, review, readOnly, showErrors, env: envIn, scroll, header, rootLabel, onCrumbs, onIssuesChange, navRef, className, can: canIn, hiddenLine, extraIssues, }: SchemaFormProps): import("react/jsx-runtime").JSX.Element;
|
|
121
|
+
export declare function SchemaForm({ schema: schemaIn, value, onChange, path: controlledPath, defaultPath, onPathChange, variant, resolveSchema: resolveIn, blockLibrary, published, inherited, presence, comments, onComment, onOpenReference, review, onFieldHistory, readOnly, showErrors, env: envIn, scroll, header, rootLabel, onCrumbs, onIssuesChange, navRef, className, can: canIn, hiddenLine, extraIssues, uniquePeers, }: SchemaFormProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { getIn, isObj, keyStartsWith, pathEq, pathKey, same, setIn } from "../lib/path.js";
|
|
2
|
+
import { condCtx, failingRules, isHidden } from "../lib/schema.js";
|
|
1
3
|
import { cn } from "../lib/cn.js";
|
|
2
4
|
import { DEFAULT_ENV, FormProvider, KitEnvProvider, fieldAccessOf, useForm, useKitEnv, visibleSchema } from "../context.js";
|
|
3
|
-
import { getIn, isObj, keyStartsWith, pathEq, pathKey, same, setIn } from "../lib/path.js";
|
|
4
|
-
import { condCtx, isHidden } from "../lib/schema.js";
|
|
5
5
|
import { collectIssues } from "../lib/validate.js";
|
|
6
6
|
import { FieldList, FieldSection } from "./grouping.js";
|
|
7
7
|
import { ButtonScreen } from "../controls/button.js";
|
|
@@ -98,7 +98,7 @@ function liveSchema(schema) {
|
|
|
98
98
|
var GHOST = "__ghost";
|
|
99
99
|
var HiddenLineCtx = React.createContext(void 0);
|
|
100
100
|
/** A stand-in that keeps a hidden field's place: no value rules, no condition, nothing to validate or drill into. */
|
|
101
|
-
function ghostOf(f, why) {
|
|
101
|
+
function ghostOf(f, why, failed = []) {
|
|
102
102
|
return {
|
|
103
103
|
name: f.name,
|
|
104
104
|
title: f.title,
|
|
@@ -108,7 +108,8 @@ function ghostOf(f, why) {
|
|
|
108
108
|
readOnly: true,
|
|
109
109
|
[GHOST]: {
|
|
110
110
|
why,
|
|
111
|
-
field: f
|
|
111
|
+
field: f,
|
|
112
|
+
failed
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
115
|
}
|
|
@@ -134,7 +135,7 @@ function GhostFieldList(props) {
|
|
|
134
135
|
const raw = form.getAt(props.basePath);
|
|
135
136
|
const parent = isObj(raw) ? raw : {};
|
|
136
137
|
const cc = condCtx(form, props.basePath);
|
|
137
|
-
const fields = props.fields.map((f) => f[GHOST] || f.hidden === true || !isHidden(f, parent, cc) ? f : ghostOf(f, "rule"));
|
|
138
|
+
const fields = props.fields.map((f) => f[GHOST] || f.hidden === true || !isHidden(f, parent, cc) ? f : ghostOf(f, "rule", failingRules(f, parent, cc)));
|
|
138
139
|
return /* @__PURE__ */ jsx(FieldList, {
|
|
139
140
|
...props,
|
|
140
141
|
fields,
|
|
@@ -143,7 +144,7 @@ function GhostFieldList(props) {
|
|
|
143
144
|
return g ? /* @__PURE__ */ jsx("div", {
|
|
144
145
|
"data-field-key": pathKey(path),
|
|
145
146
|
"data-ghost": g.why,
|
|
146
|
-
children: line(g.field, path, g.why)
|
|
147
|
+
children: line(g.field, path, g.why, g.failed)
|
|
147
148
|
}) : /* @__PURE__ */ jsx(KitField, {
|
|
148
149
|
field: f,
|
|
149
150
|
path,
|
|
@@ -167,7 +168,7 @@ var GHOST_SLOTS = {
|
|
|
167
168
|
},
|
|
168
169
|
normLink: buttonLabel
|
|
169
170
|
};
|
|
170
|
-
function SchemaForm({ schema: schemaIn, value, onChange, path: controlledPath, defaultPath, onPathChange, variant = "panel", resolveSchema: resolveIn, blockLibrary, published, inherited, presence, comments, onComment, onOpenReference, review, readOnly, showErrors = false, env: envIn, scroll, header, rootLabel, onCrumbs, onIssuesChange, navRef, className, can: canIn, hiddenLine, extraIssues }) {
|
|
171
|
+
function SchemaForm({ schema: schemaIn, value, onChange, path: controlledPath, defaultPath, onPathChange, variant = "panel", resolveSchema: resolveIn, blockLibrary, published, inherited, presence, comments, onComment, onOpenReference, review, onFieldHistory, readOnly, showErrors = false, env: envIn, scroll, header, rootLabel, onCrumbs, onIssuesChange, navRef, className, can: canIn, hiddenLine, extraIssues, uniquePeers }) {
|
|
171
172
|
const outerCan = useKitEnv().can;
|
|
172
173
|
const can = envIn?.can ?? canIn ?? outerCan;
|
|
173
174
|
const schema = React.useMemo(() => {
|
|
@@ -256,13 +257,18 @@ function SchemaForm({ schema: schemaIn, value, onChange, path: controlledPath, d
|
|
|
256
257
|
onChange(next);
|
|
257
258
|
}, [onChange]);
|
|
258
259
|
const issueList = React.useMemo(() => {
|
|
259
|
-
const
|
|
260
|
+
const variant = typeof value._variant === "string" ? value._variant : schema.variants?.[0]?.id;
|
|
261
|
+
const own = collectIssues(schema.fields, value, [], resolveSchema, [], {
|
|
262
|
+
root: value,
|
|
263
|
+
variant
|
|
264
|
+
}, uniquePeers);
|
|
260
265
|
return extraIssues?.length ? [...own, ...extraIssues.filter((x) => !own.some((o) => o.key === x.key))] : own;
|
|
261
266
|
}, [
|
|
262
267
|
schema,
|
|
263
268
|
value,
|
|
264
269
|
resolveSchema,
|
|
265
|
-
extraIssues
|
|
270
|
+
extraIssues,
|
|
271
|
+
uniquePeers
|
|
266
272
|
]);
|
|
267
273
|
const issues = React.useMemo(() => new Map(issueList.map((i) => [i.key, i])), [issueList]);
|
|
268
274
|
React.useEffect(() => onIssuesChange?.(issueList), [issueList, onIssuesChange]);
|
|
@@ -350,6 +356,7 @@ function SchemaForm({ schema: schemaIn, value, onChange, path: controlledPath, d
|
|
|
350
356
|
syncedFrom: envIn?.syncedFrom,
|
|
351
357
|
helpDisplay: envIn?.helpDisplay,
|
|
352
358
|
review,
|
|
359
|
+
onFieldHistory,
|
|
353
360
|
fieldChrome: envIn?.fieldChrome,
|
|
354
361
|
controls: envIn?.controls,
|
|
355
362
|
sectionSummary: envIn?.sectionSummary
|
|
@@ -373,7 +380,8 @@ function SchemaForm({ schema: schemaIn, value, onChange, path: controlledPath, d
|
|
|
373
380
|
comments,
|
|
374
381
|
onComment,
|
|
375
382
|
onOpenReference,
|
|
376
|
-
review
|
|
383
|
+
review,
|
|
384
|
+
onFieldHistory
|
|
377
385
|
]);
|
|
378
386
|
React.useImperativeHandle(navRef, () => ({ back: () => {
|
|
379
387
|
if (frames.length < 2) return false;
|