aboutsummaryrefslogtreecommitdiffstats
path: root/src/@types/mobx-form.types.ts
blob: 7caddc9e48d646c86dd2182c3b2627c08742b33f (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]: {
      label?: string;
      placeholder?: string;
      options?: FormFieldOptions[];
      value?: string | boolean | number | null;
      default?: string | boolean | number | null;
      type?: string; // todo specifiy probably
      disabled?: boolean;
      validators?: any; // Not sure yet.
    };
  };
}

export interface Field extends Partial<Listeners> {
  id?: string;
  type?: string;
  name?: string;
  value: string;
  label?: string;
  placeholder?: string;
  disabled?: boolean;
  error?: GlobalError | string;
}

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