@bettercms-ai/kit 3.1.18 → 3.1.21

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.
@@ -223,6 +223,9 @@ function FrameHeader({ frame, context, title }) {
223
223
  const sibling = (i) => 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 : "";
224
224
  const prev = it ? sibling(it.index - 1) : "";
225
225
  const next = it ? sibling(it.index + 1) : "";
226
+ const bounds = frame.kind === "item" || frame.kind === "block" ? frame.field?.validation : void 0;
227
+ const atMax = bounds?.max != null && list.length >= bounds.max;
228
+ const atMin = bounds?.min != null && list.length <= bounds.min;
226
229
  const moved = React.useRef(false);
227
230
  return /* @__PURE__ */ jsxs("div", {
228
231
  className: "flex items-start gap-2.5 outline-none",
@@ -278,6 +281,7 @@ function FrameHeader({ frame, context, title }) {
278
281
  children: [
279
282
  /* @__PURE__ */ jsx(MenuItem, {
280
283
  icon: /* @__PURE__ */ jsx(IconCopy, { stroke: 1.5 }),
284
+ disabled: atMax,
281
285
  onClick: () => {
282
286
  moved.current = true;
283
287
  const copy = isObj(list[it.index]) ? {
@@ -292,12 +296,13 @@ function FrameHeader({ frame, context, title }) {
292
296
  form.navigate([...it.arrayPath, it.index + 1]);
293
297
  toast?.success("Duplicated", { description: "You're now editing the copy." });
294
298
  },
295
- children: "Duplicate"
299
+ children: atMax ? "Duplicate · limit reached" : "Duplicate"
296
300
  }),
297
301
  /* @__PURE__ */ jsx(MenuSeparator, {}),
298
302
  /* @__PURE__ */ jsx(MenuItem, {
299
303
  danger: true,
300
304
  icon: /* @__PURE__ */ jsx(IconTrash, { stroke: 1.5 }),
305
+ disabled: atMin,
301
306
  onClick: () => {
302
307
  moved.current = true;
303
308
  const prevList = list;
@@ -311,7 +316,7 @@ function FrameHeader({ frame, context, title }) {
311
316
  duration: 1e4
312
317
  });
313
318
  },
314
- children: "Remove"
319
+ children: atMin ? `Remove · at least ${bounds?.min} required` : "Remove"
315
320
  })
316
321
  ]
317
322
  })] })
@@ -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, 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,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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ACA,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, 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 /* 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 /* 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 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 </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;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A,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"}
@@ -273,12 +273,29 @@ export declare function tableFromRows(rows: string[][], opts?: {
273
273
  header?: boolean;
274
274
  caption?: string;
275
275
  }): TableValue;
276
- /** Paste a text range into a table at (row, col), growing rows / columns as needed. Values coerce to column types. */
276
+ /**
277
+ * GAP-203: a pasted cell as the number a number, money or rating column stores, or null when it is not one. Digits with
278
+ * a sign and one decimal point, thousands in groups of three ("1,234.5"), with a currency symbol or code, a percent sign
279
+ * or the column's own unit around them; a rating may name its scale ("4.5/5"). Letters among the digits ("z5c5") are no
280
+ * number: their digits are never run together (it stored $55).
281
+ */
282
+ export declare function pastedNumber(raw: string, col: Pick<TableColumn, "type" | "unit">): number | null;
283
+ /** A pasted cell a number, money or rating column did not take (GAP-203): the text, and the column's label. */
284
+ export interface PasteRefusal {
285
+ text: string;
286
+ column: string;
287
+ }
288
+ /**
289
+ * Paste a text range into a table at (row, col), growing rows / columns as needed. Values coerce to column types; a
290
+ * number, money or rating cell takes only a number (`pastedNumber`), else it keeps its value and the text is added to
291
+ * `refused`.
292
+ */
277
293
  export declare function pasteRange(input: TableValue, at: {
278
294
  row: number;
279
295
  col: number;
280
296
  }, grid: string[][], opts?: {
281
297
  lockColumns?: boolean;
298
+ refused?: PasteRefusal[];
282
299
  }): TableValue;
283
300
  /**
284
301
  * Read a DOM <table> (or our <figure data-rt="table">) into the model. Our own data-* marks round-trip losslessly;
@@ -710,7 +710,25 @@ function tableFromRows(rows, opts = {}) {
710
710
  }));
711
711
  return out;
712
712
  }
713
- /** Paste a text range into a table at (row, col), growing rows / columns as needed. Values coerce to column types. */
713
+ /**
714
+ * GAP-203: a pasted cell as the number a number, money or rating column stores, or null when it is not one. Digits with
715
+ * a sign and one decimal point, thousands in groups of three ("1,234.5"), with a currency symbol or code, a percent sign
716
+ * or the column's own unit around them; a rating may name its scale ("4.5/5"). Letters among the digits ("z5c5") are no
717
+ * number: their digits are never run together (it stored $55).
718
+ */
719
+ function pastedNumber(raw, col) {
720
+ let s = strip(raw).trim().replace(/\s+/g, " ");
721
+ if (col.unit) s = s.replace(new RegExp(`\\s?${col.unit.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "i"), "");
722
+ s = s.replace(/\s?(USD|EUR|GBP|JPY|INR|AUD|CAD|CHF|%)$/i, "").replace(/^(USD|EUR|GBP|JPY|INR|AUD|CAD|CHF)\s?/i, "");
723
+ if (col.type === "rating") s = s.replace(/\s?(\/|out of)\s?\d+(\.\d+)?$/i, "");
724
+ s = s.replace(/^([+-]?)\s?[$€£¥₹]\s?/, "$1").replace(/\s?[$€£¥₹]$/, "");
725
+ return /\d/.test(s) && /^[+-]?(\d+|\d{1,3}(,\d{3})+)?(\.\d+)?$/.test(s) ? Number(s.replace(/,/g, "")) : null;
726
+ }
727
+ /**
728
+ * Paste a text range into a table at (row, col), growing rows / columns as needed. Values coerce to column types; a
729
+ * number, money or rating cell takes only a number (`pastedNumber`), else it keeps its value and the text is added to
730
+ * `refused`.
731
+ */
714
732
  function pasteRange(input, at, grid, opts = {}) {
715
733
  const t = normalizeTable(input);
716
734
  const columns = [...t.columns];
@@ -754,8 +772,23 @@ function pasteRange(input, at, grid, opts = {}) {
754
772
  line.forEach((raw, j) => {
755
773
  const col = columns[at.col + j];
756
774
  if (!col) return;
757
- rows[ri].cells[col._key] = withValue(rows[ri].cells[col._key], coerce(raw, {
758
- type: cellType(col, rows[ri], rows[ri].cells[col._key]),
775
+ const prev = rows[ri].cells[col._key];
776
+ const type = cellType(col, rows[ri], prev);
777
+ const plain = strip(raw).trim();
778
+ if ((type === "number" || type === "money" || type === "rating") && plain) {
779
+ const n = pastedNumber(raw, {
780
+ type,
781
+ unit: col.unit
782
+ });
783
+ if (n === null) opts.refused?.push({
784
+ text: plain,
785
+ column: col.label
786
+ });
787
+ else rows[ri].cells[col._key] = withValue(prev, n);
788
+ return;
789
+ }
790
+ rows[ri].cells[col._key] = withValue(prev, coerce(raw, {
791
+ type,
759
792
  max: col.max
760
793
  }));
761
794
  });
@@ -1194,6 +1227,6 @@ function tableFrom(caption, columns, rows, extra = {}) {
1194
1227
  };
1195
1228
  }
1196
1229
  //#endregion
1197
- export { GENERAL_TABLE, TABLE_COLUMN_TYPES, boolLabels, cellNote, cellText, cellType, cellValue, coerce, emptyTable, formatMoney, formatNumber, inferColumn, isCellObject, isEmptyCell, isObjLike, isTableValue, normalizeTable, orderedRows, parseDelimited, parseTableElement, pasteRange, renderTableHtml, sanitizeInline, sortRows, tableFrom, tableFromRows, tableIssues, tableJsonLd, tableSummary, tableToMarkdown, tableToRows, tkey, toBool, toDelimited, toNumber, withValue };
1230
+ export { GENERAL_TABLE, TABLE_COLUMN_TYPES, boolLabels, cellNote, cellText, cellType, cellValue, coerce, emptyTable, formatMoney, formatNumber, inferColumn, isCellObject, isEmptyCell, isObjLike, isTableValue, normalizeTable, orderedRows, parseDelimited, parseTableElement, pasteRange, pastedNumber, renderTableHtml, sanitizeInline, sortRows, tableFrom, tableFromRows, tableIssues, tableJsonLd, tableSummary, tableToMarkdown, tableToRows, tkey, toBool, toDelimited, toNumber, withValue };
1198
1231
 
1199
1232
  //# sourceMappingURL=table.js.map