2020-04-28 06:52:53 +00:00
|
|
|
import { Component } from "react";
|
|
|
|
|
import { ControlType } from "constants/PropertyControlConstants";
|
|
|
|
|
import { InputType } from "widgets/InputWidget";
|
|
|
|
|
|
|
|
|
|
abstract class BaseControl<P extends ControlProps, S = {}> extends Component<
|
|
|
|
|
P,
|
|
|
|
|
S
|
|
|
|
|
> {
|
|
|
|
|
abstract getControlType(): ControlType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ControlBuilder<T extends ControlProps> {
|
|
|
|
|
buildPropertyControl(controlProps: T): JSX.Element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ControlProps extends ControlData, ControlFunctions {
|
|
|
|
|
key?: string;
|
|
|
|
|
extraData?: ControlData[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ControlData {
|
|
|
|
|
id: string;
|
|
|
|
|
label: string;
|
|
|
|
|
configProperty: string;
|
|
|
|
|
helpText?: string;
|
|
|
|
|
isJSConvertible?: boolean;
|
|
|
|
|
controlType: ControlType;
|
|
|
|
|
propertyValue?: any;
|
|
|
|
|
isValid: boolean;
|
|
|
|
|
validationMessage?: string;
|
2020-08-31 05:15:04 +00:00
|
|
|
validationRegex?: string;
|
2020-04-28 06:52:53 +00:00
|
|
|
dataType?: InputType;
|
|
|
|
|
isRequired?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ControlFunctions {
|
|
|
|
|
onPropertyChange?: (propertyName: string, propertyValue: string) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default BaseControl;
|