@bettercms-ai/kit 3.1.31 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context.d.ts +9 -4
- package/dist/context.js.map +1 -1
- package/dist/controls/rich-text/blocks.js +1 -1
- package/dist/controls/rich-text/codec.d.ts +2 -2
- package/dist/controls/rich-text/codec.js.map +1 -1
- package/dist/controls/rich-text/control.d.ts +3 -2
- package/dist/controls/rich-text/control.js +25 -30
- package/dist/controls/rich-text/control.js.map +1 -1
- package/dist/controls/rich-text/editor.js +1 -1
- package/dist/engine/expand.d.ts +1 -1
- package/dist/engine/expand.js +1 -1
- package/dist/engine/expand.js.map +1 -1
- package/dist/engine/frame.js +1 -1
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/held.d.ts +82 -0
- package/dist/engine/held.js +190 -0
- package/dist/engine/held.js.map +1 -0
- package/dist/engine/kit-field.d.ts +5 -9
- package/dist/engine/kit-field.js +27 -67
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/schema/types.d.ts +9 -0
- package/dist/schema/types.js.map +1 -1
- package/dist/styles.css +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 { 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, itemSchemaFor, 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 /* NEW-Q49-POLYSIBLING: in a mixed list a neighbour is named and previewed by its OWN type, not the current item's\n (a photo post's URL read as \"Next store review: https://…\") */\n const schemaAt = (i: number) => {\n const v = list[i];\n if (frame.kind === \"item\" && frame.field) return itemSchemaFor(frame.field, v) ?? it?.itemSchema;\n if (frame.kind === \"block\") return (isObj(v) && typeof v._type === \"string\" ? form.resolveSchema?.(v._type) : undefined) ?? it?.block;\n return it?.block ?? it?.itemSchema;\n };\n const nounAt = (i: number) => (it?.titleAt ? noun : (schemaAt(i)?.title ?? \"item\").toLowerCase());\n const sibling = (i: number) =>\n it && i >= 0 && i < it.count ? (it.titleAt ? it.titleAt(i) : previewOf(schemaAt(i), list[i], i, schemaAt(i)?.title).title) : \"\";\n const prev = it ? sibling(it.index - 1) : \"\";\n const next = it ? sibling(it.index + 1) : \"\";\n const prevNoun = it ? nounAt(it.index - 1) : noun;\n const nextNoun = it ? nounAt(it.index + 1) : noun;\n /* NEW-Q22-ROWLIMIT: the list's own bounds hold here as on its row menu (array.tsx): a duplicate past the maximum or a\n remove below the minimum only left a held, unsavable list */\n const bounds = frame.kind === \"item\" || frame.kind === \"block\" ? frame.field?.validation : undefined;\n const atMax = bounds?.max != null && list.length >= bounds.max;\n const atMin = bounds?.min != null && list.length <= bounds.min;\n /* NEW-Q48-ITEMACTIONS: a read-only list (a locked section, a viewer) offers no Duplicate / Remove: the host drops the\n write, so the menu only announced a change that never happened */\n const env = useKitEnv();\n const readOnly = frame.field ? resolveFieldAccess(frame.field, env).readOnly : !!env.readOnly;\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 ${prevNoun}: ${prev}` : `No previous ${noun}`}\n tooltip={prev ? `Previous ${prevNoun}: ${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 ${nextNoun}: ${next}` : `No next ${noun}`}\n tooltip={next ? `Next ${nextNoun}: ${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 {readOnly ? null : (\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 disabled={atMax}\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 {atMax ? \"Duplicate · limit reached\" : \"Duplicate\"}\n </MenuItem>\n <MenuSeparator />\n <MenuItem\n danger\n icon={<IconTrash stroke={1.5} />}\n disabled={atMin}\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 {atMin ? `Remove · at least ${bounds?.min} required` : \"Remove\"}\n </MenuItem>\n </MenuContent>\n </Menu>\n )}\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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U;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"}
|
|
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, itemSchemaFor, 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-note=\"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 /* NEW-Q49-POLYSIBLING: in a mixed list a neighbour is named and previewed by its OWN type, not the current item's\n (a photo post's URL read as \"Next store review: https://…\") */\n const schemaAt = (i: number) => {\n const v = list[i];\n if (frame.kind === \"item\" && frame.field) return itemSchemaFor(frame.field, v) ?? it?.itemSchema;\n if (frame.kind === \"block\") return (isObj(v) && typeof v._type === \"string\" ? form.resolveSchema?.(v._type) : undefined) ?? it?.block;\n return it?.block ?? it?.itemSchema;\n };\n const nounAt = (i: number) => (it?.titleAt ? noun : (schemaAt(i)?.title ?? \"item\").toLowerCase());\n const sibling = (i: number) =>\n it && i >= 0 && i < it.count ? (it.titleAt ? it.titleAt(i) : previewOf(schemaAt(i), list[i], i, schemaAt(i)?.title).title) : \"\";\n const prev = it ? sibling(it.index - 1) : \"\";\n const next = it ? sibling(it.index + 1) : \"\";\n const prevNoun = it ? nounAt(it.index - 1) : noun;\n const nextNoun = it ? nounAt(it.index + 1) : noun;\n /* NEW-Q22-ROWLIMIT: the list's own bounds hold here as on its row menu (array.tsx): a duplicate past the maximum or a\n remove below the minimum only left a held, unsavable list */\n const bounds = frame.kind === \"item\" || frame.kind === \"block\" ? frame.field?.validation : undefined;\n const atMax = bounds?.max != null && list.length >= bounds.max;\n const atMin = bounds?.min != null && list.length <= bounds.min;\n /* NEW-Q48-ITEMACTIONS: a read-only list (a locked section, a viewer) offers no Duplicate / Remove: the host drops the\n write, so the menu only announced a change that never happened */\n const env = useKitEnv();\n const readOnly = frame.field ? resolveFieldAccess(frame.field, env).readOnly : !!env.readOnly;\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 ${prevNoun}: ${prev}` : `No previous ${noun}`}\n tooltip={prev ? `Previous ${prevNoun}: ${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 ${nextNoun}: ${next}` : `No next ${noun}`}\n tooltip={next ? `Next ${nextNoun}: ${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 {readOnly ? null : (\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 disabled={atMax}\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 {atMax ? \"Duplicate · limit reached\" : \"Duplicate\"}\n </MenuItem>\n <MenuSeparator />\n <MenuItem\n danger\n icon={<IconTrash stroke={1.5} />}\n disabled={atMin}\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 {atMin ? `Remove · at least ${bounds?.min} required` : \"Remove\"}\n </MenuItem>\n </MenuContent>\n </Menu>\n )}\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,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,CAAA;EAC/D,GAFK,EAAE,IAEP,CACN,GACA,MAAM,WAAW,IAAI,oBAAC,KAAD;GAAG,WAAU;GAA6C,UAAA;EAAsB,CAAA,IAAI,IACvG;;AAET;;AAGA,SAAS,gBAAgB,EAAE,SAA2B;CACpD,MAAM,OAAO,QAAQ;CACrB,MAAM,KAAK,MAAM,MAAM;CACvB,MAAM,QAAQ,MAAM,SAAS;EAAE,MAAM,OAAO,MAAM,KAAK,GAAG,EAAE,KAAK,QAAQ;EAAG,OAAO,MAAM;EAAO,MAAM;CAAkB;CACxH,OAAO,oBAAC,iBAAD;EAAwB;EAAO,OAAO,KAAK,MAAM,MAAM,IAAI;EAAG,WA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AAC,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"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HELD fields and the kit's error surfaces (kit 3.2.0).
|
|
3
|
+
*
|
|
4
|
+
* A held field is one the form cannot edit without changing what is stored: it renders read-only inside the usual
|
|
5
|
+
* FieldShell (label, help), shows the stored value as faithfully as the kit can (rich text as its HTML, scalars as text,
|
|
6
|
+
* objects and lists as a short readable summary), names why in one line, and never writes. Kit 4.0.0 removed the
|
|
7
|
+
* host-control hand-off it replaced.
|
|
8
|
+
*
|
|
9
|
+
* - `FieldSchema.held` / `KitServices.heldReason`: the host holds a field (KitField checks both before anything else)
|
|
10
|
+
* - a control that refuses a value (rich text the codec cannot carry) draws `HeldValue` in its place
|
|
11
|
+
* - a control that throws while rendering: `FieldBoundary` holds that one field; the rest of the form keeps working
|
|
12
|
+
* - a whole form that throws: the host draws `KitErrorCard` (reason, "Nothing was changed.", Retry)
|
|
13
|
+
*
|
|
14
|
+
* Markers: the value box carries `data-kit-held="<type>"`, its reason line `data-slot="kit-held-reason"`, the error card
|
|
15
|
+
* `data-kit-error`.
|
|
16
|
+
*/
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import type { FieldPath, FieldSchema } from "../schema/types";
|
|
19
|
+
/**
|
|
20
|
+
* A stored value as readable lines (never a JSON dump unless nothing else reads): a scalar is its text, a list is its
|
|
21
|
+
* count and its first items, an object its set keys by their field titles.
|
|
22
|
+
*/
|
|
23
|
+
export declare function heldLines(field: FieldSchema, value: unknown): string[];
|
|
24
|
+
export interface HeldValueProps {
|
|
25
|
+
field: FieldSchema;
|
|
26
|
+
value: unknown;
|
|
27
|
+
/** the FieldShell id: the shell's label names this box */
|
|
28
|
+
id: string;
|
|
29
|
+
/** why the field is held, as a clause or a sentence ("it holds formatting this editor cannot keep") */
|
|
30
|
+
reason: string;
|
|
31
|
+
/** rich text: the HTML the codec read for the value, when it could read it (shown read-only, sanitized) */
|
|
32
|
+
html?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The body of a held field (inside a FieldShell): the reason line, then the stored value read-only. Takes no onChange,
|
|
36
|
+
* so it cannot write.
|
|
37
|
+
*/
|
|
38
|
+
export declare function HeldValue({ field, value, id, reason, html }: HeldValueProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
/** A whole held field: the kit FieldShell (label, help, read-only) around HeldValue. Must be inside <SchemaForm>. */
|
|
40
|
+
export declare function HeldField({ field, path, reason, html }: {
|
|
41
|
+
field: FieldSchema;
|
|
42
|
+
path: FieldPath;
|
|
43
|
+
reason: string;
|
|
44
|
+
html?: string;
|
|
45
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
/**
|
|
47
|
+
* One field's error boundary: a control that throws while rendering holds that field ("this field could not be drawn:
|
|
48
|
+
* <message>") and the rest of the form keeps working. Retried once the field's schema or value changes (a schema edit,
|
|
49
|
+
* a save from elsewhere, an undo).
|
|
50
|
+
*/
|
|
51
|
+
export declare class FieldBoundary extends React.Component<{
|
|
52
|
+
field: FieldSchema;
|
|
53
|
+
path: FieldPath;
|
|
54
|
+
value: unknown;
|
|
55
|
+
children: React.ReactNode;
|
|
56
|
+
}, {
|
|
57
|
+
reason: string | null;
|
|
58
|
+
}> {
|
|
59
|
+
state: {
|
|
60
|
+
reason: string | null;
|
|
61
|
+
};
|
|
62
|
+
static getDerivedStateFromError(error: unknown): {
|
|
63
|
+
reason: string;
|
|
64
|
+
};
|
|
65
|
+
componentDidUpdate(prev: {
|
|
66
|
+
field: FieldSchema;
|
|
67
|
+
value: unknown;
|
|
68
|
+
}): void;
|
|
69
|
+
render(): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
|
|
70
|
+
}
|
|
71
|
+
export interface KitErrorCardProps {
|
|
72
|
+
/** what failed, as a sentence or a clause ("The form could not be drawn: x is undefined") */
|
|
73
|
+
reason: string;
|
|
74
|
+
/** draws the form again */
|
|
75
|
+
onRetry: () => void;
|
|
76
|
+
className?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* For a form that throws as a whole: the reason, "Nothing was changed.", and Retry. Carries `data-kit-error`. The host
|
|
80
|
+
* reports the error itself; this card only shows it.
|
|
81
|
+
*/
|
|
82
|
+
export declare function KitErrorCard({ reason, onRetry, className }: KitErrorCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { isObj } from "../lib/path.js";
|
|
2
|
+
import { plainText } from "../lib/schema.js";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { useForm } from "../context.js";
|
|
5
|
+
import { Button } from "../ui/button.js";
|
|
6
|
+
import { FieldShell } from "./field-shell.js";
|
|
7
|
+
import { sanitize } from "../controls/rich-text/dom.js";
|
|
8
|
+
import { plainOf } from "./kit-field.js";
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region src/engine/held.tsx
|
|
12
|
+
/**
|
|
13
|
+
* HELD fields and the kit's error surfaces (kit 3.2.0).
|
|
14
|
+
*
|
|
15
|
+
* A held field is one the form cannot edit without changing what is stored: it renders read-only inside the usual
|
|
16
|
+
* FieldShell (label, help), shows the stored value as faithfully as the kit can (rich text as its HTML, scalars as text,
|
|
17
|
+
* objects and lists as a short readable summary), names why in one line, and never writes. Kit 4.0.0 removed the
|
|
18
|
+
* host-control hand-off it replaced.
|
|
19
|
+
*
|
|
20
|
+
* - `FieldSchema.held` / `KitServices.heldReason`: the host holds a field (KitField checks both before anything else)
|
|
21
|
+
* - a control that refuses a value (rich text the codec cannot carry) draws `HeldValue` in its place
|
|
22
|
+
* - a control that throws while rendering: `FieldBoundary` holds that one field; the rest of the form keeps working
|
|
23
|
+
* - a whole form that throws: the host draws `KitErrorCard` (reason, "Nothing was changed.", Retry)
|
|
24
|
+
*
|
|
25
|
+
* Markers: the value box carries `data-kit-held="<type>"`, its reason line `data-slot="kit-held-reason"`, the error card
|
|
26
|
+
* `data-kit-error`.
|
|
27
|
+
*/
|
|
28
|
+
var sentence = (s) => s.trim().replace(/[.\s]*$/, ".");
|
|
29
|
+
var noop = () => {};
|
|
30
|
+
/** The HTML a stored rich-text value carries (an HTML string, a `{ html }` / `{ format: "html", value }` envelope), or null. */
|
|
31
|
+
function storedHtml(value) {
|
|
32
|
+
if (typeof value === "string") return /<[a-z!/]/i.test(value) ? value : null;
|
|
33
|
+
if (!isObj(value)) return null;
|
|
34
|
+
if (typeof value.html === "string" && value.html) return value.html;
|
|
35
|
+
if (value.format === "html" && typeof value.value === "string") return value.value;
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
/** One list item in a few words: its own text (title, label, name, block text) or a plain count of what it holds. */
|
|
39
|
+
function itemText(v) {
|
|
40
|
+
if (v == null || v === "") return "Empty";
|
|
41
|
+
if (typeof v !== "object") return String(v);
|
|
42
|
+
const t = plainText(v);
|
|
43
|
+
if (t) return t;
|
|
44
|
+
if (Array.isArray(v)) return `${v.length} ${v.length === 1 ? "item" : "items"}`;
|
|
45
|
+
const n = Object.keys(v).filter((k) => !k.startsWith("_")).length;
|
|
46
|
+
return `${n} ${n === 1 ? "field" : "fields"}`;
|
|
47
|
+
}
|
|
48
|
+
var clip = (s, n = 120) => s.length > n ? `${s.slice(0, n - 1)}…` : s;
|
|
49
|
+
var MAX_LINES = 6;
|
|
50
|
+
/**
|
|
51
|
+
* A stored value as readable lines (never a JSON dump unless nothing else reads): a scalar is its text, a list is its
|
|
52
|
+
* count and its first items, an object its set keys by their field titles.
|
|
53
|
+
*/
|
|
54
|
+
function heldLines(field, value) {
|
|
55
|
+
if (value == null || value === "" || Array.isArray(value) && !value.length) return [];
|
|
56
|
+
if (Array.isArray(value)) return [
|
|
57
|
+
`${value.length} ${value.length === 1 ? "item" : "items"}`,
|
|
58
|
+
...value.slice(0, MAX_LINES).map((v) => clip(itemText(v))),
|
|
59
|
+
...value.length > MAX_LINES ? [`and ${value.length - MAX_LINES} more`] : []
|
|
60
|
+
];
|
|
61
|
+
if (isObj(value)) {
|
|
62
|
+
if (field.type === "richtext") {
|
|
63
|
+
const t = plainText(value);
|
|
64
|
+
return t ? [t] : [];
|
|
65
|
+
}
|
|
66
|
+
const titleOf = (k) => field.fields?.find((f) => f.name === k)?.title ?? k;
|
|
67
|
+
const lines = Object.entries(value).filter(([k, v]) => !k.startsWith("_") && v != null && v !== "" && !(Array.isArray(v) && !v.length)).map(([k, v]) => `${titleOf(k)}: ${clip(itemText(v), 80)}`);
|
|
68
|
+
if (lines.length) return lines.length > MAX_LINES ? [...lines.slice(0, MAX_LINES), `and ${lines.length - MAX_LINES} more`] : lines;
|
|
69
|
+
const raw = JSON.stringify(value);
|
|
70
|
+
return raw && raw !== "{}" ? [clip(raw, 200)] : [];
|
|
71
|
+
}
|
|
72
|
+
const t = field.type === "richtext" ? plainText(value) : plainOf(field, value) || String(value);
|
|
73
|
+
return t ? [t] : [];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The body of a held field (inside a FieldShell): the reason line, then the stored value read-only. Takes no onChange,
|
|
77
|
+
* so it cannot write.
|
|
78
|
+
*/
|
|
79
|
+
function HeldValue({ field, value, id, reason, html }) {
|
|
80
|
+
const rich = field.type === "richtext" ? html ?? storedHtml(value) : null;
|
|
81
|
+
const lines = rich == null ? heldLines(field, value) : [];
|
|
82
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
83
|
+
"data-kit-held": field.type,
|
|
84
|
+
className: "flex min-w-0 flex-col gap-1.5",
|
|
85
|
+
children: [/* @__PURE__ */ jsxs("p", {
|
|
86
|
+
role: "note",
|
|
87
|
+
"data-slot": "kit-held-reason",
|
|
88
|
+
className: "rounded-kit-md bg-kit-subtle px-2.5 py-1.5 text-kit-xs text-kit-fg-2",
|
|
89
|
+
children: ["Shown read-only: ", sentence(reason)]
|
|
90
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
91
|
+
id,
|
|
92
|
+
tabIndex: 0,
|
|
93
|
+
role: "group",
|
|
94
|
+
"aria-labelledby": `${id}-label ${id}`,
|
|
95
|
+
"aria-readonly": "true",
|
|
96
|
+
"data-slot": "kit-held-value",
|
|
97
|
+
className: cn("min-w-0 break-words rounded-kit-sm text-kit-sm leading-6 text-kit-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kit-focus-ring focus-visible:[outline-style:solid] [html[data-input-modality=pointer]_&]:focus-visible:outline-0", rich == null && "whitespace-pre-wrap"),
|
|
98
|
+
children: rich != null ? /* @__PURE__ */ jsx("div", {
|
|
99
|
+
"data-slot": "kit-held-html",
|
|
100
|
+
className: "[&_a]:underline [&_ol]:list-decimal [&_ol]:pl-5 [&_ul]:list-disc [&_ul]:pl-5",
|
|
101
|
+
dangerouslySetInnerHTML: { __html: sanitize(rich) }
|
|
102
|
+
}) : lines.length ? lines.length === 1 ? lines[0] : /* @__PURE__ */ jsx("ul", {
|
|
103
|
+
className: "flex flex-col",
|
|
104
|
+
children: lines.map((l, i) => /* @__PURE__ */ jsx("li", {
|
|
105
|
+
className: cn(i === 0 && Array.isArray(value) ? "text-kit-xs text-kit-fg-3" : void 0),
|
|
106
|
+
children: l
|
|
107
|
+
}, i))
|
|
108
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
109
|
+
className: "text-kit-fg-3",
|
|
110
|
+
children: "Empty"
|
|
111
|
+
})
|
|
112
|
+
})]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** A whole held field: the kit FieldShell (label, help, read-only) around HeldValue. Must be inside <SchemaForm>. */
|
|
116
|
+
function HeldField({ field, path, reason, html }) {
|
|
117
|
+
const form = useForm();
|
|
118
|
+
const id = React.useId();
|
|
119
|
+
const value = form?.getAt(path);
|
|
120
|
+
return /* @__PURE__ */ jsx(FieldShell, {
|
|
121
|
+
field,
|
|
122
|
+
path,
|
|
123
|
+
id,
|
|
124
|
+
value,
|
|
125
|
+
onChange: noop,
|
|
126
|
+
readOnly: true,
|
|
127
|
+
children: /* @__PURE__ */ jsx(HeldValue, {
|
|
128
|
+
field,
|
|
129
|
+
value,
|
|
130
|
+
id,
|
|
131
|
+
reason,
|
|
132
|
+
html
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* One field's error boundary: a control that throws while rendering holds that field ("this field could not be drawn:
|
|
138
|
+
* <message>") and the rest of the form keeps working. Retried once the field's schema or value changes (a schema edit,
|
|
139
|
+
* a save from elsewhere, an undo).
|
|
140
|
+
*/
|
|
141
|
+
var FieldBoundary = class extends React.Component {
|
|
142
|
+
state = { reason: null };
|
|
143
|
+
static getDerivedStateFromError(error) {
|
|
144
|
+
return { reason: error instanceof Error ? error.message : String(error) };
|
|
145
|
+
}
|
|
146
|
+
componentDidUpdate(prev) {
|
|
147
|
+
if (this.state.reason === null) return;
|
|
148
|
+
if (prev.value !== this.props.value || JSON.stringify(prev.field) !== JSON.stringify(this.props.field)) this.setState({ reason: null });
|
|
149
|
+
}
|
|
150
|
+
render() {
|
|
151
|
+
if (this.state.reason === null) return this.props.children;
|
|
152
|
+
return /* @__PURE__ */ jsx(HeldField, {
|
|
153
|
+
field: this.props.field,
|
|
154
|
+
path: this.props.path,
|
|
155
|
+
reason: `this field could not be drawn: ${this.state.reason}`
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* For a form that throws as a whole: the reason, "Nothing was changed.", and Retry. Carries `data-kit-error`. The host
|
|
161
|
+
* reports the error itself; this card only shows it.
|
|
162
|
+
*/
|
|
163
|
+
function KitErrorCard({ reason, onRetry, className }) {
|
|
164
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
165
|
+
role: "alert",
|
|
166
|
+
"data-kit-error": "",
|
|
167
|
+
className: cn("flex flex-col items-start gap-2 rounded-kit-lg border border-kit-line bg-kit-subtle p-3", className),
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ jsx("p", {
|
|
170
|
+
"data-slot": "kit-error-reason",
|
|
171
|
+
className: "text-kit-sm text-kit-fg",
|
|
172
|
+
children: sentence(reason)
|
|
173
|
+
}),
|
|
174
|
+
/* @__PURE__ */ jsx("p", {
|
|
175
|
+
className: "text-kit-xs text-kit-fg-2",
|
|
176
|
+
children: "Nothing was changed."
|
|
177
|
+
}),
|
|
178
|
+
/* @__PURE__ */ jsx(Button, {
|
|
179
|
+
variant: "secondary",
|
|
180
|
+
size: "sm",
|
|
181
|
+
onClick: onRetry,
|
|
182
|
+
children: "Retry"
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
export { FieldBoundary, HeldField, HeldValue, KitErrorCard, heldLines };
|
|
189
|
+
|
|
190
|
+
//# sourceMappingURL=held.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"held.js","names":[],"sources":["../../src/engine/held.tsx"],"sourcesContent":["/**\n * HELD fields and the kit's error surfaces (kit 3.2.0).\n *\n * A held field is one the form cannot edit without changing what is stored: it renders read-only inside the usual\n * FieldShell (label, help), shows the stored value as faithfully as the kit can (rich text as its HTML, scalars as text,\n * objects and lists as a short readable summary), names why in one line, and never writes. Kit 4.0.0 removed the\n * host-control hand-off it replaced.\n *\n * - `FieldSchema.held` / `KitServices.heldReason`: the host holds a field (KitField checks both before anything else)\n * - a control that refuses a value (rich text the codec cannot carry) draws `HeldValue` in its place\n * - a control that throws while rendering: `FieldBoundary` holds that one field; the rest of the form keeps working\n * - a whole form that throws: the host draws `KitErrorCard` (reason, \"Nothing was changed.\", Retry)\n *\n * Markers: the value box carries `data-kit-held=\"<type>\"`, its reason line `data-slot=\"kit-held-reason\"`, the error card\n * `data-kit-error`.\n */\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport { plainText } from \"../lib/schema\";\nimport type { FieldPath, FieldSchema } from \"../schema/types\";\nimport { useForm } from \"../context\";\nimport { Button } from \"../ui/button\";\nimport { sanitize } from \"../controls/rich-text/dom\";\nimport { FieldShell } from \"./field-shell\";\nimport { plainOf } from \"./kit-field\";\n\nconst sentence = (s: string) => s.trim().replace(/[.\\s]*$/, \".\");\nconst noop = () => {};\n\n/** The HTML a stored rich-text value carries (an HTML string, a `{ html }` / `{ format: \"html\", value }` envelope), or null. */\nfunction storedHtml(value: unknown): string | null {\n if (typeof value === \"string\") return /<[a-z!/]/i.test(value) ? value : null;\n if (!isObj(value)) return null;\n if (typeof value.html === \"string\" && value.html) return value.html;\n if (value.format === \"html\" && typeof value.value === \"string\") return value.value;\n return null;\n}\n\n/** One list item in a few words: its own text (title, label, name, block text) or a plain count of what it holds. */\nfunction itemText(v: unknown): string {\n if (v == null || v === \"\") return \"Empty\";\n if (typeof v !== \"object\") return String(v);\n const t = plainText(v);\n if (t) return t;\n if (Array.isArray(v)) return `${v.length} ${v.length === 1 ? \"item\" : \"items\"}`;\n const n = Object.keys(v).filter((k) => !k.startsWith(\"_\")).length;\n return `${n} ${n === 1 ? \"field\" : \"fields\"}`;\n}\n\nconst clip = (s: string, n = 120) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);\nconst MAX_LINES = 6;\n\n/**\n * A stored value as readable lines (never a JSON dump unless nothing else reads): a scalar is its text, a list is its\n * count and its first items, an object its set keys by their field titles.\n */\nexport function heldLines(field: FieldSchema, value: unknown): string[] {\n if (value == null || value === \"\" || (Array.isArray(value) && !value.length)) return [];\n if (Array.isArray(value)) {\n const head = `${value.length} ${value.length === 1 ? \"item\" : \"items\"}`;\n const items = value.slice(0, MAX_LINES).map((v) => clip(itemText(v)));\n return [head, ...items, ...(value.length > MAX_LINES ? [`and ${value.length - MAX_LINES} more`] : [])];\n }\n if (isObj(value)) {\n if (field.type === \"richtext\") {\n const t = plainText(value);\n return t ? [t] : [];\n }\n const titleOf = (k: string) => field.fields?.find((f) => f.name === k)?.title ?? k;\n const lines = Object.entries(value)\n .filter(([k, v]) => !k.startsWith(\"_\") && v != null && v !== \"\" && !(Array.isArray(v) && !v.length))\n .map(([k, v]) => `${titleOf(k)}: ${clip(itemText(v), 80)}`);\n if (lines.length) return lines.length > MAX_LINES ? [...lines.slice(0, MAX_LINES), `and ${lines.length - MAX_LINES} more`] : lines;\n const raw = JSON.stringify(value);\n return raw && raw !== \"{}\" ? [clip(raw, 200)] : [];\n }\n const t = field.type === \"richtext\" ? plainText(value) : plainOf(field, value) || String(value);\n return t ? [t] : [];\n}\n\nexport interface HeldValueProps {\n field: FieldSchema;\n value: unknown;\n /** the FieldShell id: the shell's label names this box */\n id: string;\n /** why the field is held, as a clause or a sentence (\"it holds formatting this editor cannot keep\") */\n reason: string;\n /** rich text: the HTML the codec read for the value, when it could read it (shown read-only, sanitized) */\n html?: string;\n}\n\n/**\n * The body of a held field (inside a FieldShell): the reason line, then the stored value read-only. Takes no onChange,\n * so it cannot write.\n */\nexport function HeldValue({ field, value, id, reason, html }: HeldValueProps) {\n const rich = field.type === \"richtext\" ? (html ?? storedHtml(value)) : null;\n const lines = rich == null ? heldLines(field, value) : [];\n return (\n <div data-kit-held={field.type} className=\"flex min-w-0 flex-col gap-1.5\">\n <p role=\"note\" data-slot=\"kit-held-reason\" className=\"rounded-kit-md bg-kit-subtle px-2.5 py-1.5 text-kit-xs text-kit-fg-2\">\n Shown read-only: {sentence(reason)}\n </p>\n <div\n id={id}\n tabIndex={0}\n role=\"group\"\n aria-labelledby={`${id}-label ${id}`}\n aria-readonly=\"true\"\n data-slot=\"kit-held-value\"\n className={cn(\n \"min-w-0 break-words rounded-kit-sm text-kit-sm leading-6 text-kit-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-kit-focus-ring focus-visible:[outline-style:solid] [html[data-input-modality=pointer]_&]:focus-visible:outline-0\",\n rich == null && \"whitespace-pre-wrap\",\n )}\n >\n {rich != null ? (\n <div data-slot=\"kit-held-html\" className=\"[&_a]:underline [&_ol]:list-decimal [&_ol]:pl-5 [&_ul]:list-disc [&_ul]:pl-5\" dangerouslySetInnerHTML={{ __html: sanitize(rich) }} />\n ) : lines.length ? (\n lines.length === 1 ? (\n lines[0]\n ) : (\n <ul className=\"flex flex-col\">\n {lines.map((l, i) => (\n <li key={i} className={cn(i === 0 && Array.isArray(value) ? \"text-kit-xs text-kit-fg-3\" : undefined)}>\n {l}\n </li>\n ))}\n </ul>\n )\n ) : (\n <span className=\"text-kit-fg-3\">Empty</span>\n )}\n </div>\n </div>\n );\n}\n\n/** A whole held field: the kit FieldShell (label, help, read-only) around HeldValue. Must be inside <SchemaForm>. */\nexport function HeldField({ field, path, reason, html }: { field: FieldSchema; path: FieldPath; reason: string; html?: string }) {\n const form = useForm();\n const id = React.useId();\n const value = form?.getAt(path);\n return (\n <FieldShell field={field} path={path} id={id} value={value} onChange={noop} readOnly>\n <HeldValue field={field} value={value} id={id} reason={reason} html={html} />\n </FieldShell>\n );\n}\n\n/**\n * One field's error boundary: a control that throws while rendering holds that field (\"this field could not be drawn:\n * <message>\") and the rest of the form keeps working. Retried once the field's schema or value changes (a schema edit,\n * a save from elsewhere, an undo).\n */\nexport class FieldBoundary extends React.Component<\n { field: FieldSchema; path: FieldPath; value: unknown; children: React.ReactNode },\n { reason: string | null }\n> {\n state = { reason: null as string | null };\n static getDerivedStateFromError(error: unknown) {\n return { reason: error instanceof Error ? error.message : String(error) };\n }\n componentDidUpdate(prev: { field: FieldSchema; value: unknown }) {\n if (this.state.reason === null) return;\n if (prev.value !== this.props.value || JSON.stringify(prev.field) !== JSON.stringify(this.props.field)) this.setState({ reason: null });\n }\n render() {\n if (this.state.reason === null) return this.props.children;\n return <HeldField field={this.props.field} path={this.props.path} reason={`this field could not be drawn: ${this.state.reason}`} />;\n }\n}\n\nexport interface KitErrorCardProps {\n /** what failed, as a sentence or a clause (\"The form could not be drawn: x is undefined\") */\n reason: string;\n /** draws the form again */\n onRetry: () => void;\n className?: string;\n}\n\n/**\n * For a form that throws as a whole: the reason, \"Nothing was changed.\", and Retry. Carries `data-kit-error`. The host\n * reports the error itself; this card only shows it.\n */\nexport function KitErrorCard({ reason, onRetry, className }: KitErrorCardProps) {\n return (\n <div role=\"alert\" data-kit-error=\"\" className={cn(\"flex flex-col items-start gap-2 rounded-kit-lg border border-kit-line bg-kit-subtle p-3\", className)}>\n <p data-slot=\"kit-error-reason\" className=\"text-kit-sm text-kit-fg\">\n {sentence(reason)}\n </p>\n <p className=\"text-kit-xs text-kit-fg-2\">Nothing was changed.</p>\n <Button variant=\"secondary\" size=\"sm\" onClick={onRetry}>\n Retry\n </Button>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAM,YAAY,MAAc,EAAE,KAAK,CAAC,CAAC,QAAQ,WAAW,GAAG;AAC/D,IAAM,aAAa,CAAC;;AAGpB,SAAS,WAAW,OAA+B;CACjD,IAAI,OAAO,UAAU,UAAU,OAAO,YAAY,KAAK,KAAK,IAAI,QAAQ;CACxE,IAAI,CAAC,MAAM,KAAK,GAAG,OAAO;CAC1B,IAAI,OAAO,MAAM,SAAS,YAAY,MAAM,MAAM,OAAO,MAAM;CAC/D,IAAI,MAAM,WAAW,UAAU,OAAO,MAAM,UAAU,UAAU,OAAO,MAAM;CAC7E,OAAO;AACT;;AAGA,SAAS,SAAS,GAAoB;CACpC,IAAI,KAAK,QAAQ,MAAM,IAAI,OAAO;CAClC,IAAI,OAAO,MAAM,UAAU,OAAO,OAAO,CAAC;CAC1C,MAAM,IAAI,UAAU,CAAC;CACrB,IAAI,GAAG,OAAO;CACd,IAAI,MAAM,QAAQ,CAAC,GAAG,OAAO,GAAG,EAAE,OAAO,GAAG,EAAE,WAAW,IAAI,SAAS;CACtE,MAAM,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC,CAAC;CAC3D,OAAO,GAAG,EAAE,GAAG,MAAM,IAAI,UAAU;AACrC;AAEA,IAAM,QAAQ,GAAW,IAAI,QAAS,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,KAAK;AAC/E,IAAM,YAAY;;;;;AAMlB,SAAgB,UAAU,OAAoB,OAA0B;CACtE,IAAI,SAAS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W;GAAY;GAAc;EAAO,CAAA;CAClE,CAAA;AAEhB;;;;;;AAOA,IAAa,gBAAb,cAAmC,MAAM,UAGvC;CACA,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;EAChC,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,OAAO,oBAAC,WAAD;GAAW,OAAO,KAAK,MAAM;GAAO,MAAM,KAAK,MAAM;GAAM,QAAQ,kCAAkC,KAAK,MAAM;EAAW,CAAA;CACpI;AACF;;;;;AAcA,SAAgB,aAAa,EAAE,QAAQ,SAAS,aAAgC;CAC9E,OACE,qBAAC,OAAD;EAAK,MAAK;EAAQ,kBAAe;EAAG,WAAW,GAAG,2FAA2F,SAAS;EAAtJ,UAAA;GACE,oBAAC,KAAD;IAAG,aAAU;IAAmB,WAAU;IACvC,UAAA,SAAS,MAAM;GACf,CAAA;GACH,oBAAC,KAAD;IAAG,WAAU;IAA4B,UAAA;GAAuB,CAAA;GAChE,oBAAC,QAAD;IAAQ,SAAQ;IAAY,MAAK;IAAK,SAAS;IAAS,UAAA;GAEhD,CAAA;EACL;;AAET"}
|
|
@@ -33,7 +33,11 @@ export declare function useFieldAccess(field: FieldSchema): {
|
|
|
33
33
|
};
|
|
34
34
|
/** CPO D39: the field's help line — schema text first, then a line computed from its settings, then the house convention. */
|
|
35
35
|
export declare function withDefaultHelp(field: FieldSchema, isPublished?: boolean, readOnly?: boolean): FieldSchema;
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* One field. A held field (FieldSchema.held, or a reason from KitServices.heldReason) renders read-only with its reason
|
|
38
|
+
* and is never written; a control that throws while rendering holds that one field (FieldBoundary).
|
|
39
|
+
*/
|
|
40
|
+
export declare function KitField(props: KitFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
37
41
|
/**
|
|
38
42
|
* A row that opens something (V2 NavRow): type tile, title over a summary line, the field's chrome (from RowChrome),
|
|
39
43
|
* the issue rollup and a chevron.
|
|
@@ -62,11 +66,3 @@ export declare function plainOf(field: FieldSchema, value: unknown): string;
|
|
|
62
66
|
* value is shown and kept, and an edit is written only once it parses.
|
|
63
67
|
*/
|
|
64
68
|
export declare function FallbackControl(props: ControlProps): import("react/jsx-runtime").JSX.Element;
|
|
65
|
-
/**
|
|
66
|
-
* A control that cannot carry a stored value unchanged (rich text holding formatting its editor would drop) hands that
|
|
67
|
-
* value to the host's control for the type (KitServices.LegacyControl: the dashboard's FieldRenderer arm), bare inside
|
|
68
|
-
* the kit FieldShell, which owns the label and the help; the control names its reason above it. The box carries
|
|
69
|
-
* `data-kit-legacy="<type>"`, so the parity harness counts it (mismatch class `legacy-control`). A host with no legacy
|
|
70
|
-
* service, or a control that throws while rendering, says why in words; the form around it keeps working.
|
|
71
|
-
*/
|
|
72
|
-
export declare function LegacyFallback(props: ControlProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/engine/kit-field.js
CHANGED
|
@@ -17,6 +17,7 @@ import { ExpandAction, ExpandedField, expandKey, expandSpecFor, isExpandShortcut
|
|
|
17
17
|
import { SchemaForm } from "./schema-form.js";
|
|
18
18
|
import { SlotField } from "./slot.js";
|
|
19
19
|
import { JsonControl } from "../controls/json.js";
|
|
20
|
+
import { FieldBoundary, HeldField } from "./held.js";
|
|
20
21
|
import * as React from "react";
|
|
21
22
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
22
23
|
import { IconChevronRight } from "@tabler/icons-react";
|
|
@@ -66,12 +67,36 @@ function withDefaultHelp(field, isPublished, readOnly) {
|
|
|
66
67
|
description: help
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
+
/**
|
|
71
|
+
* One field. A held field (FieldSchema.held, or a reason from KitServices.heldReason) renders read-only with its reason
|
|
72
|
+
* and is never written; a control that throws while rendering holds that one field (FieldBoundary).
|
|
73
|
+
*/
|
|
74
|
+
function KitField(props) {
|
|
75
|
+
const form = useForm();
|
|
76
|
+
return /* @__PURE__ */ jsx(FieldBoundary, {
|
|
77
|
+
field: props.field,
|
|
78
|
+
path: props.path,
|
|
79
|
+
value: form?.getAt(props.path),
|
|
80
|
+
children: /* @__PURE__ */ jsx(KitFieldBody, { ...props })
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function KitFieldBody({ field, path, parent }) {
|
|
70
84
|
const form = useForm();
|
|
71
85
|
const env = useKitEnv();
|
|
86
|
+
const services = useKitServices();
|
|
72
87
|
const id = React.useId();
|
|
73
88
|
const { readOnly } = useFieldAccess(field);
|
|
74
89
|
if (!form) return null;
|
|
90
|
+
const heldReason = field.held?.reason || services.heldReason?.({
|
|
91
|
+
field,
|
|
92
|
+
path,
|
|
93
|
+
value: form.getAt(path)
|
|
94
|
+
});
|
|
95
|
+
if (heldReason) return /* @__PURE__ */ jsx(HeldField, {
|
|
96
|
+
field: withDefaultHelp(field, env.isPublished, true),
|
|
97
|
+
path,
|
|
98
|
+
reason: heldReason
|
|
99
|
+
});
|
|
75
100
|
const Custom = env.controls?.[pathKey(path)];
|
|
76
101
|
if (Custom) {
|
|
77
102
|
const ck = pathKey(path);
|
|
@@ -485,72 +510,7 @@ function FallbackControl(props) {
|
|
|
485
510
|
children: /* @__PURE__ */ jsx(JsonControl, { ...props })
|
|
486
511
|
});
|
|
487
512
|
}
|
|
488
|
-
/**
|
|
489
|
-
* A control that cannot carry a stored value unchanged (rich text holding formatting its editor would drop) hands that
|
|
490
|
-
* value to the host's control for the type (KitServices.LegacyControl: the dashboard's FieldRenderer arm), bare inside
|
|
491
|
-
* the kit FieldShell, which owns the label and the help; the control names its reason above it. The box carries
|
|
492
|
-
* `data-kit-legacy="<type>"`, so the parity harness counts it (mismatch class `legacy-control`). A host with no legacy
|
|
493
|
-
* service, or a control that throws while rendering, says why in words; the form around it keeps working.
|
|
494
|
-
*/
|
|
495
|
-
function LegacyFallback(props) {
|
|
496
|
-
const { LegacyControl } = useKitServices();
|
|
497
|
-
const { field, id } = props;
|
|
498
|
-
return /* @__PURE__ */ jsx("div", {
|
|
499
|
-
"data-kit-legacy": field.type,
|
|
500
|
-
className: "min-w-0",
|
|
501
|
-
children: LegacyControl ? /* @__PURE__ */ jsx(LegacyBoundary, {
|
|
502
|
-
field,
|
|
503
|
-
id,
|
|
504
|
-
value: props.value,
|
|
505
|
-
children: /* @__PURE__ */ jsx(LegacyControl, { ...props })
|
|
506
|
-
}, JSON.stringify(field)) : /* @__PURE__ */ jsxs(LegacyRefusal, {
|
|
507
|
-
id,
|
|
508
|
-
children: [
|
|
509
|
-
"This view has no control for ",
|
|
510
|
-
field.type,
|
|
511
|
-
" fields."
|
|
512
|
-
]
|
|
513
|
-
})
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* An `<output>`: a labelable element, so the FieldShell label's `for` lands on it, and focusable, so a keyboard user
|
|
518
|
-
* reaches the reason. The neutral focus ring shows under keyboard modality only.
|
|
519
|
-
*/
|
|
520
|
-
function LegacyRefusal({ id, children }) {
|
|
521
|
-
return /* @__PURE__ */ jsx("output", {
|
|
522
|
-
id,
|
|
523
|
-
role: "note",
|
|
524
|
-
tabIndex: 0,
|
|
525
|
-
"data-slot": "kit-legacy-refusal",
|
|
526
|
-
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",
|
|
527
|
-
children
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
/** Retries the control once its field or value changes (a schema edit, a save from elsewhere, an undo). */
|
|
531
|
-
var LegacyBoundary = class extends React.Component {
|
|
532
|
-
state = { reason: null };
|
|
533
|
-
static getDerivedStateFromError(error) {
|
|
534
|
-
return { reason: error instanceof Error ? error.message : String(error) };
|
|
535
|
-
}
|
|
536
|
-
componentDidUpdate(prev) {
|
|
537
|
-
if (this.state.reason === null) return;
|
|
538
|
-
if (prev.value !== this.props.value || JSON.stringify(prev.field) !== JSON.stringify(this.props.field)) this.setState({ reason: null });
|
|
539
|
-
}
|
|
540
|
-
render() {
|
|
541
|
-
if (this.state.reason === null) return this.props.children;
|
|
542
|
-
return /* @__PURE__ */ jsxs(LegacyRefusal, {
|
|
543
|
-
id: this.props.id,
|
|
544
|
-
children: [
|
|
545
|
-
"The ",
|
|
546
|
-
this.props.field.title,
|
|
547
|
-
" control could not load: ",
|
|
548
|
-
this.state.reason
|
|
549
|
-
]
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
513
|
//#endregion
|
|
554
|
-
export { ACTIONS, ACTION_WHEN_READ_ONLY, CONTROLS, FallbackControl, KitField,
|
|
514
|
+
export { ACTIONS, ACTION_WHEN_READ_ONLY, CONTROLS, FallbackControl, KitField, NavRow, NestedForm, plainOf, useFieldAccess, withDefaultHelp };
|
|
555
515
|
|
|
556
516
|
//# sourceMappingURL=kit-field.js.map
|