刘光辉
13 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
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
export type ControlType = 'text' | 'dropdown' | 'checkbox' | 'date' | 'multiline';
 
export type FieldMode = 'single' | 'repeat';
 
export interface DropdownOption {
  display: string;
  value: string;
}
 
export interface RawTypeConfig {
  controlType: string;
  placeholder?: string;
  defaultValue?: string;
  defaultChecked?: boolean;
  options?: DropdownOption[];
  defaultOptionValue?: string;
}
 
export type TypeConfigValidationField = 'control-type' | 'text-default' | 'dropdown-options' | 'dropdown-default' | 'date-default';
 
export type ValidationResult<T, F extends string = string> = { ok: true; value: T } | { field: F; message: string; ok: false };
 
export interface ValidatedDropdownConfig {
  controlType: 'dropdown';
  options: DropdownOption[];
  placeholder: string;
  selectedIndex: number;
}
 
export interface ValidatedStandardConfig {
  controlType: Exclude<ControlType, 'dropdown'>;
  defaultChecked: boolean;
  defaultValue: string;
  placeholder: string;
}
 
export type ValidatedTypeConfig = ValidatedDropdownConfig | ValidatedStandardConfig;
 
export interface FieldDefinitionInput {
  alias: string;
  fieldCode: string;
  groupCode: string;
  mode: FieldMode;
  rowId: string;
  typeConfig: RawTypeConfig | null | undefined;
}
 
export type FieldDefinitionValidationField = 'field-code' | 'field-alias' | 'group-code' | 'row-id' | TypeConfigValidationField;
 
export interface FieldColor {
  B: number;
  G: number;
  R: number;
}
 
interface FieldDefinitionBase {
  alias: string;
  color: FieldColor;
  fieldCode: string;
  groupCode: string;
  mode: FieldMode;
  rowId: string;
  tag: string;
}
 
export type FieldDefinition = FieldDefinitionBase & (ValidatedDropdownConfig | ValidatedStandardConfig);