Skip to content

Interface

Форми - https://apidocs.softpro.ua/fastify-table/templates/forms.html

ts
export interface IErrors {
  [key: string]: string | boolean;
}

export interface IForm {
  value: Record<string, any>;
  errors: IErrors;
    
  reset: () => void;
  validate: () => void;
  submit: () => void;
  disable: () => void;
  enable: () => void;

  on(event: 'change', listener: () => void): void;
  on(event: 'submit', listener: () => void): void;
}

export interface IOption {
  id: number | string;
  text: string;
  color?: string;
  icon?: string;
}

export interface ISchemaItem {
  name: string;
  default?: any;
  value?: any;
  schema?: ISchemaItem[];
  type: string; 
  
  // options 
  options?: IOption[];
  api?: string;
  dataKey: string;

  // text 
  label?: string;
  placeholder?: string;
  description?: string;
  info?: string;
  
  // style  
  col?: number; // 6 -> { container: 6, ... }
  columns?: object; // { container: 12, label: 4, wrapper: 12 } 
  attrs: object; 
  slots?: object;
  size?: 'small' | 'large';  // sm, md, lg
  inline: boolean;

  // features 
  conditions?: object[];
  rules?: (string | object)[];
  messages?: string | object;  
  disabled?: boolean;
  hidden?: boolean;  
}