@elytracms/studio 0.0.73 → 0.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/app-views/default-modules.js +1 -1
- package/dist/components/app-views/default-modules.js.map +1 -1
- package/dist/components/cms/cms-labels.d.ts +6 -0
- package/dist/components/cms/cms-labels.js +21 -1
- package/dist/components/cms/cms-labels.js.map +1 -1
- package/dist/components/cms/cms-store.d.ts +16 -1
- package/dist/components/cms/cms-store.js +74 -18
- package/dist/components/cms/cms-store.js.map +1 -1
- package/dist/components/cms/collection-table.js +71 -9
- package/dist/components/cms/collection-table.js.map +1 -1
- package/dist/components/cms/column-width.d.ts +8 -0
- package/dist/components/cms/column-width.js +18 -0
- package/dist/components/cms/column-width.js.map +1 -1
- package/dist/components/cms/versions-model.d.ts +13 -0
- package/dist/components/cms/versions-model.js +44 -0
- package/dist/components/cms/versions-model.js.map +1 -1
- package/dist/components/cms/versions-pane.js +27 -6
- package/dist/components/cms/versions-pane.js.map +1 -1
- package/dist/components/cms/view-bar.js +16 -6
- package/dist/components/cms/view-bar.js.map +1 -1
- package/dist/components/collection-view/cms-collection-view-source.js +7 -0
- package/dist/components/collection-view/cms-collection-view-source.js.map +1 -1
- package/dist/lib/cms-views/view-model.d.ts +62 -12
- package/dist/lib/cms-views/view-model.js +143 -44
- package/dist/lib/cms-views/view-model.js.map +1 -1
- package/dist/lib/collection-view/collection-view-source.d.ts +28 -0
- package/dist/lib/collection-view/collection-view-source.js +15 -0
- package/dist/lib/collection-view/collection-view-source.js.map +1 -1
- package/dist/lib/i18n/messages.de.js +4 -0
- package/dist/lib/i18n/messages.de.js.map +1 -1
- package/dist/lib/i18n/messages.en.d.ts +3 -0
- package/dist/lib/i18n/messages.en.js +4 -0
- package/dist/lib/i18n/messages.en.js.map +1 -1
- package/dist/lib/operations/session-hydration.d.ts +8 -0
- package/dist/lib/operations/session-hydration.js +3 -0
- package/dist/lib/operations/session-hydration.js.map +1 -1
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/status-dot.d.ts +39 -0
- package/dist/ui/status-dot.js +36 -0
- package/dist/ui/status-dot.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-store.js","sourceRoot":"","sources":["../../../src/components/cms/cms-store.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEzE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,2BAA2B,EAC3B,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,GACjB,MAAM,0BAA0B,CAAA;AAcjC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAA;AAC9E,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAC1F,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AAC9E,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAM1F,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,EAC5B,sBAAsB,EACtB,sBA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AM,YAAG,QAAQ,GAAuB,CAAA;AAC7E,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,OAAO,EAAE,YAAY,EAAE,CAAA","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport {\n createCollectionRegistry,\n createDocumentStore,\n documentKey,\n documentSchema,\n resolveDocumentTitle,\n resolveField,\n sampleDocuments,\n seedDefaults,\n sampleFilterableCollections,\n sampleLocaleConfig,\n samplePublishedKeys,\n resolveSingletonDocument,\n titleFieldOf,\n validateDocument,\n} from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CmsValidationIssue,\n CollectionDef,\n CollectionRegistry,\n DocumentRef,\n FieldDef,\n Locale,\n LocaleConfig,\n LocalizedString,\n RestoreScope,\n} from '@elytracms/core/cms-core'\nimport type { DocumentVersionRecord } from '@elytracms/core/persistence'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { configureStudioLocales, useStudioLocale } from '@elytracms/studio/lib/locale'\nimport { studioManifestLookup } from '@elytracms/studio/lib/registry'\nimport { resolveDeploymentCollections } from '@elytracms/studio/lib/workspace'\nimport { validateComposition, validateRichTextEmbeds } from './cms-composition-validators'\nimport { matchesRef, removeDoc, replaceDoc, upsertDoc } from './document-ref-utils'\nimport { createRequiredContext } from '@elytracms/studio/lib/required-context'\nimport { createCmsPersister, getStudioOperations } from '@elytracms/studio/lib/operations'\nimport type {\n CmsPersister,\n OperationError,\n OperationResult,\n} from '@elytracms/studio/lib/operations'\nimport {\n ALL_VIEW_ID,\n DEFAULT_VIEW_OVERRIDE_ID,\n canonicalViewState,\n configViewIssues,\n defaultConfigViewId,\n defaultViewState,\n deprecatedDefaultFlagViewIds,\n hasDefaultViewOverride,\n resolveCollectionViews,\n viewStatesEqual,\n} from '@elytracms/studio/lib/cms-views'\nimport type { TableViewState } from '@elytracms/studio/lib/cms-views'\nimport { useOptionalAssets } from '../assets/assets-store'\nimport { consumeStagedDocuments } from './document-staging'\nimport { applyCellValue, commitCellEdit } from './cell-edit'\nimport type { CellCommitInput, CellCommitOutcome } from './cell-edit'\nimport { runBulkAction } from './bulk-actions'\nimport type { BulkAction, BulkReport, BulkSetField } from './bulk-actions'\nimport { cleanHiddenForPublish } from './publish-clean'\n\n/**\n * A resolved table view: a named bundle of filters (closed AD-3 vocabulary),\n * sort, and visible/ordered columns. EC-246b: named views are **config-as-code**\n * (declared in `cms/`, read live via `configViewsFor`) — the editor-owned DB\n * saved-view store (EC-169) is retired. The unnamed \"All documents\" default is\n * derived per collection; editors keep only transient in-session tweaks + Reset.\n */\nexport interface SavedView {\n id: string\n /**\n * The view label — a {@link LocalizedString} (EC-343): the built-in \"All\" default is\n * a plain translated string; a config view's name may be a `{ locale }` map, resolved\n * at the render site (`ViewTabs`) via the same `resolveLabel` path as `form.label`.\n */\n name: LocalizedString\n state: TableViewState\n}\n\nexport interface ImportReport {\n added: number\n rejected: { id: string; issues: CmsValidationIssue[] }[]\n}\n\n/**\n * A document's recorded version history plus its live pin (EC-224), as the\n * Versions inspector pane reads it. `versions` is newest-first; `publishedVersion`\n * is the recorded version currently pinned live, absent when unpublished.\n */\nexport interface DocumentVersionsView {\n versions: DocumentVersionRecord[]\n publishedVersion?: number\n}\n\nexport interface CmsStore {\n /** The project this CMS session edits (set when persistence is enabled); the asset picker scopes the real library by it (EC-152). */\n projectId?: string\n collections: readonly CollectionDef[]\n localeConfig: LocaleConfig\n /**\n * The studio's ambient active locale (EC-176): table cells, detail forms,\n * and inline edits all display and write THIS locale. Switched once via the\n * shared `LocaleSwitcher`, never per control.\n */\n activeLocale: Locale\n getCollection(id: string): CollectionDef | undefined\n documentsOf(collectionId: string): CmsDocument[]\n getDocument(ref: DocumentRef): CmsDocument | undefined\n /** Resolve a relation/asset target's display title. */\n titleOf(ref: DocumentRef): string\n saveDocument(doc: CmsDocument): void\n /**\n * Commit ONE field edit from the table (EC-168): optimistic session apply +\n * exactly one `documents.upsert` operations command, awaited. Validation\n * failures and operation rejections return a structured error (the caller\n * renders it on the cell) and leave the session rolled back.\n */\n commitFieldEdit(input: CellCommitInput): Promise<CellCommitOutcome>\n createDocument(collectionId: string): DocumentRef\n /**\n * Ensure a singleton collection's lone document exists and return its ref\n * (EC-274). Resolves the existing single document, or creates one with a normal\n * generated id (never the collection id). Idempotent. The singleton route opens\n * through this so the one document always exists to edit.\n */\n ensureSingletonDocument(collectionId: string): DocumentRef\n deleteDocument(ref: DocumentRef): void\n /**\n * Is this document currently published? Sourced from the version POINTER\n * (EC-224), not the flat `state` enum — seeded from hydration and updated by\n * {@link publishDocument}/{@link unpublishDocument}.\n */\n isPublished(ref: DocumentRef): boolean\n /**\n * Publish: snapshot the draft as a new version and pin it live (EC-224).\n * Flips published-ness optimistically, then reconciles against the backend\n * record (EC-225) so the badge can never claim a publish the backend refused\n * (e.g. blocked by publish-time field validation).\n */\n publishDocument(ref: DocumentRef): Promise<void>\n /**\n * Unpublish: clear the live version pin (EC-224). Blocked at the operations\n * layer while strict relation fields published-reference it (EC-173); the\n * optimistic flip reconciles against the backend on rejection (EC-225).\n */\n unpublishDocument(ref: DocumentRef): Promise<void>\n /**\n * Load this document's recorded version history + live pin (EC-224) for the\n * Versions inspector pane. Fixture/playground sessions (no project) have no\n * persisted history → an empty view. Failures surface as {@link persistError}.\n */\n loadDocumentVersions(ref: DocumentRef): Promise<DocumentVersionsView>\n /**\n * Restore a recorded version as the new working draft (EC-224): the operation\n * snapshots the current draft first (so the rollback is itself undoable), then\n * loads the chosen snapshot. An optional `scope` (EC-298) restores only one\n * field or block, laid over the current draft, instead of the whole document.\n * Returns the restored draft (or null on failure/fixture session) so the open\n * editor can adopt it.\n */\n restoreDocumentVersion(\n ref: DocumentRef,\n version: number,\n scope?: RestoreScope,\n ): Promise<CmsDocument | null>\n importDocuments(collectionId: string, docs: unknown[]): ImportReport\n validate(doc: CmsDocument): CmsValidationIssue[]\n isFieldReadOnly(field: FieldDef): boolean\n // Views (EC-246b): the built-in default + config-declared named views (from\n // `cms/`, read live). Shared views are code, not editor-owned DB data.\n viewsOf(collectionId: string): SavedView[]\n activeViewId(collectionId: string): string\n /** Switch views — resets the working table state to the view's state. */\n setActiveView(collectionId: string, viewId: string): void\n /** The live table state (the active view's state plus unsaved edits). */\n tableStateOf(collectionId: string): TableViewState\n /**\n * Update the working state. Always pass an updater when deriving from the\n * previous state — render-time snapshots go stale across rapid events.\n */\n setTableState(\n collectionId: string,\n update: TableViewState | ((prev: TableViewState) => TableViewState),\n ): void\n /** Does the working state diverge from the active view (\"unsaved changes\")? */\n isViewDirty(collectionId: string): boolean\n /** Discard working-state edits, back to the active view. */\n resetTableState(collectionId: string): void\n /**\n * Bulk publish/unpublish/delete (EC-169) + set-field (EC-247): one operations\n * command PER item, per-item outcomes in the report — partial failure is\n * enumerated, never silent. Only succeeded items mutate the session. A\n * `set-field` carries its `{ field, value }` payload.\n */\n runBulk(\n collectionId: string,\n ids: readonly string[],\n action: BulkAction,\n setField?: BulkSetField,\n ): Promise<BulkReport>\n /**\n * Mirror a collection into the session (e.g. an accepted AI-generated\n * schema, EC-097). Replaces by id. Session-only: persistence happens through\n * the accept flow's changeset (`schema.upsertCollection`), not here.\n */\n addCollection(def: CollectionDef): void\n /**\n * Most recent failed/denied persisted mutation (structured, from the\n * operation result). Rendered by the CMS surface — never a silent failure.\n */\n persistError: OperationError | null\n clearPersistError(): void\n /** Seed the persisted baseline now (e.g. before applying an AI changeset). */\n ensurePersistedBaseline(): Promise<void>\n /** Await all queued persisted mutations (tests, publish flows). */\n flushPersistence(): Promise<void>\n}\n\nconst { Context: CmsContext, useRequired: useCms } = createRequiredContext<CmsStore>('Cms')\n\nfunction primaryField(collection: CollectionDef): string {\n return titleFieldOf(collection)?.name ?? collection.fields[0]?.name ?? 'id'\n}\n\n/**\n * EC-316 (bug fix) — mint a fresh, COLLISION-FREE document id for `+ New`.\n *\n * `seq` is an in-memory, per-session counter (reset to 0 on every reload). A\n * document minted `new-<collection>-<n>` in a PRIOR session can already occupy\n * whatever `n` this session's counter would next reissue — the pre-fix bug:\n * `+ New` on a `post` collection that already held a (possibly published)\n * `new-post-1` handed out that SAME id again, silently opening the existing\n * document for editing instead of creating a fresh draft. Walking the counter\n * past every id already in `existingIds` makes the mint collision-free\n * regardless of what a prior session left behind.\n */\nexport function mintDocumentId(\n collectionId: string,\n seq: { current: number },\n existingIds: ReadonlySet<string>,\n): string {\n let id: string\n do {\n seq.current += 1\n id = `new-${collectionId}-${seq.current}`\n } while (existingIds.has(id))\n return id\n}\n\n/**\n * Build a fresh document for `collectionId`: a collision-free id (EC-316, via\n * {@link mintDocumentId} against every id `existingDocs` already holds for\n * this collection) and the collection's declared field defaults (EC-297, via\n * `seedDefaults`). Pure — the sensitive part of the insert sequence shared by\n * `createDocument` and `ensureSingletonDocument`'s empty branch (via the\n * private `insertNewDocument` below), factored out so it's unit-testable\n * without a `CmsProvider`.\n */\nexport function buildNewDocument(\n collectionId: string,\n registry: CollectionRegistry,\n seq: { current: number },\n existingDocs: readonly CmsDocument[],\n): CmsDocument {\n const existingIds = new Set(\n existingDocs.filter((d) => d.collection === collectionId).map((d) => d.id),\n )\n const id = mintDocumentId(collectionId, seq, existingIds)\n const collection = registry.get(collectionId)\n return { collection: collectionId, id, values: collection ? seedDefaults(collection) : {} }\n}\n\n/**\n * Does `docs` already hold a document for `collectionId`? `ensureSingletonDocument`'s\n * empty branch re-checks this INSIDE the `setDocuments` updater (against the\n * latest `prev`, not a stale snapshot) so a concurrent invocation — StrictMode's\n * double-invoked effect, or a second caller racing the same synchronous guard —\n * can never materialize a second singleton document.\n */\nexport function hasDocumentFor(docs: readonly CmsDocument[], collectionId: string): boolean {\n return docs.some((d) => d.collection === collectionId)\n}\n\n/**\n * Surface a duplicate `initial: true` across a collection's config views (EC-343/\n * EC-444) as a visible, one-time console warning — never a silent swallow. This is a\n * developer config mistake (editors can't fix config-as-code), so it takes the same\n * warn-once console channel the i18n runtime uses for config problems, not an editor\n * banner; the first-declared still seeds deterministically. Deduped per collection id.\n */\nconst warnedDuplicateDefaultCollections = new Set<string>()\nfunction warnDuplicateDefaultViews(collection: CollectionDef): void {\n if (warnedDuplicateDefaultCollections.has(collection.id)) return\n const issues = configViewIssues(collection)\n if (issues.length === 0) return\n warnedDuplicateDefaultCollections.add(collection.id)\n if (typeof console !== 'undefined') console.warn(`[views] ${issues[0]!.message}`)\n}\n\n/**\n * Surface the DEPRECATED `default: true` view flag (EC-444) as a one-time console\n * warning per collection — never silent. `default` (the view flag) is renamed to\n * `initial`; it is read as an alias for one release and removed next release. Same\n * warn-once channel as the duplicate check; deduped per collection id.\n */\nconst warnedDeprecatedDefaultCollections = new Set<string>()\nfunction warnDeprecatedDefaultFlag(collection: CollectionDef): void {\n if (warnedDeprecatedDefaultCollections.has(collection.id)) return\n const ids = deprecatedDefaultFlagViewIds(collection)\n if (ids.length === 0) return\n warnedDeprecatedDefaultCollections.add(collection.id)\n if (typeof console !== 'undefined') {\n console.warn(\n `[views] Collection \"${collection.id}\" uses the deprecated view flag \\`default\\` on ${ids.join(', ')}; rename it to \\`initial\\` (EC-444 — \\`default\\` is removed next release).`,\n )\n }\n}\n\n/** The unnamed built-in view: no filters, no sort, every field visible. */\nfunction defaultView(collection: CollectionDef | undefined): SavedView {\n return {\n id: ALL_VIEW_ID,\n name: translate('cms.list.view.all'),\n state: collection\n ? defaultViewState(collection)\n : { filters: [], sort: null, columns: [], hidden: [] },\n }\n}\n\n/**\n * The CMS session store (EC-141): documents and collections are optimistic,\n * synchronous session state (live validation while typing); every mutation —\n * create/save/delete/state transitions — is mirrored onto the operations\n * layer (`documents.*` / `schema.*` commands) through {@link createCmsPersister}.\n * Failed/denied commands surface as {@link CmsStore.persistError}.\n */\nexport function CmsProvider({\n children,\n projectId,\n initialCollections,\n initialDocuments,\n initialPublishedKeys,\n initialLocaleConfig,\n}: {\n children: ReactNode\n /** Enables persistence through the shared operations client. */\n projectId?: string\n /** Seed collections (e.g. from an imported starter kit, EC-119); defaults to the samples. */\n initialCollections?: CollectionDef[]\n initialDocuments?: CmsDocument[]\n /**\n * Published document keys from hydration (EC-224): the version pointer\n * (`publishedVersion` set). Absent (kit / fixture sessions) → the sample\n * fixtures' published set (`samplePublishedKeys`).\n */\n initialPublishedKeys?: readonly string[]\n /** Locale config for the seeded content; defaults to the sample config. */\n initialLocaleConfig?: LocaleConfig\n}) {\n const [documents, setDocuments] = useState<CmsDocument[]>(() => {\n const seeded = (initialDocuments ?? sampleDocuments).map((d) => structuredClone(d))\n // EC-320 (0.0.44 follow-up): merge any documents STAGED by the\n // Components-view \"Use in document…\" transfer — a cross-mount handoff in\n // EVERY mode now (see document-staging.ts), not just the playground. The\n // merge rule itself stays mode-aware there: playground's seeded set is a\n // static baseline that never reflects a write (staged always wins);\n // Convex's is a fresh per-mount hydration query (staged fills gaps only,\n // dropped once the seeded set actually carries the key).\n return consumeStagedDocuments(projectId, seeded)\n })\n // Published-ness as the version POINTER (EC-224), decoupled from the flat\n // `state` enum: seeded from hydration's pointer set, or — when none is supplied\n // — the canonical sample published set for the playground. A kit's imported\n // content (`initialDocuments` without a pointer set) starts unpublished\n // (drafts) until an editor publishes it. The flat `state` is never consulted.\n const [publishedKeys, setPublishedKeys] = useState<Set<string>>(() => {\n if (initialPublishedKeys) return new Set(initialPublishedKeys)\n return new Set(initialDocuments ? [] : samplePublishedKeys)\n })\n const [activeViews, setActiveViews] = useState<Record<string, string>>({})\n // The live table state per collection where it diverges from the active\n // view; absent key = exactly the active view's state (not dirty).\n const [tableStates, setTableStates] = useState<Record<string, TableViewState>>({})\n // Collections are stateful so AI-generated schemas (EC-097) can be accepted\n // into the session. The session schema IS the source the sort/filter\n // offering follows (EC-177 gap 3): hydrated sessions receive the persisted\n // schema via `initialCollections`; the fixture fallback is the canonical\n // cms-core sample schema WITH its declared `filterable` flags — no\n // session-side widenings, so the studio never offers a field the backend's\n // delivery engine would reject.\n const [collections, setCollections] = useState<CollectionDef[]>(() => [\n ...(initialCollections ?? sampleFilterableCollections),\n ])\n const [persistError, setPersistError] = useState<OperationError | null>(null)\n const seq = useRef(0)\n // EC-274: collection ids whose lone singleton document this session has already\n // created — a synchronous guard so a re-invoked effect (or StrictMode's double\n // mount) never materializes a second document under a freshly generated id.\n const ensuredSingletons = useRef<Set<string>>(new Set())\n\n // Latest session state for the persister's lazy baseline (no re-subscribing).\n const collectionsRef = useRef(collections)\n collectionsRef.current = collections\n const documentsRef = useRef(documents)\n documentsRef.current = documents\n\n const persisterRef = useRef<CmsPersister | null>(null)\n if (persisterRef.current === null && projectId !== undefined) {\n persisterRef.current = createCmsPersister({\n projectId,\n getOperations: async () => (await getStudioOperations()).operations,\n getCollections: () => collectionsRef.current,\n getDocuments: () => documentsRef.current,\n // EC-277: self-type composition static props on write (the manifest half of\n // the lens), so extraction stays schema-free. Document fields self-type via\n // the schema alone (above); the registry adds blocks/embed prop coverage.\n lookupManifest: studioManifestLookup(),\n onError: setPersistError,\n })\n }\n\n const registry = useMemo(() => createCollectionRegistry(collections), [collections])\n const store = useMemo(() => createDocumentStore(documents), [documents])\n const localeConfig = initialLocaleConfig ?? sampleLocaleConfig\n\n // Asset existence is validated against the REAL asset library (assets live in\n // their own repository, not as CMS documents). With the ambient AssetsProvider\n // present, the oracle is the set of uploaded asset ids — but only once loaded;\n // while it loads we are optimistic so a valid upload is never transiently\n // flagged \"unknown\". With no provider (tests/fixtures), the oracle is absent\n // and asset existence falls back to the document store.\n const assetStore = useOptionalAssets()\n const assetExists = useMemo<((id: string) => boolean) | undefined>(() => {\n if (!assetStore) return undefined\n if (assetStore.status !== 'ready') return () => true\n const ids = new Set(assetStore.assets.map((asset) => asset.id))\n return (id) => ids.has(id)\n }, [assetStore])\n\n // The ambient studio locale (EC-176): this session's locale config drives\n // the switcher options; every CMS surface follows the one active locale.\n const { locale: activeLocale } = useStudioLocale()\n useEffect(() => {\n configureStudioLocales(localeConfig)\n }, [localeConfig])\n\n const getCollection = useCallback((id: string) => registry.get(id), [registry])\n\n const getDocument = useCallback(\n (ref: DocumentRef) => documents.find((d) => matchesRef(d, ref)),\n [documents],\n )\n\n const titleOf = useCallback(\n (ref: DocumentRef) => {\n const doc = documents.find((d) => matchesRef(d, ref))\n const collection = registry.get(ref.collection)\n if (!doc || !collection) return ref.id\n // EC-296/EC-242: a function `titleField` (title pattern) composes the title\n // from the document's resolved values (active locale). Only resolve the full\n // value set when a function is declared — the common string `titleField` case\n // still resolves the single title field below (primaryField === the title field).\n if (typeof collection.titleField === 'function') {\n const values: Record<string, unknown> = {}\n for (const field of collection.fields) {\n values[field.name] = resolveField(collection, doc, field.name, activeLocale, localeConfig).value\n }\n return resolveDocumentTitle(collection, values, ref.id)\n }\n // Resolve through the locale layer in the ambient active locale (EC-176)\n // with EC-018 fallback, so localized titles follow the switcher.\n const { value } = resolveField(\n collection,\n doc,\n primaryField(collection),\n activeLocale,\n localeConfig,\n )\n return typeof value === 'string' && value ? value : ref.id\n },\n [documents, registry, localeConfig, activeLocale],\n )\n\n const saveDocument = useCallback((doc: CmsDocument) => {\n // Replace-or-append (upsert): a brand-new document must still land even\n // though nothing in the session matches its ref yet.\n setDocuments((prev) => upsertDoc(prev, doc))\n persisterRef.current?.upsertDocument(doc)\n }, [])\n\n const commitFieldEdit = useCallback(\n (input: CellCommitInput): Promise<CellCommitOutcome> => {\n // Pure map-replace: an edit always targets a document already open in\n // the session, so a miss (already gone) is a no-op, never an append.\n const replaceWith = (doc: CmsDocument) => setDocuments((prev) => replaceDoc(prev, doc))\n const persister = persisterRef.current\n return commitCellEdit(\n {\n registry,\n documents: documentsRef.current,\n localeConfig,\n applySession: replaceWith,\n rollbackSession: replaceWith,\n ...(persister && projectId !== undefined\n ? {\n dispatch: async (next: CmsDocument) => {\n // Make sure the persisted baseline + every queued mutation\n // landed first, then issue the commit's single command.\n await persister.ensureBaseline()\n const { operations } = await getStudioOperations()\n return operations.documents.upsert({ projectId, document: next })\n },\n }\n : {}),\n },\n input,\n )\n },\n [registry, localeConfig, projectId],\n )\n\n // Shared insert sequence (EC-326): existingIds/mint/seedDefaults (via\n // `buildNewDocument`) + optimistic append + persist, consumed by both\n // `createDocument` (always inserts) and `ensureSingletonDocument`'s empty\n // branch (`guardExisting: true` — re-checks \"no document for this collection\n // yet\" against the LATEST `prev` inside the `setDocuments` updater, not the\n // `documentsRef.current` snapshot the caller already checked, so a\n // concurrent invocation — StrictMode's double-invoked effect — can never\n // materialize a second singleton document).\n const insertNewDocument = useCallback(\n (collectionId: string, options?: { guardExisting?: boolean }): CmsDocument => {\n const doc = buildNewDocument(collectionId, registry, seq, documentsRef.current)\n setDocuments((prev) =>\n options?.guardExisting && hasDocumentFor(prev, collectionId) ? prev : [...prev, doc],\n )\n persisterRef.current?.upsertDocument(doc)\n return doc\n },\n [registry],\n )\n\n const createDocument = useCallback(\n (collectionId: string): DocumentRef => {\n const doc = insertNewDocument(collectionId)\n return { collection: collectionId, id: doc.id }\n },\n [insertNewDocument],\n )\n\n // EC-274 (re-scopes EC-217): a singleton is a UI lens, not a fixed id. Resolve\n // the collection's lone document and return its ref; if none exists yet, create\n // one with a NORMAL generated id (never the collection id — no code ever names a\n // literal doc id). Idempotent under React effects/StrictMode: the create guard\n // keys on \"any document in this collection\", so a re-invocation never adds a\n // second. On drift (>1 doc) the studio routes to the list, so this defensively\n // returns the first; the empty draft persists like any create.\n const ensureSingletonDocument = useCallback(\n (collectionId: string): DocumentRef => {\n const collection = registry.get(collectionId)\n const resolution = collection\n ? resolveSingletonDocument(collection, documentsRef.current)\n : ({ kind: 'empty' } as const)\n if (resolution.kind === 'ready') {\n return { collection: collectionId, id: resolution.doc.id }\n }\n if (resolution.kind === 'drift') {\n return { collection: collectionId, id: resolution.docs[0]!.id }\n }\n // Empty: create the lone document once. The ref guard (synchronous) plus the\n // updater's \"any doc in collection\" check make this idempotent under a\n // re-invoked effect or StrictMode's double mount — never a second draft.\n const existing = documentsRef.current.find((d) => d.collection === collectionId)\n if (existing) return { collection: collectionId, id: existing.id }\n if (ensuredSingletons.current.has(collectionId)) {\n return { collection: collectionId, id: `new-${collectionId}-pending` }\n }\n ensuredSingletons.current.add(collectionId)\n // EC-316: same collision-free mint as `createDocument` (via the shared\n // `insertNewDocument` — defensive here, the singleton-empty branch only\n // runs when no document exists yet).\n const doc = insertNewDocument(collectionId, { guardExisting: true })\n return { collection: collectionId, id: doc.id }\n },\n [registry, insertNewDocument],\n )\n\n const deleteDocument = useCallback((ref: DocumentRef) => {\n setDocuments((prev) => removeDoc(prev, ref))\n persisterRef.current?.deleteDocument(ref)\n }, [])\n\n // EC-224: published-ness IS the version pointer (`publishedKeys`) — the SOLE\n // studio source of truth, read via `isPublished`. The live row stays a\n // continuous draft (Sanity model); no flat `state` mirror is maintained. Every\n // reader now consults the pointer (the table badge/$state via `isPublished`,\n // the preview engine via the pin), so the flat field is read by nothing here.\n const setPublished = useCallback((ref: DocumentRef, published: boolean) => {\n const key = documentKey(ref)\n setPublishedKeys((prev) => {\n if (prev.has(key) === published) return prev\n const next = new Set(prev)\n if (published) next.add(key)\n else next.delete(key)\n return next\n })\n }, [])\n\n const isPublished = useCallback(\n (ref: DocumentRef) => publishedKeys.has(documentKey(ref)),\n [publishedKeys],\n )\n\n // Reconcile published-ness for a ref against the AUTHORITATIVE backend record\n // (EC-225): the optimistic flip is a guess; once the queued op settles we read\n // the actual pin so the badge can never claim a state the backend refused\n // (a publish blocked by field rules, an unpublish blocked by a strict ref).\n const reconcilePublished = useCallback(\n async (ref: DocumentRef) => {\n if (projectId === undefined) return\n const { operations } = await getStudioOperations()\n const record = await operations.documents.get({ projectId, ref })\n if (record.ok) setPublished(ref, record.value.publishedVersion !== undefined)\n },\n [projectId, setPublished],\n )\n\n const publishDocument = useCallback(\n async (ref: DocumentRef) => {\n setPublished(ref, true) // optimistic\n // EC-273: no clearing here — the draft is already free of conditionally-hidden\n // values (the editor clears them on write), so the snapshot the publish op\n // pins is clean by construction.\n persisterRef.current?.publishDocument(ref)\n await persisterRef.current?.flush()\n await reconcilePublished(ref)\n },\n [setPublished, reconcilePublished],\n )\n\n const unpublishDocument = useCallback(\n async (ref: DocumentRef) => {\n setPublished(ref, false) // optimistic\n persisterRef.current?.unpublishDocument(ref)\n await persisterRef.current?.flush()\n await reconcilePublished(ref)\n },\n [setPublished, reconcilePublished],\n )\n\n const loadDocumentVersions = useCallback(\n async (ref: DocumentRef): Promise<DocumentVersionsView> => {\n // No persisted backend (fixture/playground): no recorded history.\n if (projectId === undefined) return { versions: [] }\n const { operations } = await getStudioOperations()\n const [versionsRes, recordRes] = await Promise.all([\n operations.documents.listVersions({ projectId, ref }),\n operations.documents.get({ projectId, ref }),\n ])\n if (!versionsRes.ok) {\n setPersistError(versionsRes.error)\n return { versions: [] }\n }\n // The pinned (live) version comes off the document record; a never-saved\n // doc simply has no record (and no versions) — not an error to surface.\n const publishedVersion = recordRes.ok ? recordRes.value.publishedVersion : undefined\n return {\n versions: versionsRes.value,\n ...(publishedVersion !== undefined ? { publishedVersion } : {}),\n }\n },\n [projectId],\n )\n\n const restoreDocumentVersion = useCallback(\n async (\n ref: DocumentRef,\n version: number,\n scope?: RestoreScope,\n ): Promise<CmsDocument | null> => {\n if (projectId === undefined) return null\n // Land any queued edits before the restore reads the current draft to\n // snapshot it (same ordering contract as commitFieldEdit/runBulk). This is\n // what makes a granular (field/block) restore merge over the LATEST draft.\n await persisterRef.current?.ensureBaseline()\n const { operations } = await getStudioOperations()\n const result = await operations.documents.restore({\n projectId,\n ref,\n version,\n ...(scope ? { scope } : {}),\n })\n if (!result.ok) {\n setPersistError(result.error)\n return null\n }\n const restored = result.value.document\n // Pure map-replace: a restore always targets a document already open in\n // the session.\n setDocuments((prev) => replaceDoc(prev, restored))\n return restored\n },\n [projectId],\n )\n\n const validate = useCallback(\n (doc: CmsDocument) =>\n validateDocument(registry, doc, {\n store,\n localeConfig,\n validateComposition,\n validateRichTextEmbeds,\n // EC-224: the EC-173 weak-reference warning sources published-ness from\n // the version pointer, so editing a published doc that references an\n // unpublished target surfaces the fallback warning again (it had gone\n // inert once the flat `state` mirror was dropped in B-3b).\n isPublished,\n assetExists,\n }),\n [registry, store, localeConfig, isPublished, assetExists],\n )\n\n const importDocuments = useCallback(\n (collectionId: string, raw: unknown[]): ImportReport => {\n const report: ImportReport = { added: 0, rejected: [] }\n // Pre-parse so intra-batch relation/asset targets resolve during validation.\n const parsedBatch: CmsDocument[] = []\n const schemaFails: { item: unknown; error: ReturnType<typeof documentSchema.safeParse> }[] =\n []\n for (const item of raw) {\n const parsed = documentSchema.safeParse({ ...(item as object), collection: collectionId })\n if (parsed.success) parsedBatch.push(parsed.data)\n else schemaFails.push({ item, error: parsed })\n }\n for (const { item, error } of schemaFails) {\n report.rejected.push({\n id: (item as { id?: string })?.id ?? translate('cms.list.import.noId'),\n issues: (error.success ? [] : error.error.issues).map((e) => ({\n code: 'invalid-field-value' as const,\n severity: 'error' as const,\n message: e.message,\n path: e.path.map((p) => (typeof p === 'symbol' ? String(p) : p)),\n })),\n })\n }\n // Validate each against existing docs PLUS the rest of the batch.\n const batchStore = createDocumentStore([...documents, ...parsedBatch])\n const accepted: CmsDocument[] = []\n for (const doc of parsedBatch) {\n const issues = validateDocument(registry, doc, { store: batchStore, localeConfig, assetExists })\n const errors = issues.filter((iss) => iss.severity === 'error')\n if (errors.length > 0) report.rejected.push({ id: doc.id, issues: errors })\n else accepted.push(doc)\n }\n if (accepted.length > 0) {\n // Replace-or-append (upsert): an imported row may be brand new to the\n // session, so each accepted document must land even with no prior\n // entry for its ref.\n setDocuments((prev) => accepted.reduce((acc, doc) => upsertDoc(acc, doc), prev))\n for (const doc of accepted) persisterRef.current?.upsertDocument(doc)\n // EC-224: imports land as the working DRAFT. Publish-ness is the version\n // pointer (`publishedKeys`), set by publishing — never carried in the\n // imported row — so an import never auto-publishes; the editor publishes\n // explicitly afterward.\n report.added = accepted.length\n }\n return report\n },\n [registry, documents, localeConfig, assetExists],\n )\n\n const isFieldReadOnly = useCallback((field: FieldDef) => field.form?.readOnly === true, [])\n\n // --- Views (EC-246b: config-as-code) --------------------------------------\n\n const viewsOf = useCallback(\n (collectionId: string): SavedView[] => {\n // The baseline view plus the collection's config-declared views (EC-246b/EC-444).\n // Views are PRESENTATION, read live from elytra.config.ts (AD-11) — not the\n // persisted content schema the session booted from — so they reflect code\n // immediately without a re-seed (the persisted schema is only baselined on\n // first run). The EC-169 DB saved-view store is retired: shared views are\n // code, editors keep only transient in-session tweaks + Reset.\n //\n // EC-444: a config view with the reserved `id: 'default'` REPLACES the\n // synthesized \"All entries\" baseline verbatim (first tab); absent one, the\n // synthesized baseline leads. `resolveCollectionViews` owns that selection.\n const baseline = defaultView(registry.get(collectionId))\n const configCollection = resolveDeploymentCollections().find((c) => c.id === collectionId)\n if (!configCollection) return [baseline]\n return resolveCollectionViews(configCollection, baseline)\n },\n [registry],\n )\n\n // The INITIAL active view for a collection (EC-343/EC-444): a config view flagged\n // `initial: true` seeds the first-load lens; else the baseline — the `id: 'default'`\n // override when present, else the synthesized \"All entries\" (`ALL_VIEW_ID`). Only\n // consulted before the editor has picked a view (`activeViews[id]` wins once set),\n // so transient switching + Reset are unaffected. A duplicate `initial` and any\n // deprecated `default` flag are each warned once (never silent).\n const initialViewId = useCallback((collectionId: string): string => {\n const configCollection = resolveDeploymentCollections().find((c) => c.id === collectionId)\n if (!configCollection) return ALL_VIEW_ID\n warnDuplicateDefaultViews(configCollection)\n warnDeprecatedDefaultFlag(configCollection)\n const initial = defaultConfigViewId(configCollection)\n if (initial) return initial\n return hasDefaultViewOverride(configCollection) ? DEFAULT_VIEW_OVERRIDE_ID : ALL_VIEW_ID\n }, [])\n\n const activeViewOf = useCallback(\n (collectionId: string): SavedView => {\n const id = activeViews[collectionId] ?? initialViewId(collectionId)\n return (\n viewsOf(collectionId).find((view) => view.id === id) ??\n defaultView(registry.get(collectionId))\n )\n },\n [activeViews, initialViewId, viewsOf, registry],\n )\n\n const tableStateOf = useCallback(\n (collectionId: string): TableViewState =>\n tableStates[collectionId] ?? activeViewOf(collectionId).state,\n [tableStates, activeViewOf],\n )\n\n const dropTableState = useCallback((collectionId: string) => {\n setTableStates((prev) => {\n if (!(collectionId in prev)) return prev\n const next = { ...prev }\n delete next[collectionId]\n return next\n })\n }, [])\n\n const setActiveView = useCallback(\n (collectionId: string, viewId: string) => {\n setActiveViews((prev) => ({ ...prev, [collectionId]: viewId }))\n dropTableState(collectionId)\n },\n [dropTableState],\n )\n\n // --- Bulk actions (EC-169) ------------------------------------------------\n\n const runBulk = useCallback(\n async (\n collectionId: string,\n ids: readonly string[],\n action: BulkAction,\n setField?: BulkSetField,\n ): Promise<BulkReport> => {\n const collection = registry.get(collectionId)\n // A set-field needs both the field payload AND the collection def to fold\n // the value the locale-aware way — guard so a misconfigured call fails\n // loud rather than silently no-opping each item.\n if (action === 'set-field' && (!setField || !collection)) {\n return {\n action,\n ...(setField ? { setField } : {}),\n results: ids.map((id) => ({\n ref: { collection: collectionId, id },\n title: titleOf({ collection: collectionId, id }),\n ok: false,\n reason: translate('cms.list.bulk.error.invalidSetField'),\n error: { code: 'unknown', message: 'Invalid set-field request.' },\n })),\n }\n }\n // The next document for a set-field item: fold the value into the active\n // locale's bag (localized) or the shared `values` (non-localized).\n const setFieldDoc = (doc: CmsDocument): CmsDocument =>\n applyCellValue(collection!, doc, setField!.field, activeLocale, setField!.value)\n\n let dispatch:\n | ((action: BulkAction, ref: DocumentRef) => Promise<OperationResult<unknown>>)\n | undefined\n const persister = persisterRef.current\n if (persister && projectId !== undefined) {\n // Pending queued mutations + baseline land first, then one awaited\n // command per item (same ordering contract as commitFieldEdit).\n await persister.ensureBaseline()\n const { operations } = await getStudioOperations()\n dispatch = (bulkAction, ref) => {\n if (bulkAction === 'delete') return operations.documents.delete({ projectId, ref })\n if (bulkAction === 'publish') return operations.documents.publish({ projectId, ref })\n if (bulkAction === 'unpublish') return operations.documents.unpublish({ projectId, ref })\n // set-field: upsert the document carrying the new value. The write\n // path self-types it through the schema lens (EC-277); a scalar field\n // stores its scalar as-is.\n const current = documentsRef.current.find((d) => matchesRef(d, ref))\n if (!current) {\n return Promise.resolve<OperationResult<unknown>>({\n ok: false,\n error: {\n code: 'not-found',\n message: 'Document is no longer in the session.',\n entity: 'cms-document',\n key: `${ref.collection}:${ref.id}`,\n },\n })\n }\n return operations.documents.upsert({ projectId, document: setFieldDoc(current) })\n }\n }\n return runBulkAction(\n {\n documents: documentsRef.current,\n titleOf,\n validate: (doc) =>\n validateDocument(registry, doc, {\n store: createDocumentStore(documentsRef.current),\n localeConfig,\n // EC-225: include the composition validators so a bulk PUBLISH\n // gates blocks/richText validity the same way the detail editor\n // does — the operations-layer publish gate has no component\n // registry, so composition validity is a studio-validation invariant.\n validateComposition,\n validateRichTextEmbeds,\n assetExists,\n }),\n // EC-425: bulk publish joins the single-document clean point — the\n // SAME shared hidden-strip `doPublish` runs (EC-273 field values +\n // EC-394 component props, session registry), per item.\n ...(collection\n ? { cleanForPublish: (doc: CmsDocument) => cleanHiddenForPublish(collection, doc) }\n : {}),\n // Land a cleaned draft exactly the way the editor's publish does:\n // session apply + the persister's self-typing upsert (EC-277 manifest\n // lens), flushed so the serial queue lands the upsert BEFORE the\n // awaited publish command snapshots the stored draft.\n applyCleaned: async (_ref, cleaned) => {\n setDocuments((prev) => replaceDoc(prev, cleaned))\n const persister = persisterRef.current\n if (persister && projectId !== undefined) {\n persister.upsertDocument(cleaned)\n await persister.flush()\n }\n },\n // EC-224: a succeeded publish/unpublish moves the version pointer\n // (`publishedKeys`) via setPublished — there is no separate flat\n // `state` mirror to keep in sync (published-ness is derived from the\n // pointer set).\n applyState: (ref, state) => setPublished(ref, state === 'published'),\n applyDelete: (ref) => setDocuments((prev) => removeDoc(prev, ref)),\n // EC-247: fold the new value into the session document (same\n // locale-aware path the dispatched upsert used). Not a plain\n // `replaceDoc` — the replacement is computed FROM each matched\n // document (`setFieldDoc(d)`), not a fixed value to swap in.\n applySetField: (ref) =>\n setDocuments((prev) => prev.map((d) => (matchesRef(d, ref) ? setFieldDoc(d) : d))),\n ...(dispatch ? { dispatch } : {}),\n },\n collectionId,\n ids,\n action,\n setField,\n )\n },\n [projectId, titleOf, registry, localeConfig, activeLocale, setPublished, assetExists],\n )\n\n const store$ = useMemo<CmsStore>(\n () => ({\n ...(projectId !== undefined ? { projectId } : {}),\n collections,\n localeConfig,\n activeLocale,\n getCollection,\n documentsOf: (collectionId) => documents.filter((d) => d.collection === collectionId),\n getDocument,\n titleOf,\n saveDocument,\n commitFieldEdit,\n createDocument,\n ensureSingletonDocument,\n deleteDocument,\n isPublished,\n publishDocument,\n unpublishDocument,\n loadDocumentVersions,\n restoreDocumentVersion,\n importDocuments,\n validate,\n isFieldReadOnly,\n viewsOf,\n activeViewId: (collectionId) => activeViews[collectionId] ?? initialViewId(collectionId),\n setActiveView,\n tableStateOf,\n setTableState: (collectionId, update) =>\n setTableStates((prev) => {\n const current = prev[collectionId] ?? activeViewOf(collectionId).state\n const next = typeof update === 'function' ? update(current) : update\n return { ...prev, [collectionId]: next }\n }),\n isViewDirty: (collectionId) => {\n const working = tableStates[collectionId]\n if (working === undefined) return false\n const active = activeViewOf(collectionId).state\n const collection = registry.get(collectionId)\n if (collection === undefined) return !viewStatesEqual(working, active)\n // Compare schema-resolved forms (EC-213): a column-order reconciliation\n // or a stale `hidden` entry must not read as an unsaved edit.\n return !viewStatesEqual(\n canonicalViewState(collection, working),\n canonicalViewState(collection, active),\n )\n },\n resetTableState: dropTableState,\n runBulk,\n addCollection: (def) =>\n setCollections((prev) => [...prev.filter((c) => c.id !== def.id), def]),\n persistError,\n clearPersistError: () => setPersistError(null),\n ensurePersistedBaseline: () => persisterRef.current?.ensureBaseline() ?? Promise.resolve(),\n flushPersistence: () => persisterRef.current?.flush() ?? Promise.resolve(),\n }),\n [\n projectId,\n collections,\n documents,\n localeConfig,\n activeLocale,\n getCollection,\n getDocument,\n titleOf,\n saveDocument,\n commitFieldEdit,\n createDocument,\n ensureSingletonDocument,\n deleteDocument,\n isPublished,\n publishDocument,\n unpublishDocument,\n loadDocumentVersions,\n restoreDocumentVersion,\n importDocuments,\n validate,\n isFieldReadOnly,\n viewsOf,\n activeViews,\n activeViewOf,\n initialViewId,\n tableStates,\n tableStateOf,\n setActiveView,\n dropTableState,\n runBulk,\n registry,\n persistError,\n ],\n )\n\n return <CmsContext.Provider value={store$}>{children}</CmsContext.Provider>\n}\n\nexport { useCms }\n\nexport { primaryField }\nexport type { Locale }\n"]}
|
|
1
|
+
{"version":3,"file":"cms-store.js","sourceRoot":"","sources":["../../../src/components/cms/cms-store.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEzE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,2BAA2B,EAC3B,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,GACjB,MAAM,0BAA0B,CAAA;AAcjC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AACvG,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAC1F,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AAC9E,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAM1F,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,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AAe;QACf,QAAQ;QACR,eAAe;QACf,OAAO;QACP,WAAW;QACX,YAAY;QACZ,aAAa;QACb,WAAW;QACX,YAAY;QACZ,aAAa;QACb,cAAc;QACd,OAAO;QACP,QAAQ;QACR,gBAAgB;QAChB,YAAY;KACb,CACF,CAAA;IAED,OAAO,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAAG,QAAQ,GAAuB,CAAA;AAC7E,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,OAAO,EAAE,YAAY,EAAE,CAAA","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport {\n createCollectionRegistry,\n createDocumentStore,\n documentKey,\n documentSchema,\n resolveDocumentTitle,\n resolveField,\n sampleDocuments,\n seedDefaults,\n sampleFilterableCollections,\n sampleLocaleConfig,\n samplePublishedKeys,\n resolveSingletonDocument,\n titleFieldOf,\n validateDocument,\n} from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CmsValidationIssue,\n CollectionDef,\n CollectionRegistry,\n DocumentRef,\n FieldDef,\n Locale,\n LocaleConfig,\n LocalizedString,\n RestoreScope,\n} from '@elytracms/core/cms-core'\nimport type { DocumentVersionRecord } from '@elytracms/core/persistence'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { configureStudioLocales, useStudioLocale } from '@elytracms/studio/lib/locale'\nimport { studioManifestLookup } from '@elytracms/studio/lib/registry'\nimport { resolveDeploymentCollections, resolveDeploymentRoutes } from '@elytracms/studio/lib/workspace'\nimport { validateComposition, validateRichTextEmbeds } from './cms-composition-validators'\nimport { matchesRef, removeDoc, replaceDoc, upsertDoc } from './document-ref-utils'\nimport { createRequiredContext } from '@elytracms/studio/lib/required-context'\nimport { createCmsPersister, getStudioOperations } from '@elytracms/studio/lib/operations'\nimport type {\n CmsPersister,\n OperationError,\n OperationResult,\n} from '@elytracms/studio/lib/operations'\nimport {\n ALL_VIEW_ID,\n DEFAULT_VIEW_OVERRIDE_ID,\n canonicalViewState,\n configViewIssues,\n defaultConfigViewId,\n defaultViewState,\n deprecatedDefaultFlagViewIds,\n hasDefaultViewOverride,\n pseudoColumns,\n resolveCollectionViews,\n viewStatesEqual,\n} from '@elytracms/studio/lib/cms-views'\nimport type { TableViewState } from '@elytracms/studio/lib/cms-views'\nimport { useOptionalAssets } from '../assets/assets-store'\nimport { consumeStagedDocuments } from './document-staging'\nimport { applyCellValue, commitCellEdit } from './cell-edit'\nimport type { CellCommitInput, CellCommitOutcome } from './cell-edit'\nimport { runBulkAction } from './bulk-actions'\nimport type { BulkAction, BulkReport, BulkSetField } from './bulk-actions'\nimport { cleanHiddenForPublish } from './publish-clean'\n\n/**\n * A resolved table view: a named bundle of filters (closed AD-3 vocabulary),\n * sort, and visible/ordered columns. EC-246b: named views are **config-as-code**\n * (declared in `cms/`, read live via `configViewsFor`) — the editor-owned DB\n * saved-view store (EC-169) is retired. The unnamed \"All documents\" default is\n * derived per collection; editors keep only transient in-session tweaks + Reset.\n */\nexport interface SavedView {\n id: string\n /**\n * The view label — a {@link LocalizedString} (EC-343): the built-in \"All\" default is\n * a plain translated string; a config view's name may be a `{ locale }` map, resolved\n * at the render site (`ViewTabs`) via the same `resolveLabel` path as `form.label`.\n */\n name: LocalizedString\n state: TableViewState\n}\n\nexport interface ImportReport {\n added: number\n rejected: { id: string; issues: CmsValidationIssue[] }[]\n}\n\n/**\n * A document's recorded version history plus its live pin (EC-224), as the\n * Versions inspector pane reads it. `versions` is newest-first; `publishedVersion`\n * is the recorded version currently pinned live, absent when unpublished.\n */\nexport interface DocumentVersionsView {\n versions: DocumentVersionRecord[]\n publishedVersion?: number\n}\n\nexport interface CmsStore {\n /** The project this CMS session edits (set when persistence is enabled); the asset picker scopes the real library by it (EC-152). */\n projectId?: string\n collections: readonly CollectionDef[]\n localeConfig: LocaleConfig\n /**\n * The studio's ambient active locale (EC-176): table cells, detail forms,\n * and inline edits all display and write THIS locale. Switched once via the\n * shared `LocaleSwitcher`, never per control.\n */\n activeLocale: Locale\n getCollection(id: string): CollectionDef | undefined\n documentsOf(collectionId: string): CmsDocument[]\n getDocument(ref: DocumentRef): CmsDocument | undefined\n /** Resolve a relation/asset target's display title. */\n titleOf(ref: DocumentRef): string\n saveDocument(doc: CmsDocument): void\n /**\n * Commit ONE field edit from the table (EC-168): optimistic session apply +\n * exactly one `documents.upsert` operations command, awaited. Validation\n * failures and operation rejections return a structured error (the caller\n * renders it on the cell) and leave the session rolled back.\n */\n commitFieldEdit(input: CellCommitInput): Promise<CellCommitOutcome>\n createDocument(collectionId: string): DocumentRef\n /**\n * Ensure a singleton collection's lone document exists and return its ref\n * (EC-274). Resolves the existing single document, or creates one with a normal\n * generated id (never the collection id). Idempotent. The singleton route opens\n * through this so the one document always exists to edit.\n */\n ensureSingletonDocument(collectionId: string): DocumentRef\n deleteDocument(ref: DocumentRef): void\n /**\n * Is this document currently published? Sourced from the version POINTER\n * (EC-224), not the flat `state` enum — seeded from hydration and updated by\n * {@link publishDocument}/{@link unpublishDocument}.\n */\n isPublished(ref: DocumentRef): boolean\n /**\n * The record's last-write ISO timestamp (EC-445) — the data behind the\n * `$updatedAt` list column. Seeded from hydration (connected: the persisted\n * `cmsDocuments.updatedAt`; playground: session-start for the seeded fixtures),\n * then re-stamped on the common edit paths. `undefined` for a ref the session\n * has no timestamp for. `publishedAt` is a reserved EC-445 follow-up (no data path yet).\n */\n documentUpdatedAt(ref: DocumentRef): string | undefined\n /**\n * Publish: snapshot the draft as a new version and pin it live (EC-224).\n * Flips published-ness optimistically, then reconciles against the backend\n * record (EC-225) so the badge can never claim a publish the backend refused\n * (e.g. blocked by publish-time field validation).\n */\n publishDocument(ref: DocumentRef): Promise<void>\n /**\n * Unpublish: clear the live version pin (EC-224). Blocked at the operations\n * layer while strict relation fields published-reference it (EC-173); the\n * optimistic flip reconciles against the backend on rejection (EC-225).\n */\n unpublishDocument(ref: DocumentRef): Promise<void>\n /**\n * Load this document's recorded version history + live pin (EC-224) for the\n * Versions inspector pane. Fixture/playground sessions (no project) have no\n * persisted history → an empty view. Failures surface as {@link persistError}.\n */\n loadDocumentVersions(ref: DocumentRef): Promise<DocumentVersionsView>\n /**\n * Restore a recorded version as the new working draft (EC-224): the operation\n * snapshots the current draft first (so the rollback is itself undoable), then\n * loads the chosen snapshot. An optional `scope` (EC-298) restores only one\n * field or block, laid over the current draft, instead of the whole document.\n * Returns the restored draft (or null on failure/fixture session) so the open\n * editor can adopt it.\n */\n restoreDocumentVersion(\n ref: DocumentRef,\n version: number,\n scope?: RestoreScope,\n ): Promise<CmsDocument | null>\n importDocuments(collectionId: string, docs: unknown[]): ImportReport\n validate(doc: CmsDocument): CmsValidationIssue[]\n isFieldReadOnly(field: FieldDef): boolean\n // Views (EC-246b): the built-in default + config-declared named views (from\n // `cms/`, read live). Shared views are code, not editor-owned DB data.\n viewsOf(collectionId: string): SavedView[]\n activeViewId(collectionId: string): string\n /** Switch views — resets the working table state to the view's state. */\n setActiveView(collectionId: string, viewId: string): void\n /** The live table state (the active view's state plus unsaved edits). */\n tableStateOf(collectionId: string): TableViewState\n /**\n * Update the working state. Always pass an updater when deriving from the\n * previous state — render-time snapshots go stale across rapid events.\n */\n setTableState(\n collectionId: string,\n update: TableViewState | ((prev: TableViewState) => TableViewState),\n ): void\n /** Does the working state diverge from the active view (\"unsaved changes\")? */\n isViewDirty(collectionId: string): boolean\n /** Discard working-state edits, back to the active view. */\n resetTableState(collectionId: string): void\n /**\n * Bulk publish/unpublish/delete (EC-169) + set-field (EC-247): one operations\n * command PER item, per-item outcomes in the report — partial failure is\n * enumerated, never silent. Only succeeded items mutate the session. A\n * `set-field` carries its `{ field, value }` payload.\n */\n runBulk(\n collectionId: string,\n ids: readonly string[],\n action: BulkAction,\n setField?: BulkSetField,\n ): Promise<BulkReport>\n /**\n * Mirror a collection into the session (e.g. an accepted AI-generated\n * schema, EC-097). Replaces by id. Session-only: persistence happens through\n * the accept flow's changeset (`schema.upsertCollection`), not here.\n */\n addCollection(def: CollectionDef): void\n /**\n * Most recent failed/denied persisted mutation (structured, from the\n * operation result). Rendered by the CMS surface — never a silent failure.\n */\n persistError: OperationError | null\n clearPersistError(): void\n /** Seed the persisted baseline now (e.g. before applying an AI changeset). */\n ensurePersistedBaseline(): Promise<void>\n /** Await all queued persisted mutations (tests, publish flows). */\n flushPersistence(): Promise<void>\n}\n\nconst { Context: CmsContext, useRequired: useCms } = createRequiredContext<CmsStore>('Cms')\n\nfunction primaryField(collection: CollectionDef): string {\n return titleFieldOf(collection)?.name ?? collection.fields[0]?.name ?? 'id'\n}\n\n/**\n * EC-316 (bug fix) — mint a fresh, COLLISION-FREE document id for `+ New`.\n *\n * `seq` is an in-memory, per-session counter (reset to 0 on every reload). A\n * document minted `new-<collection>-<n>` in a PRIOR session can already occupy\n * whatever `n` this session's counter would next reissue — the pre-fix bug:\n * `+ New` on a `post` collection that already held a (possibly published)\n * `new-post-1` handed out that SAME id again, silently opening the existing\n * document for editing instead of creating a fresh draft. Walking the counter\n * past every id already in `existingIds` makes the mint collision-free\n * regardless of what a prior session left behind.\n */\nexport function mintDocumentId(\n collectionId: string,\n seq: { current: number },\n existingIds: ReadonlySet<string>,\n): string {\n let id: string\n do {\n seq.current += 1\n id = `new-${collectionId}-${seq.current}`\n } while (existingIds.has(id))\n return id\n}\n\n/**\n * Build a fresh document for `collectionId`: a collision-free id (EC-316, via\n * {@link mintDocumentId} against every id `existingDocs` already holds for\n * this collection) and the collection's declared field defaults (EC-297, via\n * `seedDefaults`). Pure — the sensitive part of the insert sequence shared by\n * `createDocument` and `ensureSingletonDocument`'s empty branch (via the\n * private `insertNewDocument` below), factored out so it's unit-testable\n * without a `CmsProvider`.\n */\nexport function buildNewDocument(\n collectionId: string,\n registry: CollectionRegistry,\n seq: { current: number },\n existingDocs: readonly CmsDocument[],\n): CmsDocument {\n const existingIds = new Set(\n existingDocs.filter((d) => d.collection === collectionId).map((d) => d.id),\n )\n const id = mintDocumentId(collectionId, seq, existingIds)\n const collection = registry.get(collectionId)\n return { collection: collectionId, id, values: collection ? seedDefaults(collection) : {} }\n}\n\n/**\n * Does `docs` already hold a document for `collectionId`? `ensureSingletonDocument`'s\n * empty branch re-checks this INSIDE the `setDocuments` updater (against the\n * latest `prev`, not a stale snapshot) so a concurrent invocation — StrictMode's\n * double-invoked effect, or a second caller racing the same synchronous guard —\n * can never materialize a second singleton document.\n */\nexport function hasDocumentFor(docs: readonly CmsDocument[], collectionId: string): boolean {\n return docs.some((d) => d.collection === collectionId)\n}\n\n/**\n * Surface a duplicate `initial: true` across a collection's config views (EC-343/\n * EC-444) as a visible, one-time console warning — never a silent swallow. This is a\n * developer config mistake (editors can't fix config-as-code), so it takes the same\n * warn-once console channel the i18n runtime uses for config problems, not an editor\n * banner; the first-declared still seeds deterministically. Deduped per collection id.\n */\nconst warnedDuplicateDefaultCollections = new Set<string>()\nfunction warnDuplicateDefaultViews(collection: CollectionDef): void {\n if (warnedDuplicateDefaultCollections.has(collection.id)) return\n const issues = configViewIssues(collection)\n if (issues.length === 0) return\n warnedDuplicateDefaultCollections.add(collection.id)\n if (typeof console !== 'undefined') console.warn(`[views] ${issues[0]!.message}`)\n}\n\n/**\n * Surface the DEPRECATED `default: true` view flag (EC-444) as a one-time console\n * warning per collection — never silent. `default` (the view flag) is renamed to\n * `initial`; it is read as an alias for one release and removed next release. Same\n * warn-once channel as the duplicate check; deduped per collection id.\n */\nconst warnedDeprecatedDefaultCollections = new Set<string>()\nfunction warnDeprecatedDefaultFlag(collection: CollectionDef): void {\n if (warnedDeprecatedDefaultCollections.has(collection.id)) return\n const ids = deprecatedDefaultFlagViewIds(collection)\n if (ids.length === 0) return\n warnedDeprecatedDefaultCollections.add(collection.id)\n if (typeof console !== 'undefined') {\n console.warn(\n `[views] Collection \"${collection.id}\" uses the deprecated view flag \\`default\\` on ${ids.join(', ')}; rename it to \\`initial\\` (EC-444 — \\`default\\` is removed next release).`,\n )\n }\n}\n\n/** The unnamed built-in view: no filters, no sort, every field visible. */\nfunction defaultView(\n collection: CollectionDef | undefined,\n pseudo: readonly string[] = [],\n): SavedView {\n return {\n id: ALL_VIEW_ID,\n name: translate('cms.list.view.all'),\n state: collection\n ? defaultViewState(collection, pseudo)\n : { filters: [], sort: null, columns: [], hidden: [] },\n }\n}\n\n/**\n * The CMS session store (EC-141): documents and collections are optimistic,\n * synchronous session state (live validation while typing); every mutation —\n * create/save/delete/state transitions — is mirrored onto the operations\n * layer (`documents.*` / `schema.*` commands) through {@link createCmsPersister}.\n * Failed/denied commands surface as {@link CmsStore.persistError}.\n */\nexport function CmsProvider({\n children,\n projectId,\n initialCollections,\n initialDocuments,\n initialPublishedKeys,\n initialTimestamps,\n initialLocaleConfig,\n}: {\n children: ReactNode\n /** Enables persistence through the shared operations client. */\n projectId?: string\n /** Seed collections (e.g. from an imported starter kit, EC-119); defaults to the samples. */\n initialCollections?: CollectionDef[]\n initialDocuments?: CmsDocument[]\n /**\n * Published document keys from hydration (EC-224): the version pointer\n * (`publishedVersion` set). Absent (kit / fixture sessions) → the sample\n * fixtures' published set (`samplePublishedKeys`).\n */\n initialPublishedKeys?: readonly string[]\n /**\n * Per-document last-write timestamps from hydration (EC-445), keyed by\n * `documentKey` (`collection:id`) → ISO string. Backs the `$updatedAt` list column.\n * Absent (playground / kit session) → the seeded documents get a session-start\n * timestamp so the column is never blank, then re-stamped on edits.\n */\n initialTimestamps?: Record<string, string>\n /** Locale config for the seeded content; defaults to the sample config. */\n initialLocaleConfig?: LocaleConfig\n}) {\n const [documents, setDocuments] = useState<CmsDocument[]>(() => {\n const seeded = (initialDocuments ?? sampleDocuments).map((d) => structuredClone(d))\n // EC-320 (0.0.44 follow-up): merge any documents STAGED by the\n // Components-view \"Use in document…\" transfer — a cross-mount handoff in\n // EVERY mode now (see document-staging.ts), not just the playground. The\n // merge rule itself stays mode-aware there: playground's seeded set is a\n // static baseline that never reflects a write (staged always wins);\n // Convex's is a fresh per-mount hydration query (staged fills gaps only,\n // dropped once the seeded set actually carries the key).\n return consumeStagedDocuments(projectId, seeded)\n })\n // Published-ness as the version POINTER (EC-224), decoupled from the flat\n // `state` enum: seeded from hydration's pointer set, or — when none is supplied\n // — the canonical sample published set for the playground. A kit's imported\n // content (`initialDocuments` without a pointer set) starts unpublished\n // (drafts) until an editor publishes it. The flat `state` is never consulted.\n const [publishedKeys, setPublishedKeys] = useState<Set<string>>(() => {\n if (initialPublishedKeys) return new Set(initialPublishedKeys)\n return new Set(initialDocuments ? [] : samplePublishedKeys)\n })\n // EC-445: per-document last-write timestamps behind the `$updatedAt` column.\n // Seeded from hydration (connected: the persisted `cmsDocuments.updatedAt`), then\n // re-stamped on the common edit paths. A seeded document with no hydrated timestamp\n // (the playground fixtures / a kit) gets a session-start stamp so the column is\n // never a wall of blanks; a fresh draft is stamped when it is created.\n const [updatedAtByKey, setUpdatedAtByKey] = useState<Map<string, string>>(() => {\n const now = new Date().toISOString()\n const map = new Map<string, string>()\n if (initialTimestamps) {\n for (const [key, value] of Object.entries(initialTimestamps)) map.set(key, value)\n }\n for (const doc of initialDocuments ?? sampleDocuments) {\n const key = documentKey(doc)\n if (!map.has(key)) map.set(key, now)\n }\n return map\n })\n const stampUpdatedAt = useCallback(\n (ref: DocumentRef, iso: string = new Date().toISOString()) => {\n setUpdatedAtByKey((prev) => {\n const next = new Map(prev)\n next.set(documentKey(ref), iso)\n return next\n })\n },\n [],\n )\n const documentUpdatedAt = useCallback(\n (ref: DocumentRef) => updatedAtByKey.get(documentKey(ref)),\n [updatedAtByKey],\n )\n const [activeViews, setActiveViews] = useState<Record<string, string>>({})\n // The live table state per collection where it diverges from the active\n // view; absent key = exactly the active view's state (not dirty).\n const [tableStates, setTableStates] = useState<Record<string, TableViewState>>({})\n // Collections are stateful so AI-generated schemas (EC-097) can be accepted\n // into the session. The session schema IS the source the sort/filter\n // offering follows (EC-177 gap 3): hydrated sessions receive the persisted\n // schema via `initialCollections`; the fixture fallback is the canonical\n // cms-core sample schema WITH its declared `filterable` flags — no\n // session-side widenings, so the studio never offers a field the backend's\n // delivery engine would reject.\n const [collections, setCollections] = useState<CollectionDef[]>(() => [\n ...(initialCollections ?? sampleFilterableCollections),\n ])\n const [persistError, setPersistError] = useState<OperationError | null>(null)\n const seq = useRef(0)\n // EC-274: collection ids whose lone singleton document this session has already\n // created — a synchronous guard so a re-invoked effect (or StrictMode's double\n // mount) never materializes a second document under a freshly generated id.\n const ensuredSingletons = useRef<Set<string>>(new Set())\n\n // Latest session state for the persister's lazy baseline (no re-subscribing).\n const collectionsRef = useRef(collections)\n collectionsRef.current = collections\n const documentsRef = useRef(documents)\n documentsRef.current = documents\n\n const persisterRef = useRef<CmsPersister | null>(null)\n if (persisterRef.current === null && projectId !== undefined) {\n persisterRef.current = createCmsPersister({\n projectId,\n getOperations: async () => (await getStudioOperations()).operations,\n getCollections: () => collectionsRef.current,\n getDocuments: () => documentsRef.current,\n // EC-277: self-type composition static props on write (the manifest half of\n // the lens), so extraction stays schema-free. Document fields self-type via\n // the schema alone (above); the registry adds blocks/embed prop coverage.\n lookupManifest: studioManifestLookup(),\n onError: setPersistError,\n })\n }\n\n const registry = useMemo(() => createCollectionRegistry(collections), [collections])\n const store = useMemo(() => createDocumentStore(documents), [documents])\n const localeConfig = initialLocaleConfig ?? sampleLocaleConfig\n\n // Asset existence is validated against the REAL asset library (assets live in\n // their own repository, not as CMS documents). With the ambient AssetsProvider\n // present, the oracle is the set of uploaded asset ids — but only once loaded;\n // while it loads we are optimistic so a valid upload is never transiently\n // flagged \"unknown\". With no provider (tests/fixtures), the oracle is absent\n // and asset existence falls back to the document store.\n const assetStore = useOptionalAssets()\n const assetExists = useMemo<((id: string) => boolean) | undefined>(() => {\n if (!assetStore) return undefined\n if (assetStore.status !== 'ready') return () => true\n const ids = new Set(assetStore.assets.map((asset) => asset.id))\n return (id) => ids.has(id)\n }, [assetStore])\n\n // The ambient studio locale (EC-176): this session's locale config drives\n // the switcher options; every CMS surface follows the one active locale.\n const { locale: activeLocale } = useStudioLocale()\n useEffect(() => {\n configureStudioLocales(localeConfig)\n }, [localeConfig])\n\n const getCollection = useCallback((id: string) => registry.get(id), [registry])\n\n const getDocument = useCallback(\n (ref: DocumentRef) => documents.find((d) => matchesRef(d, ref)),\n [documents],\n )\n\n const titleOf = useCallback(\n (ref: DocumentRef) => {\n const doc = documents.find((d) => matchesRef(d, ref))\n const collection = registry.get(ref.collection)\n if (!doc || !collection) return ref.id\n // EC-296/EC-242: a function `titleField` (title pattern) composes the title\n // from the document's resolved values (active locale). Only resolve the full\n // value set when a function is declared — the common string `titleField` case\n // still resolves the single title field below (primaryField === the title field).\n if (typeof collection.titleField === 'function') {\n const values: Record<string, unknown> = {}\n for (const field of collection.fields) {\n values[field.name] = resolveField(collection, doc, field.name, activeLocale, localeConfig).value\n }\n return resolveDocumentTitle(collection, values, ref.id)\n }\n // Resolve through the locale layer in the ambient active locale (EC-176)\n // with EC-018 fallback, so localized titles follow the switcher.\n const { value } = resolveField(\n collection,\n doc,\n primaryField(collection),\n activeLocale,\n localeConfig,\n )\n return typeof value === 'string' && value ? value : ref.id\n },\n [documents, registry, localeConfig, activeLocale],\n )\n\n const saveDocument = useCallback(\n (doc: CmsDocument) => {\n // Replace-or-append (upsert): a brand-new document must still land even\n // though nothing in the session matches its ref yet.\n setDocuments((prev) => upsertDoc(prev, doc))\n stampUpdatedAt(doc) // EC-445: a save bumps the $updatedAt column\n persisterRef.current?.upsertDocument(doc)\n },\n [stampUpdatedAt],\n )\n\n const commitFieldEdit = useCallback(\n (input: CellCommitInput): Promise<CellCommitOutcome> => {\n // Pure map-replace: an edit always targets a document already open in\n // the session, so a miss (already gone) is a no-op, never an append.\n const replaceWith = (doc: CmsDocument) => setDocuments((prev) => replaceDoc(prev, doc))\n const persister = persisterRef.current\n return commitCellEdit(\n {\n registry,\n documents: documentsRef.current,\n localeConfig,\n // EC-445: the optimistic apply bumps the $updatedAt column (a rollback\n // leaves it — it self-corrects on the next hydration).\n applySession: (doc) => {\n replaceWith(doc)\n stampUpdatedAt(doc)\n },\n rollbackSession: replaceWith,\n ...(persister && projectId !== undefined\n ? {\n dispatch: async (next: CmsDocument) => {\n // Make sure the persisted baseline + every queued mutation\n // landed first, then issue the commit's single command.\n await persister.ensureBaseline()\n const { operations } = await getStudioOperations()\n return operations.documents.upsert({ projectId, document: next })\n },\n }\n : {}),\n },\n input,\n )\n },\n [registry, localeConfig, projectId, stampUpdatedAt],\n )\n\n // Shared insert sequence (EC-326): existingIds/mint/seedDefaults (via\n // `buildNewDocument`) + optimistic append + persist, consumed by both\n // `createDocument` (always inserts) and `ensureSingletonDocument`'s empty\n // branch (`guardExisting: true` — re-checks \"no document for this collection\n // yet\" against the LATEST `prev` inside the `setDocuments` updater, not the\n // `documentsRef.current` snapshot the caller already checked, so a\n // concurrent invocation — StrictMode's double-invoked effect — can never\n // materialize a second singleton document).\n const insertNewDocument = useCallback(\n (collectionId: string, options?: { guardExisting?: boolean }): CmsDocument => {\n const doc = buildNewDocument(collectionId, registry, seq, documentsRef.current)\n setDocuments((prev) =>\n options?.guardExisting && hasDocumentFor(prev, collectionId) ? prev : [...prev, doc],\n )\n stampUpdatedAt(doc) // EC-445: a fresh draft's $updatedAt starts at creation time\n persisterRef.current?.upsertDocument(doc)\n return doc\n },\n [registry, stampUpdatedAt],\n )\n\n const createDocument = useCallback(\n (collectionId: string): DocumentRef => {\n const doc = insertNewDocument(collectionId)\n return { collection: collectionId, id: doc.id }\n },\n [insertNewDocument],\n )\n\n // EC-274 (re-scopes EC-217): a singleton is a UI lens, not a fixed id. Resolve\n // the collection's lone document and return its ref; if none exists yet, create\n // one with a NORMAL generated id (never the collection id — no code ever names a\n // literal doc id). Idempotent under React effects/StrictMode: the create guard\n // keys on \"any document in this collection\", so a re-invocation never adds a\n // second. On drift (>1 doc) the studio routes to the list, so this defensively\n // returns the first; the empty draft persists like any create.\n const ensureSingletonDocument = useCallback(\n (collectionId: string): DocumentRef => {\n const collection = registry.get(collectionId)\n const resolution = collection\n ? resolveSingletonDocument(collection, documentsRef.current)\n : ({ kind: 'empty' } as const)\n if (resolution.kind === 'ready') {\n return { collection: collectionId, id: resolution.doc.id }\n }\n if (resolution.kind === 'drift') {\n return { collection: collectionId, id: resolution.docs[0]!.id }\n }\n // Empty: create the lone document once. The ref guard (synchronous) plus the\n // updater's \"any doc in collection\" check make this idempotent under a\n // re-invoked effect or StrictMode's double mount — never a second draft.\n const existing = documentsRef.current.find((d) => d.collection === collectionId)\n if (existing) return { collection: collectionId, id: existing.id }\n if (ensuredSingletons.current.has(collectionId)) {\n return { collection: collectionId, id: `new-${collectionId}-pending` }\n }\n ensuredSingletons.current.add(collectionId)\n // EC-316: same collision-free mint as `createDocument` (via the shared\n // `insertNewDocument` — defensive here, the singleton-empty branch only\n // runs when no document exists yet).\n const doc = insertNewDocument(collectionId, { guardExisting: true })\n return { collection: collectionId, id: doc.id }\n },\n [registry, insertNewDocument],\n )\n\n const deleteDocument = useCallback((ref: DocumentRef) => {\n setDocuments((prev) => removeDoc(prev, ref))\n persisterRef.current?.deleteDocument(ref)\n }, [])\n\n // EC-224: published-ness IS the version pointer (`publishedKeys`) — the SOLE\n // studio source of truth, read via `isPublished`. The live row stays a\n // continuous draft (Sanity model); no flat `state` mirror is maintained. Every\n // reader now consults the pointer (the table badge/$state via `isPublished`,\n // the preview engine via the pin), so the flat field is read by nothing here.\n const setPublished = useCallback((ref: DocumentRef, published: boolean) => {\n const key = documentKey(ref)\n setPublishedKeys((prev) => {\n if (prev.has(key) === published) return prev\n const next = new Set(prev)\n if (published) next.add(key)\n else next.delete(key)\n return next\n })\n }, [])\n\n const isPublished = useCallback(\n (ref: DocumentRef) => publishedKeys.has(documentKey(ref)),\n [publishedKeys],\n )\n\n // Reconcile published-ness for a ref against the AUTHORITATIVE backend record\n // (EC-225): the optimistic flip is a guess; once the queued op settles we read\n // the actual pin so the badge can never claim a state the backend refused\n // (a publish blocked by field rules, an unpublish blocked by a strict ref).\n const reconcilePublished = useCallback(\n async (ref: DocumentRef) => {\n if (projectId === undefined) return\n const { operations } = await getStudioOperations()\n const record = await operations.documents.get({ projectId, ref })\n if (record.ok) {\n setPublished(ref, record.value.publishedVersion !== undefined)\n // EC-445: publish/unpublish patches `updatedAt` — adopt the authoritative\n // value so the $updatedAt column reflects the actual write, not a guess.\n if (record.value.updatedAt) stampUpdatedAt(ref, record.value.updatedAt)\n }\n },\n [projectId, setPublished, stampUpdatedAt],\n )\n\n const publishDocument = useCallback(\n async (ref: DocumentRef) => {\n setPublished(ref, true) // optimistic\n // EC-273: no clearing here — the draft is already free of conditionally-hidden\n // values (the editor clears them on write), so the snapshot the publish op\n // pins is clean by construction.\n persisterRef.current?.publishDocument(ref)\n await persisterRef.current?.flush()\n await reconcilePublished(ref)\n },\n [setPublished, reconcilePublished],\n )\n\n const unpublishDocument = useCallback(\n async (ref: DocumentRef) => {\n setPublished(ref, false) // optimistic\n persisterRef.current?.unpublishDocument(ref)\n await persisterRef.current?.flush()\n await reconcilePublished(ref)\n },\n [setPublished, reconcilePublished],\n )\n\n const loadDocumentVersions = useCallback(\n async (ref: DocumentRef): Promise<DocumentVersionsView> => {\n // No persisted backend (fixture/playground): no recorded history.\n if (projectId === undefined) return { versions: [] }\n const { operations } = await getStudioOperations()\n const [versionsRes, recordRes] = await Promise.all([\n operations.documents.listVersions({ projectId, ref }),\n operations.documents.get({ projectId, ref }),\n ])\n if (!versionsRes.ok) {\n setPersistError(versionsRes.error)\n return { versions: [] }\n }\n // The pinned (live) version comes off the document record; a never-saved\n // doc simply has no record (and no versions) — not an error to surface.\n const publishedVersion = recordRes.ok ? recordRes.value.publishedVersion : undefined\n return {\n versions: versionsRes.value,\n ...(publishedVersion !== undefined ? { publishedVersion } : {}),\n }\n },\n [projectId],\n )\n\n const restoreDocumentVersion = useCallback(\n async (\n ref: DocumentRef,\n version: number,\n scope?: RestoreScope,\n ): Promise<CmsDocument | null> => {\n if (projectId === undefined) return null\n // Land any queued edits before the restore reads the current draft to\n // snapshot it (same ordering contract as commitFieldEdit/runBulk). This is\n // what makes a granular (field/block) restore merge over the LATEST draft.\n await persisterRef.current?.ensureBaseline()\n const { operations } = await getStudioOperations()\n const result = await operations.documents.restore({\n projectId,\n ref,\n version,\n ...(scope ? { scope } : {}),\n })\n if (!result.ok) {\n setPersistError(result.error)\n return null\n }\n const restored = result.value.document\n // Pure map-replace: a restore always targets a document already open in\n // the session.\n setDocuments((prev) => replaceDoc(prev, restored))\n return restored\n },\n [projectId],\n )\n\n const validate = useCallback(\n (doc: CmsDocument) =>\n validateDocument(registry, doc, {\n store,\n localeConfig,\n validateComposition,\n validateRichTextEmbeds,\n // EC-224: the EC-173 weak-reference warning sources published-ness from\n // the version pointer, so editing a published doc that references an\n // unpublished target surfaces the fallback warning again (it had gone\n // inert once the flat `state` mirror was dropped in B-3b).\n isPublished,\n assetExists,\n }),\n [registry, store, localeConfig, isPublished, assetExists],\n )\n\n const importDocuments = useCallback(\n (collectionId: string, raw: unknown[]): ImportReport => {\n const report: ImportReport = { added: 0, rejected: [] }\n // Pre-parse so intra-batch relation/asset targets resolve during validation.\n const parsedBatch: CmsDocument[] = []\n const schemaFails: { item: unknown; error: ReturnType<typeof documentSchema.safeParse> }[] =\n []\n for (const item of raw) {\n const parsed = documentSchema.safeParse({ ...(item as object), collection: collectionId })\n if (parsed.success) parsedBatch.push(parsed.data)\n else schemaFails.push({ item, error: parsed })\n }\n for (const { item, error } of schemaFails) {\n report.rejected.push({\n id: (item as { id?: string })?.id ?? translate('cms.list.import.noId'),\n issues: (error.success ? [] : error.error.issues).map((e) => ({\n code: 'invalid-field-value' as const,\n severity: 'error' as const,\n message: e.message,\n path: e.path.map((p) => (typeof p === 'symbol' ? String(p) : p)),\n })),\n })\n }\n // Validate each against existing docs PLUS the rest of the batch.\n const batchStore = createDocumentStore([...documents, ...parsedBatch])\n const accepted: CmsDocument[] = []\n for (const doc of parsedBatch) {\n const issues = validateDocument(registry, doc, { store: batchStore, localeConfig, assetExists })\n const errors = issues.filter((iss) => iss.severity === 'error')\n if (errors.length > 0) report.rejected.push({ id: doc.id, issues: errors })\n else accepted.push(doc)\n }\n if (accepted.length > 0) {\n // Replace-or-append (upsert): an imported row may be brand new to the\n // session, so each accepted document must land even with no prior\n // entry for its ref.\n setDocuments((prev) => accepted.reduce((acc, doc) => upsertDoc(acc, doc), prev))\n for (const doc of accepted) persisterRef.current?.upsertDocument(doc)\n // EC-224: imports land as the working DRAFT. Publish-ness is the version\n // pointer (`publishedKeys`), set by publishing — never carried in the\n // imported row — so an import never auto-publishes; the editor publishes\n // explicitly afterward.\n report.added = accepted.length\n }\n return report\n },\n [registry, documents, localeConfig, assetExists],\n )\n\n const isFieldReadOnly = useCallback((field: FieldDef) => field.form?.readOnly === true, [])\n\n // --- Views (EC-246b: config-as-code) --------------------------------------\n\n // EC-445: the reserved pseudo-columns a CMS collection's list surfaces. Every\n // `cmsDocuments` collection has a publish lifecycle + materialized timestamps\n // ($state + $updatedAt always apply); $url applies only where the deployment\n // resolves a delivery route for it (mirrors the live-URL column's own guard).\n const pseudoColumnsFor = useCallback(\n (collectionId: string): string[] => {\n const collection = registry.get(collectionId)\n if (!collection) return []\n const routable = resolveDeploymentRoutes().some(\n (route) => route.document?.collection === collectionId,\n )\n return pseudoColumns(collection, { publishing: true, timestamps: true, routable })\n },\n [registry],\n )\n\n const viewsOf = useCallback(\n (collectionId: string): SavedView[] => {\n // The baseline view plus the collection's config-declared views (EC-246b/EC-444).\n // Views are PRESENTATION, read live from elytra.config.ts (AD-11) — not the\n // persisted content schema the session booted from — so they reflect code\n // immediately without a re-seed (the persisted schema is only baselined on\n // first run). The EC-169 DB saved-view store is retired: shared views are\n // code, editors keep only transient in-session tweaks + Reset.\n //\n // EC-444: a config view with the reserved `id: 'default'` REPLACES the\n // synthesized \"All entries\" baseline verbatim (first tab); absent one, the\n // synthesized baseline leads. `resolveCollectionViews` owns that selection.\n const pseudo = pseudoColumnsFor(collectionId)\n const baseline = defaultView(registry.get(collectionId), pseudo)\n const configCollection = resolveDeploymentCollections().find((c) => c.id === collectionId)\n if (!configCollection) return [baseline]\n return resolveCollectionViews(configCollection, baseline, pseudo)\n },\n [registry, pseudoColumnsFor],\n )\n\n // The INITIAL active view for a collection (EC-343/EC-444): a config view flagged\n // `initial: true` seeds the first-load lens; else the baseline — the `id: 'default'`\n // override when present, else the synthesized \"All entries\" (`ALL_VIEW_ID`). Only\n // consulted before the editor has picked a view (`activeViews[id]` wins once set),\n // so transient switching + Reset are unaffected. A duplicate `initial` and any\n // deprecated `default` flag are each warned once (never silent).\n const initialViewId = useCallback((collectionId: string): string => {\n const configCollection = resolveDeploymentCollections().find((c) => c.id === collectionId)\n if (!configCollection) return ALL_VIEW_ID\n warnDuplicateDefaultViews(configCollection)\n warnDeprecatedDefaultFlag(configCollection)\n const initial = defaultConfigViewId(configCollection)\n if (initial) return initial\n return hasDefaultViewOverride(configCollection) ? DEFAULT_VIEW_OVERRIDE_ID : ALL_VIEW_ID\n }, [])\n\n const activeViewOf = useCallback(\n (collectionId: string): SavedView => {\n const id = activeViews[collectionId] ?? initialViewId(collectionId)\n return (\n viewsOf(collectionId).find((view) => view.id === id) ??\n defaultView(registry.get(collectionId), pseudoColumnsFor(collectionId))\n )\n },\n [activeViews, initialViewId, viewsOf, registry, pseudoColumnsFor],\n )\n\n const tableStateOf = useCallback(\n (collectionId: string): TableViewState =>\n tableStates[collectionId] ?? activeViewOf(collectionId).state,\n [tableStates, activeViewOf],\n )\n\n const dropTableState = useCallback((collectionId: string) => {\n setTableStates((prev) => {\n if (!(collectionId in prev)) return prev\n const next = { ...prev }\n delete next[collectionId]\n return next\n })\n }, [])\n\n const setActiveView = useCallback(\n (collectionId: string, viewId: string) => {\n setActiveViews((prev) => ({ ...prev, [collectionId]: viewId }))\n dropTableState(collectionId)\n },\n [dropTableState],\n )\n\n // --- Bulk actions (EC-169) ------------------------------------------------\n\n const runBulk = useCallback(\n async (\n collectionId: string,\n ids: readonly string[],\n action: BulkAction,\n setField?: BulkSetField,\n ): Promise<BulkReport> => {\n const collection = registry.get(collectionId)\n // A set-field needs both the field payload AND the collection def to fold\n // the value the locale-aware way — guard so a misconfigured call fails\n // loud rather than silently no-opping each item.\n if (action === 'set-field' && (!setField || !collection)) {\n return {\n action,\n ...(setField ? { setField } : {}),\n results: ids.map((id) => ({\n ref: { collection: collectionId, id },\n title: titleOf({ collection: collectionId, id }),\n ok: false,\n reason: translate('cms.list.bulk.error.invalidSetField'),\n error: { code: 'unknown', message: 'Invalid set-field request.' },\n })),\n }\n }\n // The next document for a set-field item: fold the value into the active\n // locale's bag (localized) or the shared `values` (non-localized).\n const setFieldDoc = (doc: CmsDocument): CmsDocument =>\n applyCellValue(collection!, doc, setField!.field, activeLocale, setField!.value)\n\n let dispatch:\n | ((action: BulkAction, ref: DocumentRef) => Promise<OperationResult<unknown>>)\n | undefined\n const persister = persisterRef.current\n if (persister && projectId !== undefined) {\n // Pending queued mutations + baseline land first, then one awaited\n // command per item (same ordering contract as commitFieldEdit).\n await persister.ensureBaseline()\n const { operations } = await getStudioOperations()\n dispatch = (bulkAction, ref) => {\n if (bulkAction === 'delete') return operations.documents.delete({ projectId, ref })\n if (bulkAction === 'publish') return operations.documents.publish({ projectId, ref })\n if (bulkAction === 'unpublish') return operations.documents.unpublish({ projectId, ref })\n // set-field: upsert the document carrying the new value. The write\n // path self-types it through the schema lens (EC-277); a scalar field\n // stores its scalar as-is.\n const current = documentsRef.current.find((d) => matchesRef(d, ref))\n if (!current) {\n return Promise.resolve<OperationResult<unknown>>({\n ok: false,\n error: {\n code: 'not-found',\n message: 'Document is no longer in the session.',\n entity: 'cms-document',\n key: `${ref.collection}:${ref.id}`,\n },\n })\n }\n return operations.documents.upsert({ projectId, document: setFieldDoc(current) })\n }\n }\n return runBulkAction(\n {\n documents: documentsRef.current,\n titleOf,\n validate: (doc) =>\n validateDocument(registry, doc, {\n store: createDocumentStore(documentsRef.current),\n localeConfig,\n // EC-225: include the composition validators so a bulk PUBLISH\n // gates blocks/richText validity the same way the detail editor\n // does — the operations-layer publish gate has no component\n // registry, so composition validity is a studio-validation invariant.\n validateComposition,\n validateRichTextEmbeds,\n assetExists,\n }),\n // EC-425: bulk publish joins the single-document clean point — the\n // SAME shared hidden-strip `doPublish` runs (EC-273 field values +\n // EC-394 component props, session registry), per item.\n ...(collection\n ? { cleanForPublish: (doc: CmsDocument) => cleanHiddenForPublish(collection, doc) }\n : {}),\n // Land a cleaned draft exactly the way the editor's publish does:\n // session apply + the persister's self-typing upsert (EC-277 manifest\n // lens), flushed so the serial queue lands the upsert BEFORE the\n // awaited publish command snapshots the stored draft.\n applyCleaned: async (_ref, cleaned) => {\n setDocuments((prev) => replaceDoc(prev, cleaned))\n const persister = persisterRef.current\n if (persister && projectId !== undefined) {\n persister.upsertDocument(cleaned)\n await persister.flush()\n }\n },\n // EC-224: a succeeded publish/unpublish moves the version pointer\n // (`publishedKeys`) via setPublished — there is no separate flat\n // `state` mirror to keep in sync (published-ness is derived from the\n // pointer set).\n applyState: (ref, state) => setPublished(ref, state === 'published'),\n applyDelete: (ref) => setDocuments((prev) => removeDoc(prev, ref)),\n // EC-247: fold the new value into the session document (same\n // locale-aware path the dispatched upsert used). Not a plain\n // `replaceDoc` — the replacement is computed FROM each matched\n // document (`setFieldDoc(d)`), not a fixed value to swap in.\n applySetField: (ref) =>\n setDocuments((prev) => prev.map((d) => (matchesRef(d, ref) ? setFieldDoc(d) : d))),\n ...(dispatch ? { dispatch } : {}),\n },\n collectionId,\n ids,\n action,\n setField,\n )\n },\n [projectId, titleOf, registry, localeConfig, activeLocale, setPublished, assetExists],\n )\n\n const store$ = useMemo<CmsStore>(\n () => ({\n ...(projectId !== undefined ? { projectId } : {}),\n collections,\n localeConfig,\n activeLocale,\n getCollection,\n documentsOf: (collectionId) => documents.filter((d) => d.collection === collectionId),\n getDocument,\n titleOf,\n saveDocument,\n commitFieldEdit,\n createDocument,\n ensureSingletonDocument,\n deleteDocument,\n isPublished,\n documentUpdatedAt,\n publishDocument,\n unpublishDocument,\n loadDocumentVersions,\n restoreDocumentVersion,\n importDocuments,\n validate,\n isFieldReadOnly,\n viewsOf,\n activeViewId: (collectionId) => activeViews[collectionId] ?? initialViewId(collectionId),\n setActiveView,\n tableStateOf,\n setTableState: (collectionId, update) =>\n setTableStates((prev) => {\n const current = prev[collectionId] ?? activeViewOf(collectionId).state\n const next = typeof update === 'function' ? update(current) : update\n return { ...prev, [collectionId]: next }\n }),\n isViewDirty: (collectionId) => {\n const working = tableStates[collectionId]\n if (working === undefined) return false\n const active = activeViewOf(collectionId).state\n const collection = registry.get(collectionId)\n if (collection === undefined) return !viewStatesEqual(working, active)\n // Compare schema-resolved forms (EC-213): a column-order reconciliation\n // or a stale `hidden` entry must not read as an unsaved edit. EC-445: the\n // pseudo-column universe must match so a reserved column never reads as a diff.\n const pseudo = pseudoColumnsFor(collectionId)\n return !viewStatesEqual(\n canonicalViewState(collection, working, pseudo),\n canonicalViewState(collection, active, pseudo),\n )\n },\n resetTableState: dropTableState,\n runBulk,\n addCollection: (def) =>\n setCollections((prev) => [...prev.filter((c) => c.id !== def.id), def]),\n persistError,\n clearPersistError: () => setPersistError(null),\n ensurePersistedBaseline: () => persisterRef.current?.ensureBaseline() ?? Promise.resolve(),\n flushPersistence: () => persisterRef.current?.flush() ?? Promise.resolve(),\n }),\n [\n projectId,\n collections,\n documents,\n localeConfig,\n activeLocale,\n getCollection,\n getDocument,\n titleOf,\n saveDocument,\n commitFieldEdit,\n createDocument,\n ensureSingletonDocument,\n deleteDocument,\n isPublished,\n documentUpdatedAt,\n publishDocument,\n unpublishDocument,\n loadDocumentVersions,\n restoreDocumentVersion,\n importDocuments,\n validate,\n isFieldReadOnly,\n viewsOf,\n activeViews,\n activeViewOf,\n initialViewId,\n tableStates,\n tableStateOf,\n setActiveView,\n dropTableState,\n runBulk,\n registry,\n pseudoColumnsFor,\n persistError,\n ],\n )\n\n return <CmsContext.Provider value={store$}>{children}</CmsContext.Provider>\n}\n\nexport { useCms }\n\nexport { primaryField }\nexport type { Locale }\n"]}
|
|
@@ -7,20 +7,21 @@ import { Button, Code, DropdownMenu, DropdownMenuContent, DropdownMenuItem, Drop
|
|
|
7
7
|
import { cn } from '@elytracms/studio/lib/utils';
|
|
8
8
|
import { localizedLabel, translate } from '@elytracms/studio/lib/i18n';
|
|
9
9
|
import { LocaleSwitcher, resolveDisplayedValue } from '@elytracms/studio/lib/locale';
|
|
10
|
-
import { EMPTY_SELECTION, STATE_FIELD, applyViewState, clearSelection, primaryColumn, selectAll, toggleRow, visibleColumns, visibleSelection, } from '@elytracms/studio/lib/cms-views';
|
|
10
|
+
import { EMPTY_SELECTION, PUBLISHED_AT_FIELD, STATE_FIELD, UPDATED_AT_FIELD, URL_FIELD, applyViewState, clearSelection, isPseudoColumn, primaryColumn, selectAll, toggleRow, visibleColumns, visibleSelection, } from '@elytracms/studio/lib/cms-views';
|
|
11
|
+
import { pseudoColumnsForSource } from '@elytracms/studio/lib/collection-view/collection-view-source';
|
|
11
12
|
import { cellEditKind, cellKey } from './cell-edit.js';
|
|
12
13
|
import { FallbackChip } from './cell.js';
|
|
13
14
|
import { EditableCell } from './editable-cell.js';
|
|
14
15
|
import { useCellEdit } from './use-cell-edit.js';
|
|
15
16
|
import { ImportDialog } from './import-export.js';
|
|
16
17
|
import { AssetThumb, useAssetRecord } from '../assets/asset-thumb.js';
|
|
17
|
-
import { fieldLabel } from './cms-labels.js';
|
|
18
|
+
import { fieldLabel, pseudoColumnLabel } from './cms-labels.js';
|
|
18
19
|
import { cmsIssueLabel } from '@elytracms/studio/lib/persona/labels';
|
|
19
20
|
import { TriangleAlert } from 'lucide-react';
|
|
20
21
|
import { BulkBar, BulkReportPanel } from './bulk-bar.js';
|
|
21
22
|
import { rowActionsFor } from './row-actions.js';
|
|
22
23
|
import { duplicateFromSource } from './duplicate-document.js';
|
|
23
|
-
import { CHECKBOX_COLUMN_WIDTH_REM, PRIMARY_COLUMN_WIDTH_REM, ROW_ACTIONS_COLUMN_WIDTH_REM,
|
|
24
|
+
import { CHECKBOX_COLUMN_WIDTH_REM, PRIMARY_COLUMN_WIDTH_REM, ROW_ACTIONS_COLUMN_WIDTH_REM, columnWidthRem, pseudoColumnWidthRem, } from './column-width.js';
|
|
24
25
|
import { ReferenceConfirmDialog } from './reference-confirm.js';
|
|
25
26
|
import { FilterControl } from './filter-builder.js';
|
|
26
27
|
import { DisplayMenu, ViewTabs } from './view-bar.js';
|
|
@@ -63,10 +64,14 @@ export function LoadedCollectionTable({ projectId, toolbarExtra, }) {
|
|
|
63
64
|
// The working view state (EC-169): filters + sort + columns, possibly dirty
|
|
64
65
|
// against the active saved view. The table renders exactly this state.
|
|
65
66
|
const viewState = source.viewState();
|
|
67
|
+
// EC-445: the reserved pseudo-columns this source surfaces ($state/$url/$updatedAt),
|
|
68
|
+
// folded into the column universe so they order/hide alongside real fields. The
|
|
69
|
+
// SAME list drives the Display picker (view-bar), so the universe never drifts.
|
|
70
|
+
const pseudo = pseudoColumnsForSource(source);
|
|
66
71
|
// EC-213: the title/link column is the first visible column; the rest follow
|
|
67
72
|
// in the view's column order. No separate primary-column selector.
|
|
68
|
-
const primary = primaryColumn(collection, viewState);
|
|
69
|
-
const columns = visibleColumns(collection, viewState).filter((name) => name !== primary);
|
|
73
|
+
const primary = primaryColumn(collection, viewState, pseudo);
|
|
74
|
+
const columns = visibleColumns(collection, viewState, pseudo).filter((name) => name !== primary);
|
|
70
75
|
const primaryFieldDef = collection.fields.find((f) => f.name === primary);
|
|
71
76
|
const docs = source.documents();
|
|
72
77
|
// EC-274/EC-284: collection-shape drift (a singleton with > 1 document; later
|
|
@@ -82,7 +87,11 @@ export function LoadedCollectionTable({ projectId, toolbarExtra, }) {
|
|
|
82
87
|
const visibleDocs = useMemo(
|
|
83
88
|
// EC-224: the `$state` filter/sort sources published-ness from the version
|
|
84
89
|
// POINTER (`source.publishing.isPublished`), not a flat `state` field.
|
|
85
|
-
|
|
90
|
+
// EC-445: the pseudo-DATE columns sort by the source's materialized timestamps.
|
|
91
|
+
() => applyViewState(collection, docs, source.localeConfig, viewState, (doc) => source.publishing?.isPublished({ collection: doc.collection, id: doc.id }) ?? false, {
|
|
92
|
+
updatedAt: (doc) => source.timestamps?.updatedAt({ collection: doc.collection, id: doc.id }),
|
|
93
|
+
publishedAt: (doc) => source.timestamps?.publishedAt({ collection: doc.collection, id: doc.id }),
|
|
94
|
+
}).docs, [collection, docs, source.localeConfig, viewState, source.publishing, source.timestamps]);
|
|
86
95
|
// EC-218: a collection with a `parent` self-relation can render as a nested
|
|
87
96
|
// tree (parents above their children, indented). Tree mode reorders the
|
|
88
97
|
// already-filtered rows depth-first — filters/sort still order siblings.
|
|
@@ -267,6 +276,8 @@ function DocumentsGrid({ projectId, collection, primary, primaryFieldDef, column
|
|
|
267
276
|
// the gate (mirrors the capability contract: the group is present iff the
|
|
268
277
|
// flag is set), narrowed once here so every render site below is type-safe.
|
|
269
278
|
const publishing = source.publishing;
|
|
279
|
+
// EC-445: per-document timestamps behind the $updatedAt/$publishedAt pseudo-cells.
|
|
280
|
+
const timestamps = source.timestamps;
|
|
270
281
|
const fieldByName = (name) => collection.fields.find((f) => f.name === name);
|
|
271
282
|
// Inline editing is a capability: a read-only rail yields no editable cells.
|
|
272
283
|
const editableFields = source.capabilities.inlineEdit
|
|
@@ -278,15 +289,27 @@ function DocumentsGrid({ projectId, collection, primary, primaryFieldDef, column
|
|
|
278
289
|
const cellEdit = useCellEdit({ collection, docs: sortedDocs, editableFields });
|
|
279
290
|
const selected = new Set(selectedIds);
|
|
280
291
|
const allSelected = sortedDocs.length > 0 && selectedIds.length === sortedDocs.length;
|
|
281
|
-
return (_jsx("div", { ref: cellEdit.containerRef, children: _jsxs("table", { className: "w-full table-fixed border-collapse text-sm", children: [_jsxs("colgroup", { children: [_jsx("col", { style: { width: `${CHECKBOX_COLUMN_WIDTH_REM}rem` } }), _jsx("col", { style: { width: `${PRIMARY_COLUMN_WIDTH_REM}rem` } }), columns.map((name) => (_jsx("col", { style: {
|
|
292
|
+
return (_jsx("div", { ref: cellEdit.containerRef, children: _jsxs("table", { className: "w-full table-fixed border-collapse text-sm", children: [_jsxs("colgroup", { children: [_jsx("col", { style: { width: `${CHECKBOX_COLUMN_WIDTH_REM}rem` } }), _jsx("col", { style: { width: `${PRIMARY_COLUMN_WIDTH_REM}rem` } }), columns.map((name) => (_jsx("col", { style: {
|
|
293
|
+
width: `${isPseudoColumn(name) ? pseudoColumnWidthRem(name) : columnWidthRem(fieldByName(name))}rem`,
|
|
294
|
+
} }, name))), hasRowActions ? _jsx("col", { style: { width: `${ROW_ACTIONS_COLUMN_WIDTH_REM}rem` } }) : null] }), _jsx("thead", { className: "sticky top-0 z-10 bg-background", children: _jsxs("tr", { className: "border-b border-border", children: [_jsx("th", { className: "px-3 py-2 text-left", children: _jsx(SelectionCheckbox, { checked: allSelected, indeterminate: selectedIds.length > 0 && !allSelected, label: translate('cms.list.selectAll'), testId: "select-all", onToggle: () => onToggleAll() }) }), _jsx(HeaderCell, { field: primary, label: primaryFieldDef ? fieldLabel(primaryFieldDef) : translate('cms.list.column.title'), sort: sort, onSort: onSort }), columns.map((name) => {
|
|
295
|
+
if (isPseudoColumn(name)) {
|
|
296
|
+
// $url is a derived value — not sortable (EC-216), so a plain header.
|
|
297
|
+
if (name === URL_FIELD) {
|
|
298
|
+
return (_jsx("th", { className: "px-3 py-2 text-left text-xs font-semibold text-muted-foreground", children: translate('cms.list.column.url') }, name));
|
|
299
|
+
}
|
|
300
|
+
return (_jsx(HeaderCell, { field: name, label: pseudoColumnLabel(name), sort: sort, onSort: onSort }, name));
|
|
301
|
+
}
|
|
282
302
|
const field = fieldByName(name);
|
|
283
303
|
return field ? (_jsx(HeaderCell, { field: name, label: fieldLabel(field), sort: sort, onSort: onSort }, name)) : null;
|
|
284
|
-
}),
|
|
304
|
+
}), hasRowActions ? (_jsx("th", { className: "px-2 py-2 text-right", children: _jsx("span", { className: "sr-only", children: translate('cms.list.rowActionsColumnLabel') }) })) : null] }) }), _jsx("tbody", { children: sortedDocs.map((doc) => (_jsxs("tr", { className: cn('group border-b border-border/60 hover:bg-muted/40', selected.has(doc.id) && 'bg-primary/5'), children: [_jsx("td", { className: "px-3 py-2 align-middle", children: _jsx(SelectionCheckbox, { checked: selected.has(doc.id), label: translate('cms.list.selectRow', { id: doc.id }), testId: `select-row-${doc.id}`, onToggle: (shift) => onToggleRow(doc.id, shift) }) }), _jsx("td", { className: "px-3 py-2 align-middle", children: _jsx(PrimaryCell, { projectId: projectId, collection: collection, doc: doc, primary: primary, depth: depthById?.get(doc.id) ?? 0, locale: source.activeLocale, config: source.localeConfig, detailPath: source.detailPath }) }), columns.map((name) => {
|
|
305
|
+
if (isPseudoColumn(name)) {
|
|
306
|
+
return (_jsx("td", { className: "px-3 py-2 align-middle", children: _jsx(PseudoCell, { name: name, docId: doc.id, collectionId: collectionId, publishing: publishing, timestamps: timestamps, url: urlByDocId?.get(doc.id), locale: source.activeLocale }) }, name));
|
|
307
|
+
}
|
|
285
308
|
const field = fieldByName(name);
|
|
286
309
|
const coord = { docId: doc.id, field: name };
|
|
287
310
|
const key = cellKey(coord);
|
|
288
311
|
return (_jsx("td", { className: "px-3 py-2 align-middle", children: field ? (_jsx(EditableCell, { collection: collection, doc: doc, field: field, editing: cellEdit.activeKey === key, busy: cellEdit.busyKey === key, errorMessage: cellEdit.errorOf(key), onStartEdit: () => cellEdit.start(coord), onCancel: () => cellEdit.cancel(coord), onCommit: (value, advance) => cellEdit.commit(coord, value, advance) })) : null }, name));
|
|
289
|
-
}),
|
|
312
|
+
}), hasRowActions ? (_jsx("td", { className: "px-2 py-2 text-right align-middle", children: _jsx(RowActionsMenu, { doc: doc, published: source.publishing?.isPublished({ collection: collectionId, id: doc.id }) ?? false, hasDetailPath: source.detailPath !== undefined, onAction: (action) => onRowAction(action, doc) }) })) : null] }, doc.id))) })] }) }));
|
|
290
313
|
}
|
|
291
314
|
/**
|
|
292
315
|
* The right-edge row `⋮` menu (EC-316): the SAME action vocabulary as the
|
|
@@ -366,6 +389,45 @@ function AssetThumbCell({ assetId, alt }) {
|
|
|
366
389
|
const record = useAssetRecord(assetId);
|
|
367
390
|
return _jsx(AssetThumb, { record: record, alt: alt, className: "size-8 shrink-0" });
|
|
368
391
|
}
|
|
392
|
+
/** A compact absolute date for a dense table cell (EC-445), localized; the full ISO
|
|
393
|
+
* value rides the cell's `title`. Falls back to the raw value when unparseable. */
|
|
394
|
+
function formatListDate(value, locale) {
|
|
395
|
+
const ms = Date.parse(value);
|
|
396
|
+
if (Number.isNaN(ms))
|
|
397
|
+
return value;
|
|
398
|
+
return new Date(ms).toLocaleDateString(locale);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* A reserved pseudo-column body cell (EC-445), dispatched by its `$`-key — folding
|
|
402
|
+
* what used to be the table's hardcoded trailing status/url blocks into the columns
|
|
403
|
+
* model. `$state` keeps the {@link DocStateBadge} (adopting the EC-446 `StatusDot`
|
|
404
|
+
* here is a deliberate separate step — its per-row `tabIndex` would add a tab stop
|
|
405
|
+
* per row); `$url` reuses {@link UrlCell}; the date columns render a compact locale date.
|
|
406
|
+
*/
|
|
407
|
+
function PseudoCell({ name, docId, collectionId, publishing, timestamps, url, locale, }) {
|
|
408
|
+
const ref = { collection: collectionId, id: docId };
|
|
409
|
+
switch (name) {
|
|
410
|
+
case STATE_FIELD:
|
|
411
|
+
// The column only applies where the source publishes (pseudoColumnsForSource),
|
|
412
|
+
// so `publishing` is present here; the dash is a defensive fallback.
|
|
413
|
+
return publishing ? _jsx(DocStateBadge, { published: publishing.isPublished(ref) }) : _jsx(EmDash, {});
|
|
414
|
+
case URL_FIELD:
|
|
415
|
+
return _jsx(UrlCell, { url: url });
|
|
416
|
+
case UPDATED_AT_FIELD:
|
|
417
|
+
case PUBLISHED_AT_FIELD: {
|
|
418
|
+
const value = name === UPDATED_AT_FIELD ? timestamps?.updatedAt(ref) : timestamps?.publishedAt(ref);
|
|
419
|
+
if (!value)
|
|
420
|
+
return _jsx(EmDash, {});
|
|
421
|
+
return (_jsx(Text, { size: "xs", tone: "muted", className: "tabular-nums", title: value, children: formatListDate(value, locale) }));
|
|
422
|
+
}
|
|
423
|
+
default:
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
/** The empty-value dash shared by the derived pseudo-cells (URL / dates). */
|
|
428
|
+
function EmDash() {
|
|
429
|
+
return (_jsx(Text, { size: "xs", tone: "subtle", children: "\u2014" }));
|
|
430
|
+
}
|
|
369
431
|
/**
|
|
370
432
|
* The read-only URL column cell (EC-216): the document's LIVE (published) path,
|
|
371
433
|
* linking to the absolute live URL when a `frontendUrl` is configured. Only
|