2020-04-28 06:52:53 +00:00
|
|
|
import { Component } from "react";
|
|
|
|
|
import { ControlType } from "constants/PropertyControlConstants";
|
|
|
|
|
import { InputType } from "widgets/InputWidget";
|
2020-11-03 13:05:40 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
2020-04-28 06:52:53 +00:00
|
|
|
abstract class BaseControl<P extends ControlProps, S = {}> extends Component<
|
|
|
|
|
P,
|
|
|
|
|
S
|
|
|
|
|
> {
|
|
|
|
|
abstract getControlType(): ControlType;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-19 03:32:58 +00:00
|
|
|
export type ComparisonOperations =
|
|
|
|
|
| "EQUALS"
|
|
|
|
|
| "NOT_EQUALS"
|
|
|
|
|
| "LESSER"
|
2021-02-10 05:57:21 +00:00
|
|
|
| "GREATER"
|
|
|
|
|
| "IN"
|
|
|
|
|
| "NOT_IN";
|
2020-11-19 03:32:58 +00:00
|
|
|
|
|
|
|
|
export type HiddenType =
|
|
|
|
|
| boolean
|
|
|
|
|
| { path: string; comparison: ComparisonOperations; value: any };
|
|
|
|
|
|
2020-04-28 06:52:53 +00:00
|
|
|
export interface ControlBuilder<T extends ControlProps> {
|
|
|
|
|
buildPropertyControl(controlProps: T): JSX.Element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ControlProps extends ControlData, ControlFunctions {
|
|
|
|
|
key?: string;
|
|
|
|
|
extraData?: ControlData[];
|
2020-11-19 03:32:58 +00:00
|
|
|
formName: string;
|
2020-04-28 06:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ControlData {
|
|
|
|
|
id: string;
|
|
|
|
|
label: string;
|
|
|
|
|
configProperty: string;
|
|
|
|
|
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;
|
2020-11-19 03:32:58 +00:00
|
|
|
hidden?: HiddenType;
|
2021-03-09 12:05:29 +00:00
|
|
|
placeholderText?: string;
|
2020-04-28 06:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ControlFunctions {
|
|
|
|
|
onPropertyChange?: (propertyName: string, propertyValue: string) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default BaseControl;
|