import { HTMLAttributes, ReactElement, ReactNode } from 'react'; export type FormFieldValue = string | number | boolean | null | readonly FormFieldValue[] | { [key: string]: FormFieldValue | undefined; }; type BasicFormField = { kind: 'form'; Input(props: { value: Value; onChange(value: Value): void; autoFocus: boolean; /** * This will be true when validate has returned false and the user has attempted to close the form * or when the form is open and they attempt to save the item */ forceValidation: boolean; }): ReactElement | null; /** * The options are config about the field that are available on the * preview props when rendering the toolbar and preview component */ options: Options; defaultValue: Value; /** * validate will be called in two cases: * - on the client in the editor when a user is changing the value. * Returning `false` will block closing the form * and saving the item. * - on the server when a change is received before allowing it to be saved * if `true` is returned * @param value The value of the form field. You should NOT trust * this value to be of the correct type because it could come from * a potentially malicious client */ validate(value: unknown): boolean; }; export type FormField = BasicFormField | FormFieldWithFile; export type FormFieldWithFile = FormFieldWithFileRequiringContentsForReader | FormFieldWithFileNotRequiringContentsForReader; type FormFieldWithFileRequiringContentsForReader = BasicFormField & { serializeToFile: (BaseSerializeToSingleFile & { reader: { requiresContentInReader: true; parseToReader(data: { content: Uint8Array | undefined; value: unknown; suggestedFilenamePrefix: string | undefined; }): DataInReader; }; }) | (BaseSerializeToFiles & { reader: { requiresContentInReader: true; parseToReader(data: { value: unknown; primary: Uint8Array | undefined; other: { [key: string]: Uint8Array; }; }): DataInReader; }; }); }; type FormFieldWithFileNotRequiringContentsForReader = BasicFormField & { serializeToFile: (BaseSerializeToSingleFile & { reader: { requiresContentInReader: false; parseToReader(data: { value: unknown; suggestedFilenamePrefix: string | undefined; }): DataInReader; }; }) | (BaseSerializeToFiles & { reader: { requiresContentInReader: false; parseToReader(data: { value: unknown; }): DataInReader; }; }); }; type BaseSerializeToSingleFile = { kind: 'asset'; filename(value: unknown, suggestedFilenamePrefix: string | undefined): string | undefined; serialize(value: Value, suggestedFilenamePrefix: string | undefined): { value: unknown; } & ({ content: undefined; } | { content: Uint8Array; filename: string; }); parse(data: { content: Uint8Array | undefined; value: unknown; suggestedFilenamePrefix: string | undefined; }): Value; }; type BaseSerializeToFiles = { kind: 'multi'; primaryExtension: string; files(value: unknown): string[]; serialize(value: Value): Promise<{ value: unknown; primary: Uint8Array | undefined; other: { [key: string]: Uint8Array; }; }>; parse(data: { value: unknown; primary: Uint8Array | undefined; other: { [key: string]: Uint8Array; }; }): Value; }; export type DocumentNode = DocumentElement | DocumentText; export type DocumentElement = { children: DocumentNode[]; [key: string]: unknown; }; export type DocumentText = { text: string; [key: string]: unknown; }; type InlineMarksConfig = 'inherit' | { bold?: 'inherit'; code?: 'inherit'; italic?: 'inherit'; strikethrough?: 'inherit'; underline?: 'inherit'; keyboard?: 'inherit'; subscript?: 'inherit'; superscript?: 'inherit'; }; type BlockFormattingConfig = { alignment?: 'inherit'; blockTypes?: 'inherit'; headingLevels?: 'inherit' | (1 | 2 | 3 | 4 | 5 | 6)[]; inlineMarks?: InlineMarksConfig; listTypes?: 'inherit'; softBreaks?: 'inherit'; }; export type ChildField = { kind: 'child'; options: { kind: 'block'; placeholder: string; formatting?: BlockFormattingConfig; dividers?: 'inherit'; links?: 'inherit'; relationships?: 'inherit'; } | { kind: 'inline'; placeholder: string; formatting?: { inlineMarks?: InlineMarksConfig; softBreaks?: 'inherit'; }; links?: 'inherit'; relationships?: 'inherit'; }; }; export type ArrayField = { kind: 'array'; element: ElementField; label: string; itemLabel?(props: unknown): string; asChildTag?: string; }; export type RelationshipField = { kind: 'relationship'; listKey: string; selection: string | undefined; label: string; many: Many; }; export interface ObjectField = Record> { kind: 'object'; fields: Fields; } export type ConditionalField, ConditionalValues extends { [Key in `${DiscriminantField['defaultValue']}`]: ComponentSchema; }> = { kind: 'conditional'; discriminant: DiscriminantField; values: ConditionalValues; }; type ArrayFieldInComponentSchema = { kind: 'array'; element: ComponentSchema; label: string; itemLabel?(props: unknown): string; asChildTag?: string; }; export type ComponentSchema = ChildField | FormField | ObjectField | ConditionalField, { [key: string]: ComponentSchema; }> | RelationshipField | ArrayFieldInComponentSchema; export declare const fields: { text({ label, defaultValue, validation: { length: { max, min } }, description, multiline, }: { label: string; defaultValue?: string | undefined; description?: string | undefined; validation?: { length?: { min?: number | undefined; max?: number | undefined; } | undefined; } | undefined; multiline?: boolean | undefined; }): BasicFormField; integer({ label, defaultValue, }: { label: string; defaultValue?: number | undefined; }): BasicFormField; url({ label, defaultValue, }: { label: string; defaultValue?: string | undefined; }): BasicFormField; select