@elytracms/studio 0.0.77 → 0.0.79

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.
Files changed (90) hide show
  1. package/convex/contract-parity.test.ts +238 -0
  2. package/convex/tsconfig.json +3 -1
  3. package/dist/components/app-views/default-modules.js +5 -1
  4. package/dist/components/app-views/default-modules.js.map +1 -1
  5. package/dist/components/assets/asset-thumb.js +12 -11
  6. package/dist/components/assets/asset-thumb.js.map +1 -1
  7. package/dist/components/builder/blocks-panel.d.ts +11 -5
  8. package/dist/components/builder/blocks-panel.js +18 -24
  9. package/dist/components/builder/blocks-panel.js.map +1 -1
  10. package/dist/components/builder/canvas-render-context.d.ts +22 -0
  11. package/dist/components/builder/canvas-render-context.js +65 -9
  12. package/dist/components/builder/canvas-render-context.js.map +1 -1
  13. package/dist/components/builder/reuse.d.ts +25 -0
  14. package/dist/components/builder/reuse.js +11 -2
  15. package/dist/components/builder/reuse.js.map +1 -1
  16. package/dist/components/cms/asset-field.js +52 -19
  17. package/dist/components/cms/asset-field.js.map +1 -1
  18. package/dist/components/cms/asset-picker-core.d.ts +40 -0
  19. package/dist/components/cms/asset-picker-core.js +21 -0
  20. package/dist/components/cms/asset-picker-core.js.map +1 -1
  21. package/dist/components/cms/asset-picker.d.ts +11 -2
  22. package/dist/components/cms/asset-picker.js +34 -13
  23. package/dist/components/cms/asset-picker.js.map +1 -1
  24. package/dist/components/cms/cell.js +2 -1
  25. package/dist/components/cms/cell.js.map +1 -1
  26. package/dist/components/cms/cms-store.d.ts +8 -1
  27. package/dist/components/cms/cms-store.js +8 -7
  28. package/dist/components/cms/cms-store.js.map +1 -1
  29. package/dist/components/cms/collection-table.js +8 -2
  30. package/dist/components/cms/collection-table.js.map +1 -1
  31. package/dist/components/cms/date-input-core.d.ts +64 -0
  32. package/dist/components/cms/date-input-core.js +78 -0
  33. package/dist/components/cms/date-input-core.js.map +1 -0
  34. package/dist/components/cms/date-input.d.ts +43 -0
  35. package/dist/components/cms/date-input.js +109 -0
  36. package/dist/components/cms/date-input.js.map +1 -0
  37. package/dist/components/cms/detail-editor.js.map +1 -1
  38. package/dist/components/cms/document-diff-view.js +2 -1
  39. package/dist/components/cms/document-diff-view.js.map +1 -1
  40. package/dist/components/cms/document-staging.d.ts +15 -4
  41. package/dist/components/cms/document-staging.js +26 -15
  42. package/dist/components/cms/document-staging.js.map +1 -1
  43. package/dist/components/cms/editable-cell.js +39 -5
  44. package/dist/components/cms/editable-cell.js.map +1 -1
  45. package/dist/components/cms/field-control.js +38 -7
  46. package/dist/components/cms/field-control.js.map +1 -1
  47. package/dist/components/cms/scalar-value-editor.js +4 -1
  48. package/dist/components/cms/scalar-value-editor.js.map +1 -1
  49. package/dist/components/cms/slug-auto-derive.d.ts +41 -0
  50. package/dist/components/cms/slug-auto-derive.js +14 -0
  51. package/dist/components/cms/slug-auto-derive.js.map +1 -0
  52. package/dist/components/components/transfer-dialog.js +3 -1
  53. package/dist/components/components/transfer-dialog.js.map +1 -1
  54. package/dist/components/project-session.d.ts +44 -22
  55. package/dist/components/project-session.js +72 -36
  56. package/dist/components/project-session.js.map +1 -1
  57. package/dist/lib/assets/asset-url.d.ts +20 -0
  58. package/dist/lib/assets/asset-url.js +25 -0
  59. package/dist/lib/assets/asset-url.js.map +1 -0
  60. package/dist/lib/assets/browser-blob-storage.d.ts +80 -0
  61. package/dist/lib/assets/browser-blob-storage.js +86 -0
  62. package/dist/lib/assets/browser-blob-storage.js.map +1 -0
  63. package/dist/lib/assets/index.d.ts +2 -0
  64. package/dist/lib/assets/index.js +2 -0
  65. package/dist/lib/assets/index.js.map +1 -1
  66. package/dist/lib/data/collection-content.d.ts +20 -1
  67. package/dist/lib/data/collection-content.js +51 -1
  68. package/dist/lib/data/collection-content.js.map +1 -1
  69. package/dist/lib/data/content-session-refresh.d.ts +74 -0
  70. package/dist/lib/data/content-session-refresh.js +138 -0
  71. package/dist/lib/data/content-session-refresh.js.map +1 -0
  72. package/dist/lib/data/index.d.ts +2 -0
  73. package/dist/lib/data/index.js +2 -0
  74. package/dist/lib/data/index.js.map +1 -1
  75. package/dist/lib/data/playground-unload-guard.d.ts +22 -0
  76. package/dist/lib/data/playground-unload-guard.js +73 -0
  77. package/dist/lib/data/playground-unload-guard.js.map +1 -0
  78. package/dist/lib/i18n/messages.de.js +3 -1
  79. package/dist/lib/i18n/messages.de.js.map +1 -1
  80. package/dist/lib/i18n/messages.en.d.ts +2 -0
  81. package/dist/lib/i18n/messages.en.js +5 -1
  82. package/dist/lib/i18n/messages.en.js.map +1 -1
  83. package/dist/lib/persistence/convex-adapter.js +3 -3
  84. package/dist/lib/persistence/convex-adapter.js.map +1 -1
  85. package/dist/lib/persistence/index.js +6 -1
  86. package/dist/lib/persistence/index.js.map +1 -1
  87. package/dist/ui/input.d.ts +8 -3
  88. package/dist/ui/input.js +6 -1
  89. package/dist/ui/input.js.map +1 -1
  90. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"file":"document-diff-view.js","sourceRoot":"","sources":["../../../src/components/cms/document-diff-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEjF,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAEtG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAA;AAChD,OAAO,EA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C,CAAA;IAC9B,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,CAAA;IAC7B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClD,CAAC;AAED,sDAAsD;AACtD,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAA;IACjF,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACzD,CAAC","sourcesContent":["import { createContext, useCallback, useContext, useMemo, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport { Image as ImageIcon, RotateCcw } from 'lucide-react'\nimport type { BlockChange, ChangeKind, DocumentDiff, FieldChange, PropChange } from '@elytracms/core/content'\nimport { assetSubfieldsOf, isAssetNode, readAssetId, readDocumentRef } from '@elytracms/core/cms-core'\nimport type { CollectionDef, FieldDef, RestoreScope } from '@elytracms/core/cms-core'\nimport { Badge, Button, Code, Row, Spacer, Stack, Text } from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { localeChipLabel } from '@elytracms/studio/lib/locale'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { readDiffViewMode, storeDiffViewMode } from '@elytracms/studio/lib/diff-view-preference'\nimport type { DiffViewMode } from '@elytracms/studio/lib/diff-view-preference'\nimport { useCollectionView } from '../collection-view/collection-view-context'\nimport { fieldLabel } from './cms-labels'\nimport { toRefArray } from './cell'\nimport { RichTextPreview, isRichTextValueEmpty } from './rich-text-preview'\nimport {\n DIFF_TRUNCATE_THRESHOLD,\n mergeWordDiff,\n richTextToText,\n truncateText,\n truncateTokensAroundChange,\n wordDiff,\n} from './version-compare-text'\nimport type { AnchoredExcerpt, MergedDiffToken, WordToken } from './version-compare-text'\n\n/**\n * The shared document-diff RENDERER (EC-317 change-list), extracted from\n * `VersionCompare` so a single renderer serves both the version-compare surface and\n * the EC-199 AI proposal review — never two diff renderers. It draws a `DocumentDiff`\n * ({@link diffDocuments}) as the calm change-list grouped BY FIELD: a descriptor lane,\n * before | after (or a unified lane), text as a prose diff, assets as thumbnails,\n * relations as titles, long values collapsed behind \"Show more\", zebra rows.\n *\n * It is display-only over an already-computed diff: the version chrome (version\n * pickers / steppers / restore-whole) stays in `VersionCompare`; the AI proposal card\n * feeds `diffDocuments(collection, emptyBefore, proposedAfter)` and omits `restore`.\n * The per-row restore affordance renders only when `restore.canRestore` is set, so the\n * AI review (a not-yet-saved proposal) shows a clean, restore-free diff.\n *\n * **Layout (EC-382).** One diff LOGIC, two presentations selected by `layout`:\n * `'grid'` (default) is the wide version-compare surface — a fixed descriptor lane\n * plus a unified/side-by-side value area. `'stacked'` is the sidebar-fit variant the\n * AI proposal card selects: each field is a full-width card (label header, then\n * `Current → Proposed` VERTICALLY) that reads at ~320px without a squished two-column\n * split. Only chrome + column arrangement branch on `layout`; grouping, word diffing,\n * and change detection are shared — never forked.\n *\n * Must be rendered under a `CollectionViewProvider` (the value renderers resolve\n * relation titles / asset thumbnails through `useCollectionView`).\n */\nexport type DiffLayout = 'grid' | 'stacked'\nexport interface DocumentDiffRestore {\n baseVersion: number\n canRestore: boolean\n busy: boolean\n onRestore: (scope: RestoreScope) => void\n}\n\nexport interface DocumentDiffViewProps {\n diff: DocumentDiff\n collection: CollectionDef\n /** Pre-rendered column captions (version-specific text stays with the caller). */\n columnHeaders: { unified: string; before: string; after: string }\n /** Per-row restore controls; omitted ⇒ a restore-free read-only diff (AI review). */\n restore?: DocumentDiffRestore\n /** Extra note appended to the change-count summary (e.g. a comparing-past hint). */\n summaryHint?: ReactNode\n /** Presentation variant (EC-382). Defaults to the wide `'grid'` compare layout. */\n layout?: DiffLayout\n}\n\nexport function DocumentDiffView({\n diff,\n collection,\n columnHeaders,\n restore,\n summaryHint,\n layout = 'grid',\n}: DocumentDiffViewProps) {\n const source = useCollectionView()\n\n // EC-317 — the unified/side-by-side toggle is a transient, personal-local view\n // preference: read once at mount, written back on every change.\n const [mode, setModeState] = useState<DiffViewMode>(() => readDiffViewMode())\n const setMode = useCallback((next: DiffViewMode) => {\n setModeState(next)\n storeDiffViewMode(next)\n }, [])\n\n // EC-317 — long-value truncation state: an `expandAll` flag plus per-row overrides.\n const [expandAll, setExpandAll] = useState(false)\n const [expandedRows, setExpandedRows] = useState<ReadonlySet<string>>(() => new Set())\n const toggleExpand = useCallback((id: string) => {\n setExpandedRows((prev) => {\n const next = new Set(prev)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n return next\n })\n }, [])\n const isExpanded = useCallback((id: string) => expandAll || expandedRows.has(id), [expandAll, expandedRows])\n const toggleExpandAll = useCallback(() => {\n setExpandAll((prev) => {\n const next = !prev\n if (!next) setExpandedRows(new Set())\n return next\n })\n }, [])\n const captions = useMemo(\n () => ({ before: columnHeaders.before, after: columnHeaders.after }),\n [columnHeaders.before, columnHeaders.after],\n )\n const diffDisplay = useMemo<DiffDisplayState>(\n () => ({ mode, layout, captions, expandAll, isExpanded, toggleExpand }),\n [mode, layout, captions, expandAll, isExpanded, toggleExpand],\n )\n\n const fieldOrder = useMemo(() => new Map(collection.fields.map((f, i) => [f.name, i])), [collection])\n const fieldByName = useMemo(() => new Map(collection.fields.map((f) => [f.name, f])), [collection])\n const localeRank = useMemo(() => new Map(source.localeConfig.locales.map((l, i) => [l, i])), [source.localeConfig])\n const groups = useMemo(\n () => groupByField(diff.changes, fieldOrder, localeRank),\n [diff.changes, fieldOrder, localeRank],\n )\n const groupRows = useMemo(() => {\n let rowIndex = 0\n return groups.map((group) => {\n const zebraStart = rowIndex\n rowIndex += group.entries.length\n return { group, field: fieldByName.get(group.field), zebraStart }\n })\n }, [groups, fieldByName])\n\n const canRestore = restore?.canRestore ?? false\n const baseVersion = restore?.baseVersion ?? 0\n const busy = restore?.busy ?? false\n const restoreFn = useCallback(\n (scope: RestoreScope) => restore?.onRestore(scope),\n [restore],\n )\n\n const summary = (\n <Text size=\"xs\" tone=\"muted\" className=\"px-0.5\">\n {translate(diff.changes.length === 1 ? 'cms.version.changeSummary.one' : 'cms.version.changeSummary.other', {\n count: diff.changes.length,\n unchanged: diff.unchangedCount,\n })}\n {summaryHint}\n </Text>\n )\n const expandAllButton = (\n <Button variant=\"ghost\" size=\"sm\" onClick={toggleExpandAll}>\n {translate(expandAll ? 'cms.field.collapseAll' : 'cms.field.expandAll')}\n </Button>\n )\n\n // EC-382 — the sidebar-fit variant: no two-column split to toggle, so the\n // unified/side-by-side control is dropped; each field is a full-width card\n // that lays Current → Proposed out vertically.\n if (layout === 'stacked') {\n return (\n <DiffDisplayContext.Provider value={diffDisplay}>\n <Stack gap=\"2\">\n <Row gap=\"2\" align=\"center\" justify=\"between\" wrap className=\"px-0.5\">\n {summary}\n {expandAllButton}\n </Row>\n <Stack gap=\"2\" className=\"pb-1\">\n {groupRows.map(({ group, field }) => (\n <FieldGroup\n key={group.field}\n group={group}\n field={field}\n zebraStart={0}\n baseVersion={baseVersion}\n canRestore={canRestore}\n busy={busy}\n onRestore={restoreFn}\n />\n ))}\n </Stack>\n </Stack>\n </DiffDisplayContext.Provider>\n )\n }\n\n return (\n <>\n {/* EC-317 — the diff-layout toolbar: unified/side-by-side (persisted) + expand-all. */}\n <Row gap=\"2\" align=\"center\" justify=\"between\" wrap className=\"px-0.5\">\n <DiffViewToggle mode={mode} onChange={setMode} />\n {expandAllButton}\n </Row>\n\n {summary}\n\n <DiffDisplayContext.Provider value={diffDisplay}>\n <div className=\"pb-1\">\n <div className={cn(DIFF_ROW_GRID, 'px-2 pb-1.5')}>\n <Text size=\"xs\" tone=\"subtle\" className=\"uppercase tracking-wide\">\n {translate('cms.version.fieldColumnHeader')}\n </Text>\n {mode === 'unified' ? (\n <Text size=\"xs\" tone=\"subtle\" className=\"uppercase tracking-wide\">\n {columnHeaders.unified}\n </Text>\n ) : (\n <TwoCol\n before={\n <Text size=\"xs\" tone=\"subtle\" className=\"uppercase tracking-wide\">\n {columnHeaders.before}\n </Text>\n }\n after={\n <Text size=\"xs\" tone=\"subtle\" className=\"uppercase tracking-wide\">\n {columnHeaders.after}\n </Text>\n }\n />\n )}\n </div>\n {groupRows.map(({ group, field, zebraStart }) => (\n <FieldGroup\n key={group.field}\n group={group}\n field={field}\n zebraStart={zebraStart}\n baseVersion={baseVersion}\n canRestore={canRestore}\n busy={busy}\n onRestore={restoreFn}\n />\n ))}\n </div>\n </DiffDisplayContext.Provider>\n </>\n )\n}\n\n// --- EC-317 diff-display context (mode + truncation) ------------------------------\n\ninterface DiffDisplayState {\n mode: DiffViewMode\n /** EC-382 — the active presentation variant; value renderers branch on it. */\n layout: DiffLayout\n /** EC-382 — the Current/Proposed captions, shown inline per side in `stacked`. */\n captions: { before: string; after: string }\n expandAll: boolean\n isExpanded: (id: string) => boolean\n toggleExpand: (id: string) => void\n}\n\nconst DiffDisplayContext = createContext<DiffDisplayState | null>(null)\n\nfunction useDiffDisplay(): DiffDisplayState {\n const ctx = useContext(DiffDisplayContext)\n if (!ctx) throw new Error('useDiffDisplay must be rendered under the DocumentDiffView diff area')\n return ctx\n}\n\n/** Shared grid template so the descriptor lane + header captions line up. */\nconst DIFF_ROW_GRID = 'grid grid-cols-[7.5rem_1fr_1.75rem] items-start gap-x-4'\n\n/** A before | after grid with a clear central divider. */\nfunction TwoCol({ before, after, className }: { before: ReactNode; after: ReactNode; className?: string }) {\n return (\n <div className={cn('relative grid grid-cols-2 gap-x-8', className)}>\n <div className=\"pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border\" aria-hidden />\n <div className=\"min-w-0 pr-1\">{before}</div>\n <div className=\"min-w-0 pl-1\">{after}</div>\n </div>\n )\n}\n\n/** Mode-aware value display (EC-317) / layout-aware in the EC-382 stacked variant. */\nfunction DiffColumns({ before, after, kind }: { before: ReactNode; after: ReactNode; kind: ChangeKind }) {\n const { mode, layout } = useDiffDisplay()\n if (layout === 'stacked') {\n return <StackedColumns before={before} after={after} kind={kind} />\n }\n if (mode === 'unified') {\n return (\n <Stack gap=\"1\">\n {kind !== 'added' ? <UnifiedLine tone=\"removed\">{before}</UnifiedLine> : null}\n {kind !== 'removed' ? <UnifiedLine tone=\"added\">{after}</UnifiedLine> : null}\n </Stack>\n )\n }\n return <TwoCol before={before} after={after} />\n}\n\n/**\n * EC-382 stacked value display: `Current` above `Proposed`, each captioned and\n * accented, full width — the sidebar-fit answer to the squished two-column split.\n * An `added` change shows only the proposed side; a `removed` change only current.\n */\nfunction StackedColumns({ before, after, kind }: { before: ReactNode; after: ReactNode; kind: ChangeKind }) {\n const { captions } = useDiffDisplay()\n return (\n <Stack gap=\"2\">\n {kind !== 'added' ? (\n <StackedSide caption={captions.before} tone=\"before\">\n {before}\n </StackedSide>\n ) : null}\n {kind !== 'removed' ? (\n <StackedSide caption={captions.after} tone=\"after\">\n {after}\n </StackedSide>\n ) : null}\n </Stack>\n )\n}\n\n/** One captioned side of a stacked change (EC-382). */\nfunction StackedSide({\n caption,\n tone,\n children,\n}: {\n caption: string\n tone: 'before' | 'after'\n children: ReactNode\n}) {\n return (\n <Stack gap=\"1\">\n <Text size=\"xs\" tone=\"subtle\" className=\"uppercase tracking-wide\">\n {caption}\n </Text>\n <div\n className={cn(\n 'min-w-0 border-l-2 pl-2.5',\n tone === 'before' ? 'border-border' : 'border-primary/60',\n )}\n >\n {children}\n </div>\n </Stack>\n )\n}\n\nfunction UnifiedLine({ tone, children }: { tone: 'removed' | 'added'; children: ReactNode }) {\n return (\n <Row\n gap=\"2\"\n align=\"start\"\n className={cn('rounded-sm px-1.5 py-1', tone === 'removed' ? 'bg-destructive/10' : 'bg-success/10')}\n >\n <Text\n size=\"xs\"\n mono\n aria-hidden\n className={cn('mt-0.5 shrink-0 select-none', tone === 'removed' ? 'text-destructive' : 'text-success')}\n >\n {tone === 'removed' ? '−' : '+'}\n </Text>\n <div className=\"min-w-0 flex-1\">{children}</div>\n </Row>\n )\n}\n\n/** Wraps truncatable content with its per-row \"Show more\"/\"Show less\" control. */\nfunction ExpandToggle({\n id,\n isLong,\n expanded,\n children,\n}: {\n id: string\n isLong: boolean\n expanded: boolean\n children: ReactNode\n}) {\n const { expandAll, toggleExpand } = useDiffDisplay()\n return (\n <div>\n {children}\n {isLong && !expandAll ? (\n <Button variant=\"link\" size=\"sm\" className=\"h-auto p-0 text-xs\" onClick={() => toggleExpand(id)}>\n {expanded ? translate('cms.version.showLess') : translate('cms.version.showMore')}\n </Button>\n ) : null}\n </div>\n )\n}\n\n/** The unified/side-by-side segmented toggle (EC-317). */\nfunction DiffViewToggle({ mode, onChange }: { mode: DiffViewMode; onChange: (mode: DiffViewMode) => void }) {\n return (\n <Row\n gap=\"px\"\n className=\"rounded-md bg-muted/50 p-0.5\"\n role=\"group\"\n aria-label={translate('cms.version.viewModeAriaLabel')}\n data-testid=\"diff-view-toggle\"\n >\n <DiffViewOption\n active={mode === 'sideBySide'}\n label={translate('cms.version.viewSideBySide')}\n onClick={() => onChange('sideBySide')}\n />\n <DiffViewOption\n active={mode === 'unified'}\n label={translate('cms.version.viewUnified')}\n onClick={() => onChange('unified')}\n />\n </Row>\n )\n}\n\nfunction DiffViewOption({ active, label, onClick }: { active: boolean; label: string; onClick: () => void }) {\n return (\n <button\n type=\"button\"\n aria-pressed={active}\n data-testid={`diff-view-option-${active ? 'active' : 'inactive'}`}\n onClick={onClick}\n className={cn(\n 'rounded-[5px] px-2.5 py-1 text-xs font-medium transition-colors',\n active ? 'bg-background text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground',\n )}\n >\n {label}\n </button>\n )\n}\n\ninterface FieldGroupData {\n field: string\n label: string\n type: FieldDef['type']\n entries: FieldChange[]\n}\n\n/** One field's diff rows (EC-317 grid rows / EC-382 stacked cards). */\nfunction FieldGroup({\n group,\n field,\n zebraStart,\n baseVersion,\n canRestore,\n busy,\n onRestore,\n}: {\n group: FieldGroupData\n field: FieldDef | undefined\n zebraStart: number\n baseVersion: number\n canRestore: boolean\n busy: boolean\n onRestore: (scope: RestoreScope) => void\n}) {\n const { layout } = useDiffDisplay()\n const label = field ? fieldLabel(field) : group.label\n const rows = group.entries.map((entry, i) => {\n const rowId = `${group.field}:${entry.locale ?? '_'}`\n const fieldRestore =\n canRestore && !entry.blocks ? (\n <RestoreIcon\n busy={busy}\n title={\n entry.locale\n ? translate('cms.version.restoreFieldLocale', {\n field: label,\n locale: localeChipLabel(entry.locale),\n version: baseVersion,\n })\n : translate('cms.version.restoreField', { field: label, version: baseVersion })\n }\n onClick={() => onRestore(fieldScope(entry))}\n />\n ) : null\n const descriptor = (\n <FieldDescriptor label={label} locale={entry.locale} kind={entry.kind} inline={layout === 'stacked'} />\n )\n const body = (\n <EntryBody\n change={entry}\n rowId={rowId}\n baseVersion={baseVersion}\n canRestore={canRestore}\n busy={busy}\n onRestore={onRestore}\n />\n )\n return layout === 'stacked' ? (\n <StackedFieldRow key={entry.locale ?? '__base__'} descriptor={descriptor} restore={fieldRestore}>\n {body}\n </StackedFieldRow>\n ) : (\n <FieldRow\n key={entry.locale ?? '__base__'}\n zebra={(zebraStart + i) % 2 === 1}\n descriptor={descriptor}\n restore={fieldRestore}\n >\n {body}\n </FieldRow>\n )\n })\n if (layout === 'stacked') return <>{rows}</>\n return <div className=\"border-t border-border/30\">{rows}</div>\n}\n\n/** The descriptor lane + value area, one grid row (EC-317). */\nfunction FieldRow({\n descriptor,\n restore,\n zebra,\n children,\n}: {\n descriptor: ReactNode\n restore: ReactNode\n zebra: boolean\n children: ReactNode\n}) {\n return (\n <div className={cn(DIFF_ROW_GRID, 'rounded-sm px-2 py-2.5', zebra && 'bg-muted/40')}>\n <div className=\"min-w-0\">{descriptor}</div>\n <div className=\"min-w-0\">{children}</div>\n <div className=\"flex justify-end\">{restore}</div>\n </div>\n )\n}\n\n/**\n * One field as a full-width card (EC-382 stacked variant): a label header\n * (descriptor + restore) over a full-width value area — no fixed lane to squeeze\n * the value at sidebar width.\n */\nfunction StackedFieldRow({\n descriptor,\n restore,\n children,\n}: {\n descriptor: ReactNode\n restore: ReactNode\n children: ReactNode\n}) {\n return (\n <div className=\"overflow-hidden rounded-lg border border-border/60 bg-card\">\n <Row gap=\"2\" align=\"center\" className=\"border-b border-border/50 bg-muted/30 px-3 py-2\">\n <div className=\"min-w-0 flex-1\">{descriptor}</div>\n {restore}\n </Row>\n <div className=\"px-3 py-2.5\">{children}</div>\n </div>\n )\n}\n\n/** The descriptor content (EC-317 stacked lane / EC-382 inline card header). */\nfunction FieldDescriptor({\n label,\n locale,\n kind,\n inline = false,\n}: {\n label: string\n locale?: string\n kind: ChangeKind\n inline?: boolean\n}) {\n const localeBadge = locale ? (\n <Badge variant=\"outline\" className=\"px-1 py-0 text-[0.6rem] uppercase tracking-wide text-muted-foreground\">\n {localeChipLabel(locale)}\n </Badge>\n ) : null\n if (inline) {\n return (\n <Row gap=\"2\" align=\"center\" wrap className=\"min-w-0\">\n <Text size=\"sm\" weight=\"semibold\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n {localeBadge}\n <KindTag kind={kind} />\n </Row>\n )\n }\n return (\n <Stack gap=\"1\">\n <Text size=\"sm\" weight=\"medium\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n <Row gap=\"1\" wrap>\n {localeBadge}\n <KindTag kind={kind} />\n </Row>\n </Stack>\n )\n}\n\nfunction EntryBody({\n change,\n rowId,\n baseVersion,\n canRestore,\n busy,\n onRestore,\n}: {\n change: FieldChange\n rowId: string\n baseVersion: number\n canRestore: boolean\n busy: boolean\n onRestore: (scope: RestoreScope) => void\n}) {\n const localeScope = change.locale !== undefined ? { locale: change.locale } : {}\n if (change.blocks) {\n return (\n <Stack gap=\"2\" className=\"mt-1\">\n {change.blocks.map((block) => (\n <BlockSection\n key={block.blockId}\n block={block}\n rowId={`${rowId}|block:${block.blockId}`}\n baseVersion={baseVersion}\n canRestore={canRestore}\n busy={busy}\n onRestore={() => onRestore({ kind: 'block', field: change.field, blockId: block.blockId, ...localeScope })}\n />\n ))}\n </Stack>\n )\n }\n if (change.type === 'richText') {\n const before = richTextToText(change.before)\n const after = richTextToText(change.after)\n if (before === after && before) return <MutedNote>{translate('cms.version.textUnchanged')}</MutedNote>\n // Both sides carry text → the word diff pinpoints the edit.\n if (before && after) return <WordDiffCols id={rowId} before={before} after={after} />\n // EC-379: one side is (textually) empty — a create proposal, a cleared body,\n // or structure-only content. Render the ACTUAL prose so the editor reviews\n // what they are approving (retires the blind \"Content changed.\" note).\n return (\n <DiffColumns\n kind={change.kind}\n before={<RichTextSide value={change.before} id={`${rowId}|before`} />}\n after={<RichTextSide value={change.after} id={`${rowId}|after`} />}\n />\n )\n }\n if (change.kind === 'changed' && typeof change.before === 'string' && typeof change.after === 'string') {\n return <WordDiffCols id={rowId} before={change.before} after={change.after} />\n }\n return (\n <DiffColumns\n kind={change.kind}\n before={<SideValue value={change.before} other={change.after} typeHint={change.type} id={`${rowId}|before`} />}\n after={<SideValue value={change.after} other={change.before} typeHint={change.type} id={`${rowId}|after`} />}\n />\n )\n}\n\nfunction BlockSection({\n block,\n rowId,\n baseVersion,\n canRestore,\n busy,\n onRestore,\n}: {\n block: BlockChange\n rowId: string\n baseVersion: number\n canRestore: boolean\n busy: boolean\n onRestore: () => void\n}) {\n const name = block.componentId.split('.').pop() ?? block.componentId\n return (\n <div className=\"overflow-hidden rounded-md border border-border/60\">\n <Row gap=\"2\" align=\"center\" className=\"border-b border-border/50 bg-muted/30 px-2 py-1.5\">\n <Text size=\"xs\" weight=\"semibold\" className=\"min-w-0 truncate\">\n {name}\n </Text>\n <Code tone=\"muted\">{block.componentId}</Code>\n <KindTag kind={block.kind} />\n <Spacer />\n {canRestore ? (\n <RestoreIcon\n busy={busy}\n title={translate('cms.version.restoreBlock', { version: baseVersion })}\n onClick={onRestore}\n />\n ) : null}\n </Row>\n <div className=\"px-2 py-2\">\n {block.props && block.props.length > 0 ? (\n <Stack gap=\"3\" className=\"border-l-2 border-border/50 pl-3\">\n {block.props.map((prop) => (\n <PropRow key={prop.name} prop={prop} rowId={`${rowId}|prop:${prop.name}`} />\n ))}\n </Stack>\n ) : null}\n {block.slotsChanged ? <MutedNote>{translate('cms.version.nestedContentChanged')}</MutedNote> : null}\n {block.kind !== 'changed' && !block.props?.length ? (\n <MutedNote>\n {block.kind === 'added' ? translate('cms.version.blockAdded') : translate('cms.version.blockRemoved')}\n </MutedNote>\n ) : null}\n </div>\n </div>\n )\n}\n\nfunction PropRow({ prop, rowId }: { prop: PropChange; rowId: string }) {\n const useWordDiff = prop.kind === 'changed' && typeof prop.before === 'string' && typeof prop.after === 'string'\n return (\n <div>\n <Text size=\"xs\" tone=\"subtle\" className=\"mb-0.5 block uppercase tracking-wide\">\n {prettyName(prop.name)}\n </Text>\n {useWordDiff ? (\n <WordDiffCols id={rowId} before={String(prop.before)} after={String(prop.after)} />\n ) : (\n <DiffColumns\n kind={prop.kind}\n before={<SideValue value={prop.before} other={prop.after} id={`${rowId}|before`} />}\n after={<SideValue value={prop.after} other={prop.before} id={`${rowId}|after`} />}\n />\n )}\n </div>\n )\n}\n\n/**\n * One side of a rich-text change (EC-379): rendered compact prose\n * ({@link RichTextPreview}), height-clamped behind the shared expand toggle for\n * long bodies, with the standard \"empty\" placeholder for an absent side.\n */\nfunction RichTextSide({ value, id }: { value: unknown; id: string }) {\n const { isExpanded } = useDiffDisplay()\n if (isRichTextValueEmpty(value)) {\n return (\n <Text size=\"sm\" tone=\"subtle\" className=\"italic\">\n {translate('cms.version.emptyValue')}\n </Text>\n )\n }\n const expanded = isExpanded(id)\n const isLong = richTextToText(value).length > DIFF_TRUNCATE_THRESHOLD\n return (\n <ExpandToggle id={id} isLong={isLong} expanded={expanded}>\n <div className={cn(!expanded && isLong && 'max-h-60 overflow-hidden')}>\n <RichTextPreview value={value} />\n </div>\n </ExpandToggle>\n )\n}\n\n/** One side of a non-text change — the value, or an \"empty\" placeholder. */\nfunction SideValue({\n value,\n other,\n typeHint,\n id,\n}: {\n value: unknown\n other?: unknown\n typeHint?: FieldDef['type']\n id: string\n}) {\n if (value === undefined || value === null || value === '') {\n return (\n <Text size=\"sm\" tone=\"subtle\" className=\"italic\">\n {translate('cms.version.emptyValue')}\n </Text>\n )\n }\n return <ValueView value={value} other={other} typeHint={typeHint} id={id} />\n}\n\n/** Read-only value display, dispatching on field type / self-describing value shape. */\nfunction ValueView({\n value,\n other,\n typeHint,\n id,\n}: {\n value: unknown\n other?: unknown\n typeHint?: FieldDef['type']\n id: string\n}) {\n const { isExpanded } = useDiffDisplay()\n if (typeHint === 'asset' || isAssetNode(value)) return <AssetValue value={value} />\n if (typeHint === 'relation' || readDocumentRef(value)) return <RelationValue value={value} other={other} />\n if (typeHint === 'richText')\n return (\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words\">\n {richTextToText(value) || translate('cms.version.richText')}\n </Text>\n )\n if (typeHint === 'boolean' || typeof value === 'boolean')\n return (\n <Text size=\"sm\" mono>\n {value === true ? translate('common.yes') : translate('common.no')}\n </Text>\n )\n if (typeHint === 'date')\n return (\n <Text size=\"sm\" mono>\n {String(value).slice(0, 10)}\n </Text>\n )\n if (typeof value === 'object')\n return (\n <Text size=\"sm\" tone=\"muted\">\n {Array.isArray(value)\n ? translate(value.length === 1 ? 'cms.version.itemCount.one' : 'cms.version.itemCount.other', {\n count: value.length,\n })\n : translate('cms.version.objectValue')}\n </Text>\n )\n const expanded = isExpanded(id)\n const { shown, isLong } = truncateText(String(value), expanded)\n return (\n <ExpandToggle id={id} isLong={isLong} expanded={expanded}>\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words\">\n {shown}\n </Text>\n </ExpandToggle>\n )\n}\n\nfunction RelationValue({ value, other }: { value: unknown; other?: unknown }) {\n const source = useCollectionView()\n const refs = toRefArray(value)\n if (refs.length === 0)\n return (\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words\">\n {String(value)}\n </Text>\n )\n const otherRefs = other !== undefined ? toRefArray(other) : []\n const label = refs\n .map((ref) => {\n const title = source.titleOf(ref)\n const collision = otherRefs.some((o) => o.id !== ref.id && source.titleOf(o) === title)\n return collision ? `${title} · ${ref.id}` : title\n })\n .join(', ')\n return <Text size=\"sm\">{label}</Text>\n}\n\n/** Asset-record-owned keys — resolved off the asset RECORD at render, not authored. */\nconst ASSET_RECORD_KEYS = new Set<string>([\n 'url', 'alt', 'width', 'height', 'focalPoint', 'contentType', 'mimeType',\n 'byteSize', 'storageKey', 'title', 'filename', 'meta', 'createdAt', 'updatedAt',\n])\n\nfunction authoredAssetSubfields(value: unknown): [string, unknown][] {\n return Object.entries(assetSubfieldsOf(value)).filter(([key]) => !ASSET_RECORD_KEYS.has(key))\n}\n\nfunction AssetValue({ value }: { value: unknown }) {\n const items = (Array.isArray(value) ? value : [value])\n .map((entry) => ({ id: readAssetId(entry), sub: authoredAssetSubfields(entry) }))\n .filter((a): a is { id: string; sub: [string, unknown][] } => a.id !== undefined)\n if (items.length === 0)\n return (\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words\">\n {String(value)}\n </Text>\n )\n return (\n <div className=\"flex flex-wrap gap-2\">\n {items.map(({ id, sub }, i) => (\n <div key={`${id}-${i}`} className=\"flex flex-col gap-1\">\n <AssetThumb id={id} />\n {sub.length > 0 ? (\n <Stack gap=\"1\" className=\"pl-0.5\">\n {sub.map(([key, val]) => (\n <Text key={key} size=\"xs\" tone=\"muted\" className=\"break-words\">\n <span className=\"uppercase tracking-wide text-muted-foreground/70\">{prettyName(key)}:</span>{' '}\n {typeof val === 'object' && val !== null\n ? translate('cms.version.objectValue')\n : String(val)}\n </Text>\n ))}\n </Stack>\n ) : null}\n </div>\n ))}\n </div>\n )\n}\n\n/** An asset as a thumbnail (image with a resolvable URL) or a labelled badge. */\nfunction AssetThumb({ id }: { id: string }) {\n const source = useCollectionView()\n const assetCollectionId = source.assetCollectionId ?? 'asset'\n const record = source.resolveAsset?.(id)\n const label = record?.title ?? record?.filename ?? source.titleOf({ collection: assetCollectionId, id })\n const isImage = record?.contentType?.startsWith('image/') ?? false\n const url = record?.url\n if (isImage && url && url.startsWith('http')) {\n return (\n <span className=\"inline-flex min-w-0 items-center gap-2\">\n <img\n src={url}\n alt={record?.alt ?? label}\n loading=\"lazy\"\n className=\"size-12 shrink-0 rounded border border-border bg-muted object-cover\"\n />\n <Text size=\"xs\" tone=\"muted\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n </span>\n )\n }\n return (\n <Badge variant=\"outline\">\n <ImageIcon className=\"size-3\" /> {label}\n </Badge>\n )\n}\n\n// --- Prose word diff --------------------------------------------------------------\n\nconst isWordTokenChanged = (token: WordToken) => token.changed\nconst isMergedTokenChanged = (token: MergedDiffToken) => token.kind !== 'same'\n\nfunction WordDiffCols({ id, before, after }: { id: string; before: string; after: string }) {\n const { mode, layout, isExpanded, captions } = useDiffDisplay()\n const expanded = isExpanded(id)\n const wd = useMemo(() => wordDiff(before, after), [before, after])\n const merged = useMemo(() => mergeWordDiff(wd.before, wd.after), [wd])\n\n // EC-382: change-anchored truncation — the collapsed excerpt centers on the\n // FIRST edit (the EC-379 finding: an edit past the head threshold could hide\n // behind \"Show more\"). Applies to every layout/mode; only the arrangement varies.\n const beforeSlice = truncateTokensAroundChange(wd.before, expanded, isWordTokenChanged)\n const afterSlice = truncateTokensAroundChange(wd.after, expanded, isWordTokenChanged)\n\n if (layout === 'stacked') {\n const isLong = beforeSlice.isLong || afterSlice.isLong\n return (\n <ExpandToggle id={id} isLong={isLong} expanded={expanded}>\n <Stack gap=\"2\">\n <StackedSide caption={captions.before} tone=\"before\">\n <WordTokens excerpt={beforeSlice} side=\"before\" />\n </StackedSide>\n <StackedSide caption={captions.after} tone=\"after\">\n <WordTokens excerpt={afterSlice} side=\"after\" />\n </StackedSide>\n </Stack>\n </ExpandToggle>\n )\n }\n\n if (mode === 'unified') {\n const mergedSlice = truncateTokensAroundChange(merged, expanded, isMergedTokenChanged)\n return (\n <ExpandToggle id={id} isLong={mergedSlice.isLong} expanded={expanded}>\n <UnifiedWordTokens excerpt={mergedSlice} />\n </ExpandToggle>\n )\n }\n\n const isLong = beforeSlice.isLong || afterSlice.isLong\n return (\n <ExpandToggle id={id} isLong={isLong} expanded={expanded}>\n <TwoCol\n before={<WordTokens excerpt={beforeSlice} side=\"before\" />}\n after={<WordTokens excerpt={afterSlice} side=\"after\" />}\n />\n </ExpandToggle>\n )\n}\n\n/** A \"…\" standing in for the hidden context an anchored excerpt trimmed (EC-382). */\nfunction EllipsisMark() {\n return (\n <span aria-hidden className=\"select-none text-muted-foreground/60\">\n …{' '}\n </span>\n )\n}\n\nfunction WordTokens({ excerpt, side }: { excerpt: AnchoredExcerpt<WordToken>; side: 'before' | 'after' }) {\n return (\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words leading-relaxed\">\n {excerpt.leadingEllipsis ? <EllipsisMark /> : null}\n {excerpt.shown.map((token, i) =>\n token.changed ? (\n <mark\n key={i}\n className={cn(\n 'rounded-sm px-0.5',\n side === 'before'\n ? 'bg-destructive/15 text-destructive line-through decoration-destructive/40'\n : 'bg-success/20 text-foreground',\n )}\n >\n {token.text}\n </mark>\n ) : (\n <span key={i} className=\"text-muted-foreground\">\n {token.text}\n </span>\n ),\n )}\n {excerpt.trailingEllipsis ? <EllipsisMark /> : null}\n </Text>\n )\n}\n\nfunction UnifiedWordTokens({ excerpt }: { excerpt: AnchoredExcerpt<MergedDiffToken> }) {\n return (\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words leading-relaxed\">\n {excerpt.leadingEllipsis ? <EllipsisMark /> : null}\n {excerpt.shown.map((token, i) =>\n token.kind === 'same' ? (\n <span key={i} className=\"text-muted-foreground\">\n {token.text}\n </span>\n ) : (\n <mark\n key={i}\n className={cn(\n 'rounded-sm px-0.5',\n token.kind === 'removed'\n ? 'bg-destructive/15 text-destructive line-through decoration-destructive/40'\n : 'bg-success/20 text-foreground',\n )}\n >\n {token.text}\n </mark>\n ),\n )}\n {excerpt.trailingEllipsis ? <EllipsisMark /> : null}\n </Text>\n )\n}\n\n// --- Small shared bits ------------------------------------------------------------\n\nfunction KindTag({ kind }: { kind: FieldChange['kind'] }) {\n if (kind === 'changed') return null\n return (\n <Text size=\"xs\" tone=\"subtle\">\n · {kind === 'added' ? translate('cms.version.kindNew') : translate('cms.version.kindRemoved')}\n </Text>\n )\n}\n\nfunction RestoreIcon({ busy, title, onClick }: { busy: boolean; title: string; onClick: () => void }) {\n return (\n <Button variant=\"ghost\" size=\"icon-sm\" disabled={busy} title={title} aria-label={title} onClick={onClick}>\n <RotateCcw />\n </Button>\n )\n}\n\nfunction MutedNote({ children }: { children: ReactNode }) {\n return (\n <Text size=\"sm\" tone=\"muted\" className=\"italic\">\n {children}\n </Text>\n )\n}\n\nfunction fieldScope(change: FieldChange): RestoreScope {\n return { kind: 'field', field: change.field, ...(change.locale !== undefined ? { locale: change.locale } : {}) }\n}\n\n/** Group changes BY FIELD (a localized field's per-locale variants together). */\nfunction groupByField(\n changes: FieldChange[],\n fieldOrder: Map<string, number>,\n localeRank: Map<string, number>,\n): FieldGroupData[] {\n const map = new Map<string, FieldGroupData>()\n for (const change of changes) {\n let group = map.get(change.field)\n if (!group) {\n group = { field: change.field, label: change.label, type: change.type, entries: [] }\n map.set(change.field, group)\n }\n group.entries.push(change)\n }\n const groups = [...map.values()]\n groups.sort(\n (a, b) =>\n (fieldOrder.get(a.field) ?? Number.MAX_SAFE_INTEGER) - (fieldOrder.get(b.field) ?? Number.MAX_SAFE_INTEGER),\n )\n for (const group of groups) {\n group.entries.sort((a, b) => localeCompare(a.locale, b.locale, localeRank))\n }\n return groups\n}\n\nfunction localeCompare(a: string | undefined, b: string | undefined, rank: Map<string, number>): number {\n if (a === b) return 0\n if (a === undefined) return -1\n if (b === undefined) return 1\n return (rank.get(a) ?? 99) - (rank.get(b) ?? 99)\n}\n\n/** camelCase / snake prop name → a readable label. */\nfunction prettyName(name: string): string {\n const spaced = name.replace(/[_-]+/g, ' ').replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n return spaced.charAt(0).toUpperCase() + spaced.slice(1)\n}\n"]}
1
+ {"version":3,"file":"document-diff-view.js","sourceRoot":"","sources":["../../../src/components/cms/document-diff-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEjF,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAEtG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAEhG,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC3E,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,0BAA0B,EAC1B,QAAQ,GACT,MAAM,wBAAwB,CAAA;AAiD/B,MAAM,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AAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACzD,CAAC","sourcesContent":["import { createContext, useCallback, useContext, useMemo, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport { Image as ImageIcon, RotateCcw } from 'lucide-react'\nimport type { BlockChange, ChangeKind, DocumentDiff, FieldChange, PropChange } from '@elytracms/core/content'\nimport { assetSubfieldsOf, isAssetNode, readAssetId, readDocumentRef } from '@elytracms/core/cms-core'\nimport type { CollectionDef, FieldDef, RestoreScope } from '@elytracms/core/cms-core'\nimport { Badge, Button, Code, Row, Spacer, Stack, Text } from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { localeChipLabel } from '@elytracms/studio/lib/locale'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { readDiffViewMode, storeDiffViewMode } from '@elytracms/studio/lib/diff-view-preference'\nimport type { DiffViewMode } from '@elytracms/studio/lib/diff-view-preference'\nimport { isDisplayableAssetUrl } from '@elytracms/studio/lib/assets'\nimport { useCollectionView } from '../collection-view/collection-view-context'\nimport { fieldLabel } from './cms-labels'\nimport { toRefArray } from './cell'\nimport { RichTextPreview, isRichTextValueEmpty } from './rich-text-preview'\nimport {\n DIFF_TRUNCATE_THRESHOLD,\n mergeWordDiff,\n richTextToText,\n truncateText,\n truncateTokensAroundChange,\n wordDiff,\n} from './version-compare-text'\nimport type { AnchoredExcerpt, MergedDiffToken, WordToken } from './version-compare-text'\n\n/**\n * The shared document-diff RENDERER (EC-317 change-list), extracted from\n * `VersionCompare` so a single renderer serves both the version-compare surface and\n * the EC-199 AI proposal review — never two diff renderers. It draws a `DocumentDiff`\n * ({@link diffDocuments}) as the calm change-list grouped BY FIELD: a descriptor lane,\n * before | after (or a unified lane), text as a prose diff, assets as thumbnails,\n * relations as titles, long values collapsed behind \"Show more\", zebra rows.\n *\n * It is display-only over an already-computed diff: the version chrome (version\n * pickers / steppers / restore-whole) stays in `VersionCompare`; the AI proposal card\n * feeds `diffDocuments(collection, emptyBefore, proposedAfter)` and omits `restore`.\n * The per-row restore affordance renders only when `restore.canRestore` is set, so the\n * AI review (a not-yet-saved proposal) shows a clean, restore-free diff.\n *\n * **Layout (EC-382).** One diff LOGIC, two presentations selected by `layout`:\n * `'grid'` (default) is the wide version-compare surface — a fixed descriptor lane\n * plus a unified/side-by-side value area. `'stacked'` is the sidebar-fit variant the\n * AI proposal card selects: each field is a full-width card (label header, then\n * `Current → Proposed` VERTICALLY) that reads at ~320px without a squished two-column\n * split. Only chrome + column arrangement branch on `layout`; grouping, word diffing,\n * and change detection are shared — never forked.\n *\n * Must be rendered under a `CollectionViewProvider` (the value renderers resolve\n * relation titles / asset thumbnails through `useCollectionView`).\n */\nexport type DiffLayout = 'grid' | 'stacked'\nexport interface DocumentDiffRestore {\n baseVersion: number\n canRestore: boolean\n busy: boolean\n onRestore: (scope: RestoreScope) => void\n}\n\nexport interface DocumentDiffViewProps {\n diff: DocumentDiff\n collection: CollectionDef\n /** Pre-rendered column captions (version-specific text stays with the caller). */\n columnHeaders: { unified: string; before: string; after: string }\n /** Per-row restore controls; omitted ⇒ a restore-free read-only diff (AI review). */\n restore?: DocumentDiffRestore\n /** Extra note appended to the change-count summary (e.g. a comparing-past hint). */\n summaryHint?: ReactNode\n /** Presentation variant (EC-382). Defaults to the wide `'grid'` compare layout. */\n layout?: DiffLayout\n}\n\nexport function DocumentDiffView({\n diff,\n collection,\n columnHeaders,\n restore,\n summaryHint,\n layout = 'grid',\n}: DocumentDiffViewProps) {\n const source = useCollectionView()\n\n // EC-317 — the unified/side-by-side toggle is a transient, personal-local view\n // preference: read once at mount, written back on every change.\n const [mode, setModeState] = useState<DiffViewMode>(() => readDiffViewMode())\n const setMode = useCallback((next: DiffViewMode) => {\n setModeState(next)\n storeDiffViewMode(next)\n }, [])\n\n // EC-317 — long-value truncation state: an `expandAll` flag plus per-row overrides.\n const [expandAll, setExpandAll] = useState(false)\n const [expandedRows, setExpandedRows] = useState<ReadonlySet<string>>(() => new Set())\n const toggleExpand = useCallback((id: string) => {\n setExpandedRows((prev) => {\n const next = new Set(prev)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n return next\n })\n }, [])\n const isExpanded = useCallback((id: string) => expandAll || expandedRows.has(id), [expandAll, expandedRows])\n const toggleExpandAll = useCallback(() => {\n setExpandAll((prev) => {\n const next = !prev\n if (!next) setExpandedRows(new Set())\n return next\n })\n }, [])\n const captions = useMemo(\n () => ({ before: columnHeaders.before, after: columnHeaders.after }),\n [columnHeaders.before, columnHeaders.after],\n )\n const diffDisplay = useMemo<DiffDisplayState>(\n () => ({ mode, layout, captions, expandAll, isExpanded, toggleExpand }),\n [mode, layout, captions, expandAll, isExpanded, toggleExpand],\n )\n\n const fieldOrder = useMemo(() => new Map(collection.fields.map((f, i) => [f.name, i])), [collection])\n const fieldByName = useMemo(() => new Map(collection.fields.map((f) => [f.name, f])), [collection])\n const localeRank = useMemo(() => new Map(source.localeConfig.locales.map((l, i) => [l, i])), [source.localeConfig])\n const groups = useMemo(\n () => groupByField(diff.changes, fieldOrder, localeRank),\n [diff.changes, fieldOrder, localeRank],\n )\n const groupRows = useMemo(() => {\n let rowIndex = 0\n return groups.map((group) => {\n const zebraStart = rowIndex\n rowIndex += group.entries.length\n return { group, field: fieldByName.get(group.field), zebraStart }\n })\n }, [groups, fieldByName])\n\n const canRestore = restore?.canRestore ?? false\n const baseVersion = restore?.baseVersion ?? 0\n const busy = restore?.busy ?? false\n const restoreFn = useCallback(\n (scope: RestoreScope) => restore?.onRestore(scope),\n [restore],\n )\n\n const summary = (\n <Text size=\"xs\" tone=\"muted\" className=\"px-0.5\">\n {translate(diff.changes.length === 1 ? 'cms.version.changeSummary.one' : 'cms.version.changeSummary.other', {\n count: diff.changes.length,\n unchanged: diff.unchangedCount,\n })}\n {summaryHint}\n </Text>\n )\n const expandAllButton = (\n <Button variant=\"ghost\" size=\"sm\" onClick={toggleExpandAll}>\n {translate(expandAll ? 'cms.field.collapseAll' : 'cms.field.expandAll')}\n </Button>\n )\n\n // EC-382 — the sidebar-fit variant: no two-column split to toggle, so the\n // unified/side-by-side control is dropped; each field is a full-width card\n // that lays Current → Proposed out vertically.\n if (layout === 'stacked') {\n return (\n <DiffDisplayContext.Provider value={diffDisplay}>\n <Stack gap=\"2\">\n <Row gap=\"2\" align=\"center\" justify=\"between\" wrap className=\"px-0.5\">\n {summary}\n {expandAllButton}\n </Row>\n <Stack gap=\"2\" className=\"pb-1\">\n {groupRows.map(({ group, field }) => (\n <FieldGroup\n key={group.field}\n group={group}\n field={field}\n zebraStart={0}\n baseVersion={baseVersion}\n canRestore={canRestore}\n busy={busy}\n onRestore={restoreFn}\n />\n ))}\n </Stack>\n </Stack>\n </DiffDisplayContext.Provider>\n )\n }\n\n return (\n <>\n {/* EC-317 — the diff-layout toolbar: unified/side-by-side (persisted) + expand-all. */}\n <Row gap=\"2\" align=\"center\" justify=\"between\" wrap className=\"px-0.5\">\n <DiffViewToggle mode={mode} onChange={setMode} />\n {expandAllButton}\n </Row>\n\n {summary}\n\n <DiffDisplayContext.Provider value={diffDisplay}>\n <div className=\"pb-1\">\n <div className={cn(DIFF_ROW_GRID, 'px-2 pb-1.5')}>\n <Text size=\"xs\" tone=\"subtle\" className=\"uppercase tracking-wide\">\n {translate('cms.version.fieldColumnHeader')}\n </Text>\n {mode === 'unified' ? (\n <Text size=\"xs\" tone=\"subtle\" className=\"uppercase tracking-wide\">\n {columnHeaders.unified}\n </Text>\n ) : (\n <TwoCol\n before={\n <Text size=\"xs\" tone=\"subtle\" className=\"uppercase tracking-wide\">\n {columnHeaders.before}\n </Text>\n }\n after={\n <Text size=\"xs\" tone=\"subtle\" className=\"uppercase tracking-wide\">\n {columnHeaders.after}\n </Text>\n }\n />\n )}\n </div>\n {groupRows.map(({ group, field, zebraStart }) => (\n <FieldGroup\n key={group.field}\n group={group}\n field={field}\n zebraStart={zebraStart}\n baseVersion={baseVersion}\n canRestore={canRestore}\n busy={busy}\n onRestore={restoreFn}\n />\n ))}\n </div>\n </DiffDisplayContext.Provider>\n </>\n )\n}\n\n// --- EC-317 diff-display context (mode + truncation) ------------------------------\n\ninterface DiffDisplayState {\n mode: DiffViewMode\n /** EC-382 — the active presentation variant; value renderers branch on it. */\n layout: DiffLayout\n /** EC-382 — the Current/Proposed captions, shown inline per side in `stacked`. */\n captions: { before: string; after: string }\n expandAll: boolean\n isExpanded: (id: string) => boolean\n toggleExpand: (id: string) => void\n}\n\nconst DiffDisplayContext = createContext<DiffDisplayState | null>(null)\n\nfunction useDiffDisplay(): DiffDisplayState {\n const ctx = useContext(DiffDisplayContext)\n if (!ctx) throw new Error('useDiffDisplay must be rendered under the DocumentDiffView diff area')\n return ctx\n}\n\n/** Shared grid template so the descriptor lane + header captions line up. */\nconst DIFF_ROW_GRID = 'grid grid-cols-[7.5rem_1fr_1.75rem] items-start gap-x-4'\n\n/** A before | after grid with a clear central divider. */\nfunction TwoCol({ before, after, className }: { before: ReactNode; after: ReactNode; className?: string }) {\n return (\n <div className={cn('relative grid grid-cols-2 gap-x-8', className)}>\n <div className=\"pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border\" aria-hidden />\n <div className=\"min-w-0 pr-1\">{before}</div>\n <div className=\"min-w-0 pl-1\">{after}</div>\n </div>\n )\n}\n\n/** Mode-aware value display (EC-317) / layout-aware in the EC-382 stacked variant. */\nfunction DiffColumns({ before, after, kind }: { before: ReactNode; after: ReactNode; kind: ChangeKind }) {\n const { mode, layout } = useDiffDisplay()\n if (layout === 'stacked') {\n return <StackedColumns before={before} after={after} kind={kind} />\n }\n if (mode === 'unified') {\n return (\n <Stack gap=\"1\">\n {kind !== 'added' ? <UnifiedLine tone=\"removed\">{before}</UnifiedLine> : null}\n {kind !== 'removed' ? <UnifiedLine tone=\"added\">{after}</UnifiedLine> : null}\n </Stack>\n )\n }\n return <TwoCol before={before} after={after} />\n}\n\n/**\n * EC-382 stacked value display: `Current` above `Proposed`, each captioned and\n * accented, full width — the sidebar-fit answer to the squished two-column split.\n * An `added` change shows only the proposed side; a `removed` change only current.\n */\nfunction StackedColumns({ before, after, kind }: { before: ReactNode; after: ReactNode; kind: ChangeKind }) {\n const { captions } = useDiffDisplay()\n return (\n <Stack gap=\"2\">\n {kind !== 'added' ? (\n <StackedSide caption={captions.before} tone=\"before\">\n {before}\n </StackedSide>\n ) : null}\n {kind !== 'removed' ? (\n <StackedSide caption={captions.after} tone=\"after\">\n {after}\n </StackedSide>\n ) : null}\n </Stack>\n )\n}\n\n/** One captioned side of a stacked change (EC-382). */\nfunction StackedSide({\n caption,\n tone,\n children,\n}: {\n caption: string\n tone: 'before' | 'after'\n children: ReactNode\n}) {\n return (\n <Stack gap=\"1\">\n <Text size=\"xs\" tone=\"subtle\" className=\"uppercase tracking-wide\">\n {caption}\n </Text>\n <div\n className={cn(\n 'min-w-0 border-l-2 pl-2.5',\n tone === 'before' ? 'border-border' : 'border-primary/60',\n )}\n >\n {children}\n </div>\n </Stack>\n )\n}\n\nfunction UnifiedLine({ tone, children }: { tone: 'removed' | 'added'; children: ReactNode }) {\n return (\n <Row\n gap=\"2\"\n align=\"start\"\n className={cn('rounded-sm px-1.5 py-1', tone === 'removed' ? 'bg-destructive/10' : 'bg-success/10')}\n >\n <Text\n size=\"xs\"\n mono\n aria-hidden\n className={cn('mt-0.5 shrink-0 select-none', tone === 'removed' ? 'text-destructive' : 'text-success')}\n >\n {tone === 'removed' ? '−' : '+'}\n </Text>\n <div className=\"min-w-0 flex-1\">{children}</div>\n </Row>\n )\n}\n\n/** Wraps truncatable content with its per-row \"Show more\"/\"Show less\" control. */\nfunction ExpandToggle({\n id,\n isLong,\n expanded,\n children,\n}: {\n id: string\n isLong: boolean\n expanded: boolean\n children: ReactNode\n}) {\n const { expandAll, toggleExpand } = useDiffDisplay()\n return (\n <div>\n {children}\n {isLong && !expandAll ? (\n <Button variant=\"link\" size=\"sm\" className=\"h-auto p-0 text-xs\" onClick={() => toggleExpand(id)}>\n {expanded ? translate('cms.version.showLess') : translate('cms.version.showMore')}\n </Button>\n ) : null}\n </div>\n )\n}\n\n/** The unified/side-by-side segmented toggle (EC-317). */\nfunction DiffViewToggle({ mode, onChange }: { mode: DiffViewMode; onChange: (mode: DiffViewMode) => void }) {\n return (\n <Row\n gap=\"px\"\n className=\"rounded-md bg-muted/50 p-0.5\"\n role=\"group\"\n aria-label={translate('cms.version.viewModeAriaLabel')}\n data-testid=\"diff-view-toggle\"\n >\n <DiffViewOption\n active={mode === 'sideBySide'}\n label={translate('cms.version.viewSideBySide')}\n onClick={() => onChange('sideBySide')}\n />\n <DiffViewOption\n active={mode === 'unified'}\n label={translate('cms.version.viewUnified')}\n onClick={() => onChange('unified')}\n />\n </Row>\n )\n}\n\nfunction DiffViewOption({ active, label, onClick }: { active: boolean; label: string; onClick: () => void }) {\n return (\n <button\n type=\"button\"\n aria-pressed={active}\n data-testid={`diff-view-option-${active ? 'active' : 'inactive'}`}\n onClick={onClick}\n className={cn(\n 'rounded-[5px] px-2.5 py-1 text-xs font-medium transition-colors',\n active ? 'bg-background text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground',\n )}\n >\n {label}\n </button>\n )\n}\n\ninterface FieldGroupData {\n field: string\n label: string\n type: FieldDef['type']\n entries: FieldChange[]\n}\n\n/** One field's diff rows (EC-317 grid rows / EC-382 stacked cards). */\nfunction FieldGroup({\n group,\n field,\n zebraStart,\n baseVersion,\n canRestore,\n busy,\n onRestore,\n}: {\n group: FieldGroupData\n field: FieldDef | undefined\n zebraStart: number\n baseVersion: number\n canRestore: boolean\n busy: boolean\n onRestore: (scope: RestoreScope) => void\n}) {\n const { layout } = useDiffDisplay()\n const label = field ? fieldLabel(field) : group.label\n const rows = group.entries.map((entry, i) => {\n const rowId = `${group.field}:${entry.locale ?? '_'}`\n const fieldRestore =\n canRestore && !entry.blocks ? (\n <RestoreIcon\n busy={busy}\n title={\n entry.locale\n ? translate('cms.version.restoreFieldLocale', {\n field: label,\n locale: localeChipLabel(entry.locale),\n version: baseVersion,\n })\n : translate('cms.version.restoreField', { field: label, version: baseVersion })\n }\n onClick={() => onRestore(fieldScope(entry))}\n />\n ) : null\n const descriptor = (\n <FieldDescriptor label={label} locale={entry.locale} kind={entry.kind} inline={layout === 'stacked'} />\n )\n const body = (\n <EntryBody\n change={entry}\n rowId={rowId}\n baseVersion={baseVersion}\n canRestore={canRestore}\n busy={busy}\n onRestore={onRestore}\n />\n )\n return layout === 'stacked' ? (\n <StackedFieldRow key={entry.locale ?? '__base__'} descriptor={descriptor} restore={fieldRestore}>\n {body}\n </StackedFieldRow>\n ) : (\n <FieldRow\n key={entry.locale ?? '__base__'}\n zebra={(zebraStart + i) % 2 === 1}\n descriptor={descriptor}\n restore={fieldRestore}\n >\n {body}\n </FieldRow>\n )\n })\n if (layout === 'stacked') return <>{rows}</>\n return <div className=\"border-t border-border/30\">{rows}</div>\n}\n\n/** The descriptor lane + value area, one grid row (EC-317). */\nfunction FieldRow({\n descriptor,\n restore,\n zebra,\n children,\n}: {\n descriptor: ReactNode\n restore: ReactNode\n zebra: boolean\n children: ReactNode\n}) {\n return (\n <div className={cn(DIFF_ROW_GRID, 'rounded-sm px-2 py-2.5', zebra && 'bg-muted/40')}>\n <div className=\"min-w-0\">{descriptor}</div>\n <div className=\"min-w-0\">{children}</div>\n <div className=\"flex justify-end\">{restore}</div>\n </div>\n )\n}\n\n/**\n * One field as a full-width card (EC-382 stacked variant): a label header\n * (descriptor + restore) over a full-width value area — no fixed lane to squeeze\n * the value at sidebar width.\n */\nfunction StackedFieldRow({\n descriptor,\n restore,\n children,\n}: {\n descriptor: ReactNode\n restore: ReactNode\n children: ReactNode\n}) {\n return (\n <div className=\"overflow-hidden rounded-lg border border-border/60 bg-card\">\n <Row gap=\"2\" align=\"center\" className=\"border-b border-border/50 bg-muted/30 px-3 py-2\">\n <div className=\"min-w-0 flex-1\">{descriptor}</div>\n {restore}\n </Row>\n <div className=\"px-3 py-2.5\">{children}</div>\n </div>\n )\n}\n\n/** The descriptor content (EC-317 stacked lane / EC-382 inline card header). */\nfunction FieldDescriptor({\n label,\n locale,\n kind,\n inline = false,\n}: {\n label: string\n locale?: string\n kind: ChangeKind\n inline?: boolean\n}) {\n const localeBadge = locale ? (\n <Badge variant=\"outline\" className=\"px-1 py-0 text-[0.6rem] uppercase tracking-wide text-muted-foreground\">\n {localeChipLabel(locale)}\n </Badge>\n ) : null\n if (inline) {\n return (\n <Row gap=\"2\" align=\"center\" wrap className=\"min-w-0\">\n <Text size=\"sm\" weight=\"semibold\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n {localeBadge}\n <KindTag kind={kind} />\n </Row>\n )\n }\n return (\n <Stack gap=\"1\">\n <Text size=\"sm\" weight=\"medium\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n <Row gap=\"1\" wrap>\n {localeBadge}\n <KindTag kind={kind} />\n </Row>\n </Stack>\n )\n}\n\nfunction EntryBody({\n change,\n rowId,\n baseVersion,\n canRestore,\n busy,\n onRestore,\n}: {\n change: FieldChange\n rowId: string\n baseVersion: number\n canRestore: boolean\n busy: boolean\n onRestore: (scope: RestoreScope) => void\n}) {\n const localeScope = change.locale !== undefined ? { locale: change.locale } : {}\n if (change.blocks) {\n return (\n <Stack gap=\"2\" className=\"mt-1\">\n {change.blocks.map((block) => (\n <BlockSection\n key={block.blockId}\n block={block}\n rowId={`${rowId}|block:${block.blockId}`}\n baseVersion={baseVersion}\n canRestore={canRestore}\n busy={busy}\n onRestore={() => onRestore({ kind: 'block', field: change.field, blockId: block.blockId, ...localeScope })}\n />\n ))}\n </Stack>\n )\n }\n if (change.type === 'richText') {\n const before = richTextToText(change.before)\n const after = richTextToText(change.after)\n if (before === after && before) return <MutedNote>{translate('cms.version.textUnchanged')}</MutedNote>\n // Both sides carry text → the word diff pinpoints the edit.\n if (before && after) return <WordDiffCols id={rowId} before={before} after={after} />\n // EC-379: one side is (textually) empty — a create proposal, a cleared body,\n // or structure-only content. Render the ACTUAL prose so the editor reviews\n // what they are approving (retires the blind \"Content changed.\" note).\n return (\n <DiffColumns\n kind={change.kind}\n before={<RichTextSide value={change.before} id={`${rowId}|before`} />}\n after={<RichTextSide value={change.after} id={`${rowId}|after`} />}\n />\n )\n }\n if (change.kind === 'changed' && typeof change.before === 'string' && typeof change.after === 'string') {\n return <WordDiffCols id={rowId} before={change.before} after={change.after} />\n }\n return (\n <DiffColumns\n kind={change.kind}\n before={<SideValue value={change.before} other={change.after} typeHint={change.type} id={`${rowId}|before`} />}\n after={<SideValue value={change.after} other={change.before} typeHint={change.type} id={`${rowId}|after`} />}\n />\n )\n}\n\nfunction BlockSection({\n block,\n rowId,\n baseVersion,\n canRestore,\n busy,\n onRestore,\n}: {\n block: BlockChange\n rowId: string\n baseVersion: number\n canRestore: boolean\n busy: boolean\n onRestore: () => void\n}) {\n const name = block.componentId.split('.').pop() ?? block.componentId\n return (\n <div className=\"overflow-hidden rounded-md border border-border/60\">\n <Row gap=\"2\" align=\"center\" className=\"border-b border-border/50 bg-muted/30 px-2 py-1.5\">\n <Text size=\"xs\" weight=\"semibold\" className=\"min-w-0 truncate\">\n {name}\n </Text>\n <Code tone=\"muted\">{block.componentId}</Code>\n <KindTag kind={block.kind} />\n <Spacer />\n {canRestore ? (\n <RestoreIcon\n busy={busy}\n title={translate('cms.version.restoreBlock', { version: baseVersion })}\n onClick={onRestore}\n />\n ) : null}\n </Row>\n <div className=\"px-2 py-2\">\n {block.props && block.props.length > 0 ? (\n <Stack gap=\"3\" className=\"border-l-2 border-border/50 pl-3\">\n {block.props.map((prop) => (\n <PropRow key={prop.name} prop={prop} rowId={`${rowId}|prop:${prop.name}`} />\n ))}\n </Stack>\n ) : null}\n {block.slotsChanged ? <MutedNote>{translate('cms.version.nestedContentChanged')}</MutedNote> : null}\n {block.kind !== 'changed' && !block.props?.length ? (\n <MutedNote>\n {block.kind === 'added' ? translate('cms.version.blockAdded') : translate('cms.version.blockRemoved')}\n </MutedNote>\n ) : null}\n </div>\n </div>\n )\n}\n\nfunction PropRow({ prop, rowId }: { prop: PropChange; rowId: string }) {\n const useWordDiff = prop.kind === 'changed' && typeof prop.before === 'string' && typeof prop.after === 'string'\n return (\n <div>\n <Text size=\"xs\" tone=\"subtle\" className=\"mb-0.5 block uppercase tracking-wide\">\n {prettyName(prop.name)}\n </Text>\n {useWordDiff ? (\n <WordDiffCols id={rowId} before={String(prop.before)} after={String(prop.after)} />\n ) : (\n <DiffColumns\n kind={prop.kind}\n before={<SideValue value={prop.before} other={prop.after} id={`${rowId}|before`} />}\n after={<SideValue value={prop.after} other={prop.before} id={`${rowId}|after`} />}\n />\n )}\n </div>\n )\n}\n\n/**\n * One side of a rich-text change (EC-379): rendered compact prose\n * ({@link RichTextPreview}), height-clamped behind the shared expand toggle for\n * long bodies, with the standard \"empty\" placeholder for an absent side.\n */\nfunction RichTextSide({ value, id }: { value: unknown; id: string }) {\n const { isExpanded } = useDiffDisplay()\n if (isRichTextValueEmpty(value)) {\n return (\n <Text size=\"sm\" tone=\"subtle\" className=\"italic\">\n {translate('cms.version.emptyValue')}\n </Text>\n )\n }\n const expanded = isExpanded(id)\n const isLong = richTextToText(value).length > DIFF_TRUNCATE_THRESHOLD\n return (\n <ExpandToggle id={id} isLong={isLong} expanded={expanded}>\n <div className={cn(!expanded && isLong && 'max-h-60 overflow-hidden')}>\n <RichTextPreview value={value} />\n </div>\n </ExpandToggle>\n )\n}\n\n/** One side of a non-text change — the value, or an \"empty\" placeholder. */\nfunction SideValue({\n value,\n other,\n typeHint,\n id,\n}: {\n value: unknown\n other?: unknown\n typeHint?: FieldDef['type']\n id: string\n}) {\n if (value === undefined || value === null || value === '') {\n return (\n <Text size=\"sm\" tone=\"subtle\" className=\"italic\">\n {translate('cms.version.emptyValue')}\n </Text>\n )\n }\n return <ValueView value={value} other={other} typeHint={typeHint} id={id} />\n}\n\n/** Read-only value display, dispatching on field type / self-describing value shape. */\nfunction ValueView({\n value,\n other,\n typeHint,\n id,\n}: {\n value: unknown\n other?: unknown\n typeHint?: FieldDef['type']\n id: string\n}) {\n const { isExpanded } = useDiffDisplay()\n if (typeHint === 'asset' || isAssetNode(value)) return <AssetValue value={value} />\n if (typeHint === 'relation' || readDocumentRef(value)) return <RelationValue value={value} other={other} />\n if (typeHint === 'richText')\n return (\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words\">\n {richTextToText(value) || translate('cms.version.richText')}\n </Text>\n )\n if (typeHint === 'boolean' || typeof value === 'boolean')\n return (\n <Text size=\"sm\" mono>\n {value === true ? translate('common.yes') : translate('common.no')}\n </Text>\n )\n if (typeHint === 'date')\n return (\n <Text size=\"sm\" mono>\n {String(value).slice(0, 10)}\n </Text>\n )\n if (typeof value === 'object')\n return (\n <Text size=\"sm\" tone=\"muted\">\n {Array.isArray(value)\n ? translate(value.length === 1 ? 'cms.version.itemCount.one' : 'cms.version.itemCount.other', {\n count: value.length,\n })\n : translate('cms.version.objectValue')}\n </Text>\n )\n const expanded = isExpanded(id)\n const { shown, isLong } = truncateText(String(value), expanded)\n return (\n <ExpandToggle id={id} isLong={isLong} expanded={expanded}>\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words\">\n {shown}\n </Text>\n </ExpandToggle>\n )\n}\n\nfunction RelationValue({ value, other }: { value: unknown; other?: unknown }) {\n const source = useCollectionView()\n const refs = toRefArray(value)\n if (refs.length === 0)\n return (\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words\">\n {String(value)}\n </Text>\n )\n const otherRefs = other !== undefined ? toRefArray(other) : []\n const label = refs\n .map((ref) => {\n const title = source.titleOf(ref)\n const collision = otherRefs.some((o) => o.id !== ref.id && source.titleOf(o) === title)\n return collision ? `${title} · ${ref.id}` : title\n })\n .join(', ')\n return <Text size=\"sm\">{label}</Text>\n}\n\n/** Asset-record-owned keys — resolved off the asset RECORD at render, not authored. */\nconst ASSET_RECORD_KEYS = new Set<string>([\n 'url', 'alt', 'width', 'height', 'focalPoint', 'contentType', 'mimeType',\n 'byteSize', 'storageKey', 'title', 'filename', 'meta', 'createdAt', 'updatedAt',\n])\n\nfunction authoredAssetSubfields(value: unknown): [string, unknown][] {\n return Object.entries(assetSubfieldsOf(value)).filter(([key]) => !ASSET_RECORD_KEYS.has(key))\n}\n\nfunction AssetValue({ value }: { value: unknown }) {\n const items = (Array.isArray(value) ? value : [value])\n .map((entry) => ({ id: readAssetId(entry), sub: authoredAssetSubfields(entry) }))\n .filter((a): a is { id: string; sub: [string, unknown][] } => a.id !== undefined)\n if (items.length === 0)\n return (\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words\">\n {String(value)}\n </Text>\n )\n return (\n <div className=\"flex flex-wrap gap-2\">\n {items.map(({ id, sub }, i) => (\n <div key={`${id}-${i}`} className=\"flex flex-col gap-1\">\n <AssetThumb id={id} />\n {sub.length > 0 ? (\n <Stack gap=\"1\" className=\"pl-0.5\">\n {sub.map(([key, val]) => (\n <Text key={key} size=\"xs\" tone=\"muted\" className=\"break-words\">\n <span className=\"uppercase tracking-wide text-muted-foreground/70\">{prettyName(key)}:</span>{' '}\n {typeof val === 'object' && val !== null\n ? translate('cms.version.objectValue')\n : String(val)}\n </Text>\n ))}\n </Stack>\n ) : null}\n </div>\n ))}\n </div>\n )\n}\n\n/** An asset as a thumbnail (image with a resolvable URL) or a labelled badge. */\nfunction AssetThumb({ id }: { id: string }) {\n const source = useCollectionView()\n const assetCollectionId = source.assetCollectionId ?? 'asset'\n const record = source.resolveAsset?.(id)\n const label = record?.title ?? record?.filename ?? source.titleOf({ collection: assetCollectionId, id })\n const isImage = record?.contentType?.startsWith('image/') ?? false\n const url = record?.url\n if (isImage && isDisplayableAssetUrl(url)) {\n return (\n <span className=\"inline-flex min-w-0 items-center gap-2\">\n <img\n src={url}\n alt={record?.alt ?? label}\n loading=\"lazy\"\n className=\"size-12 shrink-0 rounded border border-border bg-muted object-cover\"\n />\n <Text size=\"xs\" tone=\"muted\" className=\"min-w-0 truncate\">\n {label}\n </Text>\n </span>\n )\n }\n return (\n <Badge variant=\"outline\">\n <ImageIcon className=\"size-3\" /> {label}\n </Badge>\n )\n}\n\n// --- Prose word diff --------------------------------------------------------------\n\nconst isWordTokenChanged = (token: WordToken) => token.changed\nconst isMergedTokenChanged = (token: MergedDiffToken) => token.kind !== 'same'\n\nfunction WordDiffCols({ id, before, after }: { id: string; before: string; after: string }) {\n const { mode, layout, isExpanded, captions } = useDiffDisplay()\n const expanded = isExpanded(id)\n const wd = useMemo(() => wordDiff(before, after), [before, after])\n const merged = useMemo(() => mergeWordDiff(wd.before, wd.after), [wd])\n\n // EC-382: change-anchored truncation — the collapsed excerpt centers on the\n // FIRST edit (the EC-379 finding: an edit past the head threshold could hide\n // behind \"Show more\"). Applies to every layout/mode; only the arrangement varies.\n const beforeSlice = truncateTokensAroundChange(wd.before, expanded, isWordTokenChanged)\n const afterSlice = truncateTokensAroundChange(wd.after, expanded, isWordTokenChanged)\n\n if (layout === 'stacked') {\n const isLong = beforeSlice.isLong || afterSlice.isLong\n return (\n <ExpandToggle id={id} isLong={isLong} expanded={expanded}>\n <Stack gap=\"2\">\n <StackedSide caption={captions.before} tone=\"before\">\n <WordTokens excerpt={beforeSlice} side=\"before\" />\n </StackedSide>\n <StackedSide caption={captions.after} tone=\"after\">\n <WordTokens excerpt={afterSlice} side=\"after\" />\n </StackedSide>\n </Stack>\n </ExpandToggle>\n )\n }\n\n if (mode === 'unified') {\n const mergedSlice = truncateTokensAroundChange(merged, expanded, isMergedTokenChanged)\n return (\n <ExpandToggle id={id} isLong={mergedSlice.isLong} expanded={expanded}>\n <UnifiedWordTokens excerpt={mergedSlice} />\n </ExpandToggle>\n )\n }\n\n const isLong = beforeSlice.isLong || afterSlice.isLong\n return (\n <ExpandToggle id={id} isLong={isLong} expanded={expanded}>\n <TwoCol\n before={<WordTokens excerpt={beforeSlice} side=\"before\" />}\n after={<WordTokens excerpt={afterSlice} side=\"after\" />}\n />\n </ExpandToggle>\n )\n}\n\n/** A \"…\" standing in for the hidden context an anchored excerpt trimmed (EC-382). */\nfunction EllipsisMark() {\n return (\n <span aria-hidden className=\"select-none text-muted-foreground/60\">\n …{' '}\n </span>\n )\n}\n\nfunction WordTokens({ excerpt, side }: { excerpt: AnchoredExcerpt<WordToken>; side: 'before' | 'after' }) {\n return (\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words leading-relaxed\">\n {excerpt.leadingEllipsis ? <EllipsisMark /> : null}\n {excerpt.shown.map((token, i) =>\n token.changed ? (\n <mark\n key={i}\n className={cn(\n 'rounded-sm px-0.5',\n side === 'before'\n ? 'bg-destructive/15 text-destructive line-through decoration-destructive/40'\n : 'bg-success/20 text-foreground',\n )}\n >\n {token.text}\n </mark>\n ) : (\n <span key={i} className=\"text-muted-foreground\">\n {token.text}\n </span>\n ),\n )}\n {excerpt.trailingEllipsis ? <EllipsisMark /> : null}\n </Text>\n )\n}\n\nfunction UnifiedWordTokens({ excerpt }: { excerpt: AnchoredExcerpt<MergedDiffToken> }) {\n return (\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words leading-relaxed\">\n {excerpt.leadingEllipsis ? <EllipsisMark /> : null}\n {excerpt.shown.map((token, i) =>\n token.kind === 'same' ? (\n <span key={i} className=\"text-muted-foreground\">\n {token.text}\n </span>\n ) : (\n <mark\n key={i}\n className={cn(\n 'rounded-sm px-0.5',\n token.kind === 'removed'\n ? 'bg-destructive/15 text-destructive line-through decoration-destructive/40'\n : 'bg-success/20 text-foreground',\n )}\n >\n {token.text}\n </mark>\n ),\n )}\n {excerpt.trailingEllipsis ? <EllipsisMark /> : null}\n </Text>\n )\n}\n\n// --- Small shared bits ------------------------------------------------------------\n\nfunction KindTag({ kind }: { kind: FieldChange['kind'] }) {\n if (kind === 'changed') return null\n return (\n <Text size=\"xs\" tone=\"subtle\">\n · {kind === 'added' ? translate('cms.version.kindNew') : translate('cms.version.kindRemoved')}\n </Text>\n )\n}\n\nfunction RestoreIcon({ busy, title, onClick }: { busy: boolean; title: string; onClick: () => void }) {\n return (\n <Button variant=\"ghost\" size=\"icon-sm\" disabled={busy} title={title} aria-label={title} onClick={onClick}>\n <RotateCcw />\n </Button>\n )\n}\n\nfunction MutedNote({ children }: { children: ReactNode }) {\n return (\n <Text size=\"sm\" tone=\"muted\" className=\"italic\">\n {children}\n </Text>\n )\n}\n\nfunction fieldScope(change: FieldChange): RestoreScope {\n return { kind: 'field', field: change.field, ...(change.locale !== undefined ? { locale: change.locale } : {}) }\n}\n\n/** Group changes BY FIELD (a localized field's per-locale variants together). */\nfunction groupByField(\n changes: FieldChange[],\n fieldOrder: Map<string, number>,\n localeRank: Map<string, number>,\n): FieldGroupData[] {\n const map = new Map<string, FieldGroupData>()\n for (const change of changes) {\n let group = map.get(change.field)\n if (!group) {\n group = { field: change.field, label: change.label, type: change.type, entries: [] }\n map.set(change.field, group)\n }\n group.entries.push(change)\n }\n const groups = [...map.values()]\n groups.sort(\n (a, b) =>\n (fieldOrder.get(a.field) ?? Number.MAX_SAFE_INTEGER) - (fieldOrder.get(b.field) ?? Number.MAX_SAFE_INTEGER),\n )\n for (const group of groups) {\n group.entries.sort((a, b) => localeCompare(a.locale, b.locale, localeRank))\n }\n return groups\n}\n\nfunction localeCompare(a: string | undefined, b: string | undefined, rank: Map<string, number>): number {\n if (a === b) return 0\n if (a === undefined) return -1\n if (b === undefined) return 1\n return (rank.get(a) ?? 99) - (rank.get(b) ?? 99)\n}\n\n/** camelCase / snake prop name → a readable label. */\nfunction prettyName(name: string): string {\n const spaced = name.replace(/[_-]+/g, ' ').replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n return spaced.charAt(0).toUpperCase() + spaced.slice(1)\n}\n"]}
@@ -3,10 +3,21 @@ import type { CmsDocument } from '@elytracms/core/cms-core';
3
3
  export declare function stageDocument(projectId: string, doc: CmsDocument): void;
4
4
  /**
5
5
  * Merge any documents staged for `projectId` into a fresh mount's
6
- * seeded/hydrated document list. See the module doc for why the merge rule
7
- * itself is mode-aware (playground: staged always wins; Convex: staged fills
8
- * gaps only, dropped once superseded).
6
+ * seeded/hydrated document list. EC-461: the merge rule keys on whether the
7
+ * seeded set REFLECTS WRITES — a fact of the MOUNT, not of the backend:
8
+ *
9
+ * - `seedReflectsWrites: true` — the seeded set came from a fresh per-mount
10
+ * hydration query (Convex, or the playground's seeded in-memory adapter now
11
+ * that EC-461 retired the static-baseline gate). A staged doc only fills a
12
+ * gap; a key the snapshot carries supersedes and drops the staged entry.
13
+ * - `seedReflectsWrites: false` — the seeded set is a static kit/fixture
14
+ * baseline (an un-baselined playground kit project, a fixture session) that
15
+ * never reflects a write on its own — a staged doc always wins for its key.
16
+ *
17
+ * The default preserves the historical mode split for callers that don't know
18
+ * their seed's provenance (fixtures/tests): connected hydrates, playground may
19
+ * not. `CmsScreen`/the transfer dialog pass the real provenance (`cms !== null`).
9
20
  */
10
- export declare function consumeStagedDocuments(projectId: string | undefined, seeded: readonly CmsDocument[]): CmsDocument[];
21
+ export declare function consumeStagedDocuments(projectId: string | undefined, seeded: readonly CmsDocument[], seedReflectsWrites?: boolean): CmsDocument[];
11
22
  /** Test seam: drop all staged documents. */
12
23
  export declare function clearStagedDocuments(): void;
@@ -9,10 +9,11 @@ import { isPlaygroundMode } from '@elytracms/studio/lib/persistence';
9
9
  * snapshot its `CmsSessionGate` resolves, and in BOTH modes that snapshot can
10
10
  * miss a document the transfer just wrote — for two DIFFERENT reasons:
11
11
  *
12
- * - **Playground**: `CmsSessionGate` renders synchronously with `session:
13
- * null` (the EC-138 determinism contract) — it never queries anything, so
14
- * the seeded set is always the STATIC kit/fixture baseline, forever. It
15
- * never reflects a write, on the first mount or the hundredth.
12
+ * - **Playground**: since EC-461 the gate hydrates from the seeded in-memory
13
+ * adapter like connected mode (the old synchronous static-baseline gate was
14
+ * the loss family's root) — but an UN-BASELINED project (a kit instantiated
15
+ * in-session, nothing persisted yet) still seeds the static kit baseline,
16
+ * which never reflects a write on its own.
16
17
  * - **Convex**: the seeded set comes from a REAL fresh-per-mount query
17
18
  * (`loadCms()`), so it usually catches up — but there is no synchronous
18
19
  * guarantee it observes a write from a moment earlier (belt and braces: the
@@ -60,29 +61,39 @@ export function stageDocument(projectId, doc) {
60
61
  }
61
62
  /**
62
63
  * Merge any documents staged for `projectId` into a fresh mount's
63
- * seeded/hydrated document list. See the module doc for why the merge rule
64
- * itself is mode-aware (playground: staged always wins; Convex: staged fills
65
- * gaps only, dropped once superseded).
64
+ * seeded/hydrated document list. EC-461: the merge rule keys on whether the
65
+ * seeded set REFLECTS WRITES — a fact of the MOUNT, not of the backend:
66
+ *
67
+ * - `seedReflectsWrites: true` — the seeded set came from a fresh per-mount
68
+ * hydration query (Convex, or the playground's seeded in-memory adapter now
69
+ * that EC-461 retired the static-baseline gate). A staged doc only fills a
70
+ * gap; a key the snapshot carries supersedes and drops the staged entry.
71
+ * - `seedReflectsWrites: false` — the seeded set is a static kit/fixture
72
+ * baseline (an un-baselined playground kit project, a fixture session) that
73
+ * never reflects a write on its own — a staged doc always wins for its key.
74
+ *
75
+ * The default preserves the historical mode split for callers that don't know
76
+ * their seed's provenance (fixtures/tests): connected hydrates, playground may
77
+ * not. `CmsScreen`/the transfer dialog pass the real provenance (`cms !== null`).
66
78
  */
67
- export function consumeStagedDocuments(projectId, seeded) {
79
+ export function consumeStagedDocuments(projectId, seeded, seedReflectsWrites = !isPlaygroundMode()) {
68
80
  if (projectId === undefined)
69
81
  return [...seeded];
70
82
  const list = staged.get(projectId);
71
83
  if (!list || list.length === 0)
72
84
  return [...seeded];
73
- if (isPlaygroundMode()) {
74
- // The seeded set is a static kit/fixture baseline that never reflects a
75
- // write on its own — a staged doc always wins for its key, matching the
85
+ if (!seedReflectsWrites) {
86
+ // Static baseline: a staged doc always wins for its key, matching the
76
87
  // ONLY mechanism that ever represents a live edit across mounts here.
77
88
  const byKey = new Map(seeded.map((d) => [docKey(d), d]));
78
89
  for (const d of list)
79
90
  byKey.set(docKey(d), structuredClone(d));
80
91
  return [...byKey.values()];
81
92
  }
82
- // Convex: `seeded` is a fresh per-mount hydration query — a real signal of
83
- // the current persisted truth. A staged doc only fills a gap that snapshot
84
- // doesn't already carry; a key it DOES carry is superseded and dropped from
85
- // the buffer so it can never resurrect on a later mount.
93
+ // Hydrated seed: a real signal of the current persisted truth. A staged doc
94
+ // only fills a gap that snapshot doesn't already carry; a key it DOES carry
95
+ // is superseded and dropped from the buffer so it can never resurrect on a
96
+ // later mount and shadow a newer revision.
86
97
  const seededKeys = new Set(seeded.map(docKey));
87
98
  const superseded = list.filter((d) => seededKeys.has(docKey(d)));
88
99
  if (superseded.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"document-staging.js","sourceRoot":"","sources":["../../../src/components/cms/document-staging.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAA;AAE/C,SAAS,MAAM,CAAC,GAAgB;IAC9B,OAAO,GAAG,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,EAAE,EAAE,CAAA;AACtC,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,aAAa,CAAC,SAAiB,EAAE,GAAgB;IAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;IACxC,uEAAuE;IACvE,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACd,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;AAC7B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAA6B,EAC7B,MAA8B;IAE9B,IAAI,SAAS,KAAK,SAAS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IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;;YACrD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IAC/B,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1D,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,GAAG,MAAM,CAAC,CAAA;IACxC,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC3D,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,oBAAoB;IAClC,MAAM,CAAC,KAAK,EAAE,CAAA;AAChB,CAAC","sourcesContent":["import type { CmsDocument } from '@elytracms/core/cms-core'\nimport { isPlaygroundMode } from '@elytracms/studio/lib/persistence'\n\n/**\n * EC-320 (0.0.44 follow-up) — a tiny cross-mount handoff for a freshly created\n * (or freshly appended-to) document.\n *\n * The \"Use in document…\" transfer creates/updates a draft in the Components\n * view, then navigates to that document's CMS editor — a FRESH `CmsProvider`\n * mount. That fresh mount seeds its documents from whatever hydration/kit\n * snapshot its `CmsSessionGate` resolves, and in BOTH modes that snapshot can\n * miss a document the transfer just wrote — for two DIFFERENT reasons:\n *\n * - **Playground**: `CmsSessionGate` renders synchronously with `session:\n * null` (the EC-138 determinism contract) — it never queries anything, so\n * the seeded set is always the STATIC kit/fixture baseline, forever. It\n * never reflects a write, on the first mount or the hundredth.\n * - **Convex**: the seeded set comes from a REAL fresh-per-mount query\n * (`loadCms()`), so it usually catches up — but there is no synchronous\n * guarantee it observes a write from a moment earlier (belt and braces: the\n * transfer also AWAITS its own write landing — see `transfer-dialog.tsx` —\n * but staging covers the mount regardless of that timing).\n *\n * A previous version of this module gated `stageDocument` itself on\n * `isPlaygroundMode()`, reasoning that Convex mode \"re-hydrates from\n * persistence\" per mount and so never needs staging. That reasoning was\n * wrong — a fresh query has no synchronous ordering guarantee against a write\n * from moments earlier — and the gate was exactly why the Convex-mode\n * transfer 404'd (EC-320 follow-up finding). Staging now runs in every mode.\n *\n * The two modes DO still genuinely differ on the read side, though — not by a\n * wrong assumption this time, but structurally:\n *\n * - Playground's seeded set can NEVER be \"fresher\" than a staged write (it\n * never changes at all), so a staged entry always wins over it — exactly\n * the original, working behavior, now also covering \"insert into an\n * EXISTING document\" (whose key was already in the static baseline before\n * the edit — the append would otherwise be invisible).\n * - Convex's seeded set is a genuine live signal, so a staged entry only\n * fills a GAP it doesn't already carry; once it does, the seeded set wins\n * outright (the newer-or-equal persisted truth) and the stale staged entry\n * is dropped — so it can never resurrect on a later mount and shadow a\n * revision made after the transfer (e.g. a subsequent edit, once persisted\n * and re-hydrated).\n *\n * Reads that don't drop anything are non-destructive (StrictMode-safe: a\n * double mount computes the identical merge both times); the buffer itself is\n * in-memory, session-scoped runtime state — never persisted, never a\n * substitute for the real write.\n */\n\nconst staged = new Map<string, CmsDocument[]>()\n\nfunction docKey(doc: CmsDocument): string {\n return `${doc.collection}/${doc.id}`\n}\n\n/** Stage a document for the next `CmsProvider` mount of `projectId` (any mode). */\nexport function stageDocument(projectId: string, doc: CmsDocument): void {\n const list = staged.get(projectId) ?? []\n // Replace any prior staging of the same doc key so a re-transfer wins.\n const next = list.filter((d) => docKey(d) !== docKey(doc))\n next.push(doc)\n staged.set(projectId, next)\n}\n\n/**\n * Merge any documents staged for `projectId` into a fresh mount's\n * seeded/hydrated document list. See the module doc for why the merge rule\n * itself is mode-aware (playground: staged always wins; Convex: staged fills\n * gaps only, dropped once superseded).\n */\nexport function consumeStagedDocuments(\n projectId: string | undefined,\n seeded: readonly CmsDocument[],\n): CmsDocument[] {\n if (projectId === undefined) return [...seeded]\n const list = staged.get(projectId)\n if (!list || list.length === 0) return [...seeded]\n\n if (isPlaygroundMode()) {\n // The seeded set is a static kit/fixture baseline that never reflects a\n // write on its own — a staged doc always wins for its key, matching the\n // ONLY mechanism that ever represents a live edit across mounts here.\n const byKey = new Map(seeded.map((d) => [docKey(d), d]))\n for (const d of list) byKey.set(docKey(d), structuredClone(d))\n return [...byKey.values()]\n }\n\n // Convex: `seeded` is a fresh per-mount hydration query — a real signal of\n // the current persisted truth. A staged doc only fills a gap that snapshot\n // doesn't already carry; a key it DOES carry is superseded and dropped from\n // the buffer so it can never resurrect on a later mount.\n const seededKeys = new Set(seeded.map(docKey))\n const superseded = list.filter((d) => seededKeys.has(docKey(d)))\n if (superseded.length > 0) {\n const remaining = list.filter((d) => !superseded.some((s) => docKey(s) === docKey(d)))\n if (remaining.length > 0) staged.set(projectId, remaining)\n else staged.delete(projectId)\n }\n\n const gap = list.filter((d) => !seededKeys.has(docKey(d)))\n if (gap.length === 0) return [...seeded]\n return [...seeded, ...gap.map((d) => structuredClone(d))]\n}\n\n/** Test seam: drop all staged documents. */\nexport function clearStagedDocuments(): void {\n staged.clear()\n}\n"]}
1
+ {"version":3,"file":"document-staging.js","sourceRoot":"","sources":["../../../src/components/cms/document-staging.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAA;AAE/C,SAAS,MAAM,CAAC,GAAgB;IAC9B,OAAO,GAAG,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,EAAE,EAAE,CAAA;AACtC,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,aAAa,CAAC,SAAiB,EAAE,GAAgB;IAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE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CAAA;IAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAChE,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACtF,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;;YACrD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IAC/B,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1D,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,GAAG,MAAM,CAAC,CAAA;IACxC,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC3D,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,oBAAoB;IAClC,MAAM,CAAC,KAAK,EAAE,CAAA;AAChB,CAAC","sourcesContent":["import type { CmsDocument } from '@elytracms/core/cms-core'\nimport { isPlaygroundMode } from '@elytracms/studio/lib/persistence'\n\n/**\n * EC-320 (0.0.44 follow-up) — a tiny cross-mount handoff for a freshly created\n * (or freshly appended-to) document.\n *\n * The \"Use in document…\" transfer creates/updates a draft in the Components\n * view, then navigates to that document's CMS editor — a FRESH `CmsProvider`\n * mount. That fresh mount seeds its documents from whatever hydration/kit\n * snapshot its `CmsSessionGate` resolves, and in BOTH modes that snapshot can\n * miss a document the transfer just wrote — for two DIFFERENT reasons:\n *\n * - **Playground**: since EC-461 the gate hydrates from the seeded in-memory\n * adapter like connected mode (the old synchronous static-baseline gate was\n * the loss family's root) — but an UN-BASELINED project (a kit instantiated\n * in-session, nothing persisted yet) still seeds the static kit baseline,\n * which never reflects a write on its own.\n * - **Convex**: the seeded set comes from a REAL fresh-per-mount query\n * (`loadCms()`), so it usually catches up — but there is no synchronous\n * guarantee it observes a write from a moment earlier (belt and braces: the\n * transfer also AWAITS its own write landing — see `transfer-dialog.tsx` —\n * but staging covers the mount regardless of that timing).\n *\n * A previous version of this module gated `stageDocument` itself on\n * `isPlaygroundMode()`, reasoning that Convex mode \"re-hydrates from\n * persistence\" per mount and so never needs staging. That reasoning was\n * wrong — a fresh query has no synchronous ordering guarantee against a write\n * from moments earlier — and the gate was exactly why the Convex-mode\n * transfer 404'd (EC-320 follow-up finding). Staging now runs in every mode.\n *\n * The two modes DO still genuinely differ on the read side, though — not by a\n * wrong assumption this time, but structurally:\n *\n * - Playground's seeded set can NEVER be \"fresher\" than a staged write (it\n * never changes at all), so a staged entry always wins over it — exactly\n * the original, working behavior, now also covering \"insert into an\n * EXISTING document\" (whose key was already in the static baseline before\n * the edit — the append would otherwise be invisible).\n * - Convex's seeded set is a genuine live signal, so a staged entry only\n * fills a GAP it doesn't already carry; once it does, the seeded set wins\n * outright (the newer-or-equal persisted truth) and the stale staged entry\n * is dropped — so it can never resurrect on a later mount and shadow a\n * revision made after the transfer (e.g. a subsequent edit, once persisted\n * and re-hydrated).\n *\n * Reads that don't drop anything are non-destructive (StrictMode-safe: a\n * double mount computes the identical merge both times); the buffer itself is\n * in-memory, session-scoped runtime state — never persisted, never a\n * substitute for the real write.\n */\n\nconst staged = new Map<string, CmsDocument[]>()\n\nfunction docKey(doc: CmsDocument): string {\n return `${doc.collection}/${doc.id}`\n}\n\n/** Stage a document for the next `CmsProvider` mount of `projectId` (any mode). */\nexport function stageDocument(projectId: string, doc: CmsDocument): void {\n const list = staged.get(projectId) ?? []\n // Replace any prior staging of the same doc key so a re-transfer wins.\n const next = list.filter((d) => docKey(d) !== docKey(doc))\n next.push(doc)\n staged.set(projectId, next)\n}\n\n/**\n * Merge any documents staged for `projectId` into a fresh mount's\n * seeded/hydrated document list. EC-461: the merge rule keys on whether the\n * seeded set REFLECTS WRITES — a fact of the MOUNT, not of the backend:\n *\n * - `seedReflectsWrites: true` — the seeded set came from a fresh per-mount\n * hydration query (Convex, or the playground's seeded in-memory adapter now\n * that EC-461 retired the static-baseline gate). A staged doc only fills a\n * gap; a key the snapshot carries supersedes and drops the staged entry.\n * - `seedReflectsWrites: false` — the seeded set is a static kit/fixture\n * baseline (an un-baselined playground kit project, a fixture session) that\n * never reflects a write on its own — a staged doc always wins for its key.\n *\n * The default preserves the historical mode split for callers that don't know\n * their seed's provenance (fixtures/tests): connected hydrates, playground may\n * not. `CmsScreen`/the transfer dialog pass the real provenance (`cms !== null`).\n */\nexport function consumeStagedDocuments(\n projectId: string | undefined,\n seeded: readonly CmsDocument[],\n seedReflectsWrites: boolean = !isPlaygroundMode(),\n): CmsDocument[] {\n if (projectId === undefined) return [...seeded]\n const list = staged.get(projectId)\n if (!list || list.length === 0) return [...seeded]\n\n if (!seedReflectsWrites) {\n // Static baseline: a staged doc always wins for its key, matching the\n // ONLY mechanism that ever represents a live edit across mounts here.\n const byKey = new Map(seeded.map((d) => [docKey(d), d]))\n for (const d of list) byKey.set(docKey(d), structuredClone(d))\n return [...byKey.values()]\n }\n\n // Hydrated seed: a real signal of the current persisted truth. A staged doc\n // only fills a gap that snapshot doesn't already carry; a key it DOES carry\n // is superseded and dropped from the buffer so it can never resurrect on a\n // later mount and shadow a newer revision.\n const seededKeys = new Set(seeded.map(docKey))\n const superseded = list.filter((d) => seededKeys.has(docKey(d)))\n if (superseded.length > 0) {\n const remaining = list.filter((d) => !superseded.some((s) => docKey(s) === docKey(d)))\n if (remaining.length > 0) staged.set(projectId, remaining)\n else staged.delete(projectId)\n }\n\n const gap = list.filter((d) => !seededKeys.has(docKey(d)))\n if (gap.length === 0) return [...seeded]\n return [...seeded, ...gap.map((d) => structuredClone(d))]\n}\n\n/** Test seam: drop all staged documents. */\nexport function clearStagedDocuments(): void {\n staged.clear()\n}\n"]}
@@ -7,7 +7,9 @@ import { localizedLabel, translate } from '@elytracms/studio/lib/i18n';
7
7
  import { editCreatesVariant, resolveDisplayedValue } from '@elytracms/studio/lib/locale';
8
8
  import { applyAssetSelection, singleAssetIdOf } from '../assets/asset-selection.js';
9
9
  import { CellValue, toRefArray } from './cell.js';
10
+ import { DateInput } from './date-input.js';
10
11
  import { cellEditKind, cellKey } from './cell-edit.js';
12
+ import { fieldLabel } from './cms-labels.js';
11
13
  import { useCollectionView } from '../collection-view/collection-view-context.js';
12
14
  import { RelationPicker } from './relation-picker.js';
13
15
  import { AssetPicker } from './asset-picker.js';
@@ -22,7 +24,15 @@ import { AssetPicker } from './asset-picker.js';
22
24
  */
23
25
  export function EditableCell({ collection, doc, field, editing, busy, errorMessage, onStartEdit, onCancel, onCommit, }) {
24
26
  const source = useCollectionView();
25
- const kind = cellEditKind(field, source.isFieldReadOnly(field));
27
+ // Inline editing is a capability. EC-463: the gate used to sit only on the
28
+ // Tab-advance list, so a rail WITHOUT it (redirects, users, the self-account
29
+ // view) still rendered focusable, clickable, editor-opening cells whose commit
30
+ // then hit "no `inlineEditing.commitField` → close without dispatching" — the
31
+ // edit was accepted on screen and silently thrown away. A read-only rail now
32
+ // really does yield no editable cells.
33
+ const kind = source.capabilities.inlineEdit
34
+ ? cellEditKind(field, source.isFieldReadOnly(field))
35
+ : 'none';
26
36
  // The table's locale resolution (EC-176): the cell displays the AMBIENT
27
37
  // active locale (EC-018 fallback applied) and edits write that locale only.
28
38
  // Editing a fallback-shown value therefore creates the localized variant —
@@ -36,12 +46,25 @@ export function EditableCell({ collection, doc, field, editing, busy, errorMessa
36
46
  editCreatesVariant(collection, doc, field.name, locale, source.localeConfig), cellKeyId: key, children: _jsx(InlineCellEditor, { field: field, value: value, busy: busy, onCommit: onCommit, onCancel: onCancel }) }));
37
47
  }
38
48
  function handleKeyDown(event) {
39
- if (event.key === 'Enter' || event.key === 'F2') {
49
+ // EC-463: Space too — it is half of the native activation contract the
50
+ // `role="button"` this cell now carries promises.
51
+ if (event.key === 'Enter' || event.key === 'F2' || event.key === ' ') {
40
52
  event.preventDefault();
41
53
  onStartEdit();
42
54
  }
43
55
  }
44
- return (_jsxs("div", { "data-cell-key": key, "data-testid": `cell-${key}`, tabIndex: kind === 'none' ? undefined : 0,
56
+ const editable = kind !== 'none';
57
+ return (_jsxs("div", { "data-cell-key": key, "data-testid": `cell-${key}`, tabIndex: editable ? 0 : undefined,
58
+ // EC-463: an editable cell WAS an anonymous focusable `div` — the
59
+ // accessibility tree listed it as a nameless "generic, clickable", so
60
+ // neither a screen reader nor an agent editor could tell what activating it
61
+ // would edit. It is an activation surface, so it says so and names itself.
62
+ role: editable ? 'button' : undefined, "aria-label": editable
63
+ ? translate('cms.cell.editAria', {
64
+ field: fieldLabel(field),
65
+ title: source.titleOf({ collection: collection.id, id: doc.id }),
66
+ })
67
+ : undefined,
45
68
  // While a picker cell is editing, the dialog renders inside this div. React
46
69
  // bubbles portal events through the COMPONENT tree, so a click on the picker
47
70
  // (e.g. its ✕) would re-fire onStartEdit and reopen it — hence the `editing`
@@ -67,6 +90,14 @@ function InlineCellEditor({ field, value, busy, onCommit, onCancel, }) {
67
90
  const [draft, setDraft] = useState(() => initialDraft(field, value));
68
91
  const draftRef = useRef(draft);
69
92
  draftRef.current = draft;
93
+ // EC-463: the ref moves SYNCHRONOUSLY with the control, not at the next
94
+ // render. A control that only emits its final value on the settling keystroke
95
+ // (the date control's Enter) would otherwise be committed one render stale —
96
+ // the same event that produces the value also triggers `commit()` below.
97
+ function updateDraft(next) {
98
+ draftRef.current = next;
99
+ setDraft(next);
100
+ }
70
101
  // Each editor instance settles exactly once (Tab keydown + the blur it
71
102
  // causes must not commit twice).
72
103
  const settledRef = useRef(false);
@@ -102,7 +133,7 @@ function InlineCellEditor({ field, value, busy, onCommit, onCancel, }) {
102
133
  if (!event.currentTarget.contains(event.relatedTarget))
103
134
  commit(null);
104
135
  }
105
- return (_jsx("div", { onKeyDown: handleKeyDown, onBlur: handleBlur, onClick: (event) => event.stopPropagation(), className: "min-w-0 flex-1", "data-testid": "cell-editor", "aria-busy": busy || undefined, children: _jsx(CellEditorControl, { field: field, draft: draft, onDraft: setDraft }) }));
136
+ return (_jsx("div", { onKeyDown: handleKeyDown, onBlur: handleBlur, onClick: (event) => event.stopPropagation(), className: "min-w-0 flex-1", "data-testid": "cell-editor", "aria-busy": busy || undefined, children: _jsx(CellEditorControl, { field: field, draft: draft, onDraft: updateDraft }) }));
106
137
  }
107
138
  /** The actual input for the field type (compact, table-density variants). */
108
139
  function CellEditorControl({ field, draft, onDraft, }) {
@@ -112,7 +143,10 @@ function CellEditorControl({ field, draft, onDraft, }) {
112
143
  case 'number':
113
144
  return (_jsx(Input, { autoFocus: true, type: "number", value: typeof draft === 'string' ? draft : '', onChange: (event) => onDraft(event.target.value), className: "h-7 text-sm", "data-testid": "cell-editor-number" }));
114
145
  case 'date':
115
- return (_jsx(Input, { autoFocus: true, type: "date", value: typeof draft === 'string' ? draft : '', onChange: (event) => onDraft(event.target.value), className: "h-7 text-sm", "data-testid": "cell-editor-date" }));
146
+ // EC-463: the shared date control. The cell's own draft already commits on
147
+ // Enter/Tab/blur, so what this adds here is the working insert/paste path
148
+ // and the guard against a re-render clobbering half-typed segments.
149
+ return (_jsx(DateInput, { autoFocus: true, value: typeof draft === 'string' ? draft : '', onChange: (stored) => onDraft(stored ? stored.slice(0, 10) : ''), className: "h-7 text-sm", testId: "cell-editor-date" }));
116
150
  case 'select':
117
151
  if (field.multiple) {
118
152
  return _jsx(MultiSelectControl, { field: field, draft: draft, onDraft: onDraft });