2019-09-12 08:11:25 +00:00
|
|
|
import React from "react";
|
2019-09-13 10:45:49 +00:00
|
|
|
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
|
|
|
|
2019-09-13 10:45:49 +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";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-13 10:45:49 +00:00
|
|
|
export type InputType =
|
|
|
|
|
| "TEXT"
|
|
|
|
|
| "NUMBER"
|
|
|
|
|
| "INTEGER"
|
|
|
|
|
| "PHONE_NUMBER"
|
|
|
|
|
| "EMAIL"
|
|
|
|
|
| "PASSWORD"
|
|
|
|
|
| "CURRENCY"
|
|
|
|
|
| "SEARCH";
|
2019-09-12 08:11:25 +00:00
|
|
|
|
2019-09-19 11:29:24 +00:00
|
|
|
export interface InputValidator {
|
|
|
|
|
validationRegex: string;
|
|
|
|
|
errorMessage: string;
|
|
|
|
|
}
|
2019-09-13 10:45:49 +00:00
|
|
|
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;
|
2019-09-19 11:29:24 +00:00
|
|
|
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;
|
2019-09-19 11:29:24 +00:00
|
|
|
inputValidators: InputValidator[];
|
2019-09-13 10:45:49 +00:00
|
|
|
focusIndex?: number;
|
2019-09-19 11:29:24 +00:00
|
|
|
isAutoFocusEnabled?: boolean;
|
2019-09-12 08:11:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default InputWidget;
|