import { GraphQLError } from 'graphql'; import type { ReactElement } from 'react'; import { GqlNames, JSONValue } from './utils'; export declare type NavigationProps = { authenticatedItem: AuthenticatedItem; lists: ListMeta[]; }; export declare type AuthenticatedItem = { state: 'unauthenticated'; } | { state: 'authenticated'; label: string; id: string; listKey: string; } | { state: 'loading'; } | { state: 'error'; error: Error | readonly [GraphQLError, ...GraphQLError[]]; }; export declare type VisibleLists = { state: 'loaded'; lists: ReadonlySet; } | { state: 'loading'; } | { state: 'error'; error: Error | readonly [GraphQLError, ...GraphQLError[]]; }; export declare type CreateViewFieldModes = { state: 'loaded'; lists: Record>; } | { state: 'loading'; } | { state: 'error'; error: Error | readonly [GraphQLError, ...GraphQLError[]]; }; export declare type AdminConfig = { components?: { Logo?: (props: {}) => ReactElement; Navigation?: (props: NavigationProps) => ReactElement; }; }; export declare type FieldControllerConfig = { listKey: string; path: string; label: string; customViews: Record; fieldMeta: FieldMeta; }; declare type FilterTypeDeclaration = { readonly label: string; readonly initialValue: Value; }; export declare type FilterTypeToFormat = { readonly type: string; readonly label: string; readonly value: Value; }; export declare type FieldController = { path: string; label: string; graphqlSelection: string; defaultValue: FormState; deserialize: (item: any) => FormState; serialize: (formState: FormState) => any; validate?: (formState: FormState) => boolean; filter?: { types: Record>; graphql(type: { type: string; value: FilterValue; }): Record; Label(type: FilterTypeToFormat): string | ReactElement | null; Filter(props: { type: string; value: FilterValue; onChange(value: FilterValue): void; autoFocus?: boolean; }): ReactElement | null; }; }; export declare type FieldMeta = { path: string; label: string; fieldMeta: JSONValue; viewsIndex: number; customViewsIndex: number | null; views: FieldViews[number]; controller: FieldController; search: 'default' | 'insensitive' | null; itemView: { /** * `null` indicates that the value is dynamic and must be fetched for any given item */ fieldMode: 'edit' | 'read' | 'hidden' | null; }; }; export declare type ListMeta = { key: string; path: string; label: string; singular: string; plural: string; description: string | null; gqlNames: GqlNames; initialColumns: string[]; pageSize: number; labelField: string; initialSort: null | { direction: 'ASC' | 'DESC'; field: string; }; fields: { [path: string]: FieldMeta; }; }; export declare type AdminMeta = { enableSignout: boolean; enableSessionItem: boolean; lists: { [list: string]: ListMeta; }; }; export declare type FieldProps FieldController> = { field: ReturnType; value: ReturnType['deserialize']>; onChange?(value: ReturnType['deserialize']>): void; autoFocus?: boolean; /** * Will be true when the user has clicked submit and * the validate function on the field controller has returned false */ forceValidation?: boolean; }; export declare type FieldViews = Record) => ReactElement | null; Cell: CellComponent; CardValue: CardValueComponent; controller: (args: FieldControllerConfig) => FieldController; allowedExportsOnCustomViews?: string[]; }>; export declare type CellComponent FieldController = () => FieldController> = { (props: { item: Record; linkTo: { href: string; as: string; } | undefined; field: ReturnType; }): ReactElement | null; supportsLinkTo?: boolean; }; export declare type CardValueComponent FieldController = () => FieldController> = (props: { item: Record; field: ReturnType; }) => ReactElement; export declare type FieldMetaRootVal = { path: string; label: string; fieldMeta: JSONValue | null; viewsIndex: number; customViewsIndex: number | null; listKey: string; search: 'default' | 'insensitive' | null; }; export declare type ListMetaRootVal = { key: string; path: string; label: string; singular: string; plural: string; initialColumns: string[]; pageSize: number; labelField: string; initialSort: { field: string; direction: 'ASC' | 'DESC'; } | null; fields: Array; itemQueryName: string; listQueryName: string; description: string | null; }; export declare type AdminMetaRootVal = { enableSignout: boolean; enableSessionItem: boolean; lists: Array; listsByKey: Record; views: string[]; }; export {};