/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ import { type ReactNode } from 'react'; import type { AdminResourceConfig, Field, WorkflowStatus } from '@byline/core'; import { type ScheduledPublicationInfo, type SchedulePublicationInput } from './scheduled-publication-control.js'; import { type SystemFieldsSubmitPayload } from './use-form-submission.js'; import type { DocumentActionsLocaleOption } from './document-actions.js'; import type { UseNavigationGuard } from './navigation-guard.js'; export type { SystemFieldsSubmitPayload } from './use-form-submission.js'; /** Metadata about a previously published version that is still live. */ export interface PublishedVersionInfo { id: string; versionId: string; status: string; createdAt: string | Date; updatedAt: string | Date; } /** Props shared by both the public FormRenderer and its internal FormContent component. */ export interface FormRendererProps { mutationIssue?: 'stale' | 'reload' | 'lock' | 'unavailable' | 'committed' | null; mutationsBlocked?: boolean; observedRevision?: number; onMutationError?: (error: unknown) => 'blocked' | 'committed' | null | void; onTreeMutationCommitted?: (receipt: import('@byline/core').StructuralMutationReceipt) => void; scheduledPublicationsNeedReconfirmation?: boolean; scheduledPublicationsHref?: string; /** Explicit discard action; defaults to a complete server reload. */ onReloadDocument?: () => void | Promise; mode: 'create' | 'edit'; fields: Field[]; onSubmit: (data: SystemFieldsSubmitPayload) => void | Promise; onCancel: () => void; onStatusChange?: (nextStatus: string) => Promise; onUnpublish?: () => Promise; scheduledPublication?: ScheduledPublicationInfo | null; onSchedulePublication?: (input: SchedulePublicationInput) => Promise; onConfirmScheduledPublication?: () => Promise; onCancelScheduledPublication?: () => Promise; onDelete?: () => Promise; /** * Called when the editor confirms the duplicate modal in * `DocumentActions`. Edit views provide a handler that invokes the * `duplicateCollectionDocument` server fn and navigates to the new doc. * When omitted, the Duplicate menu item is hidden. */ onDuplicate?: () => Promise; /** * Called when the editor confirms the Copy-to-Locale modal in * `DocumentActions`. Edit views provide a handler that invokes the * `copyDocumentToLocale` server fn and navigates to the target-locale * view. When omitted (or when fewer than two `contentLocales` are * configured), the Copy-to-Locale menu item is hidden. */ onCopyToLocale?: (args: { targetLocale: string; overwrite: boolean; }) => Promise; /** * Called when the editor confirms the Delete-Locale modal in * `DocumentActions`. Edit views provide a handler that invokes the * `deleteDocumentLocale` server fn and navigates to a surviving locale. * When omitted (or when the document has no non-default locale with * content), the Delete-Locale menu item is hidden. */ onDeleteLocale?: (args: { targetLocale: string; }) => Promise; /** * All configured content locales (code + display label) — required for * the Copy-to-Locale modal's target Select. Threaded as an opaque list * through to `DocumentActions`. */ contentLocales?: ReadonlyArray; nextStatus?: WorkflowStatus; workflowStatuses?: WorkflowStatus[]; publishedVersion?: PublishedVersionInfo | null; initialData?: Record; /** * Presentation configuration for the resource being edited — a collection * or a singleton. Typed as the union rather than the shared * `FormAdminConfig` base so the renderer can read collection-only members * such as `lockPath`. */ adminConfig?: AdminResourceConfig; /** * Name of the schema field to render as the live form heading. * Sourced from `CollectionDefinition.useAsTitle` by the caller. */ useAsTitle?: string; /** * Name of the schema field that initialises the system path. * Sourced from `CollectionDefinition.useAsPath` by the caller. When * present the path widget renders in the sidebar. */ useAsPath?: string; /** * Whether the system path widget may render in the sidebar. Defaults to * `true`, which preserves the historical behaviour of showing the widget * whenever `useAsPath` is declared or the document envelope carries a * `path`. Set `false` for a resource whose path is internal metadata and * must never be presented or edited. */ showPath?: boolean; /** * Explicit form heading, used verbatim. Overrides both `useAsTitle`'s live * value and the create/edit wording derived from `mode` — for a resource * whose identity does not change when it is first materialised. */ heading?: string; /** * Opts the available-locales widget into the sidebar (below the path * widget). Sourced from `CollectionDefinition.advertiseLocales` by the * caller. When true, one checkbox per content locale renders, reconciled * against the document's `_availableVersionLocales` ledger fact. */ advertiseLocales?: boolean; /** * Opts the document-tree placement widget into the sidebar (above the * available-locales widget). Sourced from `CollectionDefinition.tree` by the * caller. Renders only in edit mode (placement needs a persisted document) * and only when the host wires the tree services. See docs/04-collections/04-document-trees.md. */ tree?: boolean; headingLabel?: string; headerSlot?: ReactNode; /** Collection path forwarded to upload-capable fields (e.g. `'media'`). */ collectionPath?: string; /** The active content locale — initialised from the route query string. */ initialLocale?: string; /** Called when the user picks a different content locale. */ onLocaleChange?: (locale: string) => void; /** * Schema-mismatch warnings produced by a "best-effort" reconstruction * of the document (`findById({ lenient: true })`). When present, the * form renders an inline Alert telling the editor that fields from a * previous schema have been dropped — saving the form will overwrite * them with the new shape. */ restoreWarnings?: string[]; /** * Default content locale used when no `initialLocale` is supplied and as the * fallback inside `PathWidget`. Hosts typically pass their app-wide * `i18n.content.defaultLocale`. Defaults to `'en'`. */ defaultLocale?: string; /** * Framework-specific navigation guard hook. * When provided, this overrides the adapter from `NavigationGuardProvider` context. * If neither is set, a no-op `beforeunload`-only guard is used. */ useNavigationGuard?: UseNavigationGuard; } export declare const FormRenderer: (props: FormRendererProps) => import("react").JSX.Element;