PromucFlow_constructor/app/client/src/widgets/InputWidget.tsx

57 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-09-12 08:11:25 +00:00
import React from "react";
import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget";
2019-09-12 08:11:25 +00:00
import { WidgetType } from "../constants/WidgetConstants";
2019-10-30 10:23:20 +00:00
import InputComponent from "../components/blueprint/InputComponent";
2019-09-12 08:11:25 +00:00
class InputWidget extends BaseWidget<InputWidgetProps, WidgetState> {
2019-09-12 08:11:25 +00:00
getPageView() {
2019-10-30 10:23:20 +00:00
return (
<InputComponent
style={this.getPositionStyle()}
widgetId={this.props.widgetId}
inputType={this.props.inputType}
disabled={this.props.isDisabled}
defaultValue={this.props.defaultText}
maxNum={this.props.maxNum}
minNum={this.props.minNum}
placeholder={this.props.placeholderText}
stepSize={1}
/>
);
2019-09-12 08:11:25 +00:00
}
getWidgetType(): WidgetType {
return "INPUT_WIDGET";
}
}
export type InputType =
| "TEXT"
| "NUMBER"
| "INTEGER"
| "PHONE_NUMBER"
| "EMAIL"
| "PASSWORD"
| "CURRENCY"
| "SEARCH";
2019-09-12 08:11:25 +00:00
export interface InputValidator {
validationRegex: string;
errorMessage: string;
}
export interface InputWidgetProps extends WidgetProps {
2019-09-12 08:11:25 +00:00
inputType: InputType;
defaultText?: string;
2019-10-30 10:23:20 +00:00
isDisabled?: boolean;
placeholderText?: string;
maxChars?: number;
2019-10-30 10:23:20 +00:00
minNum?: number;
maxNum?: number;
2019-09-12 08:11:25 +00:00
label: string;
inputValidators: InputValidator[];
focusIndex?: number;
isAutoFocusEnabled?: boolean;
2019-09-12 08:11:25 +00:00
}
export default InputWidget;