UNPKG

magner

Version:

Universal admin panel magnetic to any backend

23 lines (22 loc) 1.43 kB
import type { GenericComponent } from '../../types/form'; import type { FormLayout, GenericFormLayout } from '../../types/form/layout'; export type SupportedDataTypes = 'string' | 'number' | 'array' | 'object' | 'date' | 'boolean'; export type DataTypeInitials = '' | null | [] | {} | false; /** * If there is a field which operates a data not of a string type, it is recommended to * set the 'dataType' field to help the form working with the data. */ export declare const dataTypeToInitial: (dataType: SupportedDataTypes) => DataTypeInitials; /** Function extracts all fields from the nested layout recursively */ export declare const collectFieldsFromLayout: (layout: GenericFormLayout<any> | GenericFormLayout<any>[]) => GenericComponent<any>[]; export declare const parseUrl: (query: { data?: string; }) => any; /** Extract all generic components (fields) from layout */ export declare const layoutToFields: (layout: FormLayout<any>) => GenericComponent<Record<string, unknown>>[]; /** * Creates an object with initial values for each field of a form. * This object is used when the form triggers the 'submit' event. */ export declare const fieldsToModels: (fields: GenericComponent<Record<string, any>>[], initialData?: Record<string, any>) => Record<string, DataTypeInitials>; export declare const initialDifference: (form: Record<string, any>, initialData: Record<string, any>) => Record<string, DataTypeInitials>;