-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Input.ts
34 lines (28 loc) · 1.08 KB
/
Input.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
import { FieldSchema, ValueSchema } from '@ephox/boulder';
import { Option, Result } from '@ephox/katamari';
import { FormComponentWithLabelApi, FormComponentWithLabel, formComponentWithLabelFields } from './FormComponent';
export interface InputApi extends FormComponentWithLabelApi {
type: 'input';
inputMode?: string;
placeholder?: string;
maximized?: boolean;
disabled?: boolean;
}
export interface Input extends FormComponentWithLabel {
type: 'input';
inputMode: Option<string>;
placeholder: Option<string>;
maximized: boolean;
disabled: boolean;
}
const inputFields = formComponentWithLabelFields.concat([
FieldSchema.optionString('inputMode'),
FieldSchema.optionString('placeholder'),
FieldSchema.defaultedBoolean('maximized', false),
FieldSchema.defaultedBoolean('disabled', false)
]);
export const inputSchema = ValueSchema.objOf(inputFields);
export const inputDataProcessor = ValueSchema.string;
export const createInput = (spec: InputApi): Result<Input, ValueSchema.SchemaError<any>> => {
return ValueSchema.asRaw<Input>('input', inputSchema, spec);
};