aboutsummaryrefslogtreecommitdiffstats
path: root/src/@types/mobx-form.types.ts
blob: 2a984d3a61da92113ce8586cf386f04b60864dfa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { ChangeEventHandler, FocusEventHandler } from 'react';
import { GlobalError } from './ferdium-components.types';

export interface FormFieldOptions {
  value?: string;
  label?: string;
  disabled?: boolean;
}

export interface FormFields {
  fields: {
    [key: string]: Field;
  };
}

export interface Field extends Listeners {
  id?: string;
  type?: string; // todo specifiy probably
  name?: string;
  value?: any;
  label?: string;
  placeholder?: string;
  disabled?: boolean;
  error?: GlobalError | string;
  options?: SelectOptions[];
  default?: string | boolean | number | null;
  validators?: any; // Not sure yet.
}

export interface SelectOptions {
  disabled?: boolean;
  label?: string;
  value?: string;
}

export interface Listeners {
  onChange?: ChangeEventHandler<HTMLInputElement | HTMLSelectElement>;
  onBlur?: FocusEventHandler<HTMLElement>;
  onFocus?: FocusEventHandler<HTMLElement>;
}