/
types.ts
87 lines (73 loc) · 1.86 KB
/
types.ts
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { ArgType } from '../blocks';
/* eslint-disable @typescript-eslint/no-empty-interface */
export interface ControlProps<T> {
name: string;
value?: T;
defaultValue?: T;
argType?: ArgType;
onChange: (value: T) => T | void;
onFocus?: (evt: any) => void;
onBlur?: (evt: any) => void;
}
export type BooleanValue = boolean;
export interface BooleanConfig {}
export type ColorValue = string;
export type PresetColor = ColorValue | { color: ColorValue; title?: string };
export interface ColorConfig {
presetColors?: PresetColor[];
startOpen?: boolean;
}
export type DateValue = Date | number;
export interface DateConfig {}
export type NumberValue = number;
export interface NumberConfig {
min?: number;
max?: number;
step?: number;
}
export type RangeConfig = NumberConfig;
export type ObjectValue = any;
export interface ObjectConfig {}
export type OptionsSingleSelection = any;
export type OptionsMultiSelection = any[];
export type OptionsSelection = OptionsSingleSelection | OptionsMultiSelection;
export type OptionsArray = any[];
export type OptionsObject = Record<string, any>;
export type Options = OptionsArray | OptionsObject;
export type OptionsControlType =
| 'radio'
| 'inline-radio'
| 'check'
| 'inline-check'
| 'select'
| 'multi-select';
export interface OptionsConfig {
labels: Record<any, string>;
options: Options;
type: OptionsControlType;
}
export interface NormalizedOptionsConfig {
options: OptionsObject;
}
export type TextValue = string;
export interface TextConfig {}
export type ControlType =
| 'array'
| 'boolean'
| 'color'
| 'date'
| 'number'
| 'range'
| 'object'
| OptionsControlType
| 'text';
export type Control =
| BooleanConfig
| ColorConfig
| DateConfig
| NumberConfig
| ObjectConfig
| OptionsConfig
| RangeConfig
| TextConfig;
export type Controls = Record<string, Control>;