1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | export interface BaseField<TType extends string, TValue> {
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 | name: string;
|
14 |
|
15 | |
16 |
|
17 |
|
18 |
|
19 |
|
20 | type: TType,
|
21 |
|
22 | |
23 |
|
24 |
|
25 | value?: TValue;
|
26 |
|
27 | |
28 |
|
29 |
|
30 | placeholder?: TValue;
|
31 |
|
32 | |
33 |
|
34 |
|
35 | required: boolean;
|
36 |
|
37 | |
38 |
|
39 |
|
40 | readOnly: boolean;
|
41 |
|
42 | |
43 |
|
44 |
|
45 | label?: string;
|
46 | }
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | export type Checkbox = BaseField<'checkbox', boolean>
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | export type Color = BaseField<'color', string>
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | export type Date = BaseField<'date', string>
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | export type DateTime = BaseField<'datetime', Date>
|
68 |
|
69 | export type DateTimeLocal = BaseField<'datetime-local', Date>
|
70 |
|
71 | export type Email = BaseField<'email', string>
|
72 |
|
73 | export type File = BaseField<'file', never>
|
74 |
|
75 | export type Hidden = BaseField<'hidden', string>
|
76 |
|
77 | export interface Number extends BaseField<'number', number> {
|
78 | max?: number;
|
79 | min?: number;
|
80 | step?: number;
|
81 | }
|
82 |
|
83 | export type Month = BaseField<'month', string>
|
84 |
|
85 | export type Password = BaseField<'password', string>
|
86 |
|
87 | export interface Radio extends BaseField<'radio', string> {
|
88 | options?: Map<string, string>;
|
89 | }
|
90 |
|
91 | export interface Range extends BaseField<'range', number> {
|
92 | max?: number;
|
93 | min?: number;
|
94 | step?: number;
|
95 | }
|
96 |
|
97 | export type Search = BaseField<'search', string>
|
98 |
|
99 | export type Tel = BaseField<'tel', string>
|
100 |
|
101 | export interface Text extends BaseField<'text', string> {
|
102 | minLength?: number;
|
103 | maxLength?: number;
|
104 | pattern?: RegExp,
|
105 | options?: Map<string, string>;
|
106 | }
|
107 |
|
108 | export type Time = BaseField<'time', string>
|
109 |
|
110 | export type Url = BaseField<'url', string>
|
111 |
|
112 | export type Week = BaseField<'week', string>
|
113 |
|
114 |
|
115 | export type Field = Checkbox | Color | Date | DateTime | DateTimeLocal | Email
|
116 |
|
117 | | File | Hidden | Number | Month | Password | Radio | Range | Search | Tel
|
118 | | Text | Time | Url | Week;
|