import { IFieldConfig, TCondition, TFieldRef } from "./common-interface"; import { TFormType, TSectionLayout, TValue } from "./types"; export interface IParamType { type?: string; ref?: string; section?: string; } export declare type TParamType = IParamType | TValue; export declare type TParam = [string, TParamType]; /** * Display/layout properties of the field */ export interface IDisplayProps { /** For large devices */ lg?: number; /** For medium devices */ md?: number; /** For small devices */ sm?: number; /** For very small devices */ xs?: number; /** Offset distance from row start */ offset?: string; /** Wheter to start field from a new row position */ rs?: boolean; isStandalone?: boolean; /** Field alignment */ align?: string; /** Layout inside field */ fieldLayout?: string; /** Layout for dropdown options */ optionsLayout?: string; } export interface IMultitextInput { chars: string; width: string; isReadonly?: boolean; required?: boolean; placeholder?: string; value?: string; } /** * Represents a dropdown option */ export interface IOption { value: TValue; label: string; ref?: TFieldRef; } export interface IValidationDetail { errorMsg?: string; } export interface IInfoDetail { infoMsg?: string; infoMsgFn?: string; } export interface IPatternValidationDetail extends IValidationDetail { allowValidOnly?: boolean; } export interface IFieldValidation { value: T; errorMsg: string; } export interface IPatternFieldValidation extends IFieldValidation { allowValidOnly?: boolean; } /** * Validation properties for field */ export interface IValidation { /** Marks the field as mandatory before form submission */ required?: boolean | IFieldValidation; /** @deprecated Validation details specific to required property */ requiredDetail?: IValidationDetail; /** Pattern to be used by the field -- valid for field of type text */ pattern?: string | IPatternFieldValidation; /** @deprecated Pattern details specific to pattern property */ patternDetail?: IPatternValidationDetail; /** Minimum value acceptable by the field */ min?: number | string | IFieldValidation; /** @deprecated Details related to min. property */ minDetail?: IValidationDetail; /** Maximum value acceptable by the field */ max?: number | string | IFieldValidation; /** @deprecated Details related to max. property */ maxDetail?: IValidationDetail; info?: string | IFieldValidation; /** @deprecated Generic info related to the field */ infoDetail?: IInfoDetail; } export interface IConfigParam { key: string; value: string; } export interface IConfig { type?: string; apihost?: string; basepath?: string; protocol?: string; headers?: Array; } /** * Rest configuration to be used in schema definition */ export interface IRest { config: IConfig; } export interface IFormConfigExtended { variant?: string; size?: string; tabs?: { variant?: string; disabled?: Array; }; gapX?: number; gapY?: number; loader?: { color?: string; enabled?: boolean; }; headers?: Record; } export interface IFormConfig { type?: TFormType; sectionLayout?: TSectionLayout; fieldLayout?: string; config?: IFormConfigExtended; } export interface ITemplateConfig { params: Record; } export interface IURLLoaderConfig { type: string; url: string; urlType?: string; queryParams?: Array; pathParams?: Array; responseKey?: string; valueKey?: string; labelKey?: string; loadOn?: Array; openTo?: string; inputFormat?: string; views?: string; inputs?: Array; separator?: string; accept?: string; toolbarVersion?: number; } /** * Configuration info of icon */ export interface IIconConfig { [key: string]: { type: string; position?: string; }; } export interface IconConfig { name: string; position: string; } export interface IBaseDependency { section?: string; ref: string; value?: TValue; } export declare type IExistsDependency = IBaseDependency; export declare type IEnabledDependency = IBaseDependency; export interface ILoadDependency extends IBaseDependency { url: string; } export interface IEqualsDependency extends IBaseDependency { currentValue: TValue; resetValue?: TValue; } export declare type IDisplayTypeDependency = IBaseDependency; export interface IDependency { exists?: IExistsDependency; enabled?: IEnabledDependency; load?: ILoadDependency; equals?: IEqualsDependency; displayType?: IDisplayTypeDependency; } export interface IClickEvent { type: string; value?: string; } export interface IInputEvent { type: string; url: string; params: Array; labelKey?: string; valueKey?: string; responseKey?: string; response?: string; value?: string; } export interface IChangeEvent { type: string; name?: string; ref?: string; valueKey?: string; value?: TValue; valueFn?: string; valueMap?: Record; section?: string; condition?: TCondition[]; eventType?: string; payload?: any; } export interface IEvent { click?: IClickEvent; input?: IInputEvent; change?: IChangeEvent | Array; open?: IFieldConfig; } export interface IFormatterType { [key: string]: (arg: TValue) => string; } export interface IThemeFieldConfig { [key: string]: string; } export interface IMeta { /** * values - hidden (whether field is to be hidden) * value - section (whether field is a section) */ type?: string; /** Is field to be displayed * @internal */ display?: boolean; /** For future usage */ isArray?: boolean; /** Display name of the field */ displayName?: string; /** Display type of the field. */ displayType?: string; /** Placeholder to be used in the field */ placeholder?: string; /** Value of the field */ value?: string | number | boolean; /** Layout properties of the field */ displayProps?: IDisplayProps; /** Native html properties of the field */ htmlProps?: Record; /** List of options available for the field (e.g-> dropdown, select etc) */ options?: Array; /** Marks a field as `disabled` */ isDisabled?: boolean; /** Marks as field as `readonly` */ isReadonly?: boolean; /** Validation details for the field */ validation?: IValidation; /** Field relationships/dependencies with other fields */ dependencies?: IDependency; url?: string; /** Custom classname to be used for the field */ className?: string; /** Events supported by the field */ events?: IEvent; labelPlacement?: string; /** Validation errors with the field */ error?: { hasError: boolean; errorMsg: string; }; /** Configuration information of the field */ config?: IFieldConfig; /** Theme configuration information for the field */ themeConfig?: IThemeFieldConfig; /** Init config for the field */ /** @deprecated */ init?: IFieldConfig; /** @deprecated Icons used by the field */ icons?: IIconConfig; /** For icon name */ iconName?: string; /** For configurable icon */ icon?: IconConfig; } /** * This represents each form field in the metaform schema */ export interface IField { /** * The name of the field */ name: string; /** * This property is used for grouping the field while submitting the form. * Use `null` if field has no parent key while submitting the form */ prop?: string | null; /** * This property contains meta information (field details ) about the field */ meta: IMeta; /** * A list of children fields */ fields?: Array; } /** * The schema definition used in metaforms */ export interface ISchema { /** * Rest configuration */ rest?: IRest; /** * List of form fields */ fields: Array; /** * Button definitions in the form */ buttons?: Array; } /** * The root of json schema * @category Main schema definition */ export interface IUISchema { schema: ISchema; } /** * Represents a field error type */ export interface IFieldError { field: string; hasError: boolean; errorMsg: string; }