2019-09-18 10:19:50 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import BaseControl, { ControlProps } from "./BaseControl";
|
2019-11-19 12:44:58 +00:00
|
|
|
import { ControlWrapper, StyledInputGroup } from "./StyledControls";
|
2019-11-25 05:07:27 +00:00
|
|
|
import { InputType } from "widgets/InputWidget";
|
|
|
|
|
import { ControlType } from "constants/PropertyControlConstants";
|
2019-11-19 12:44:58 +00:00
|
|
|
import { Intent } from "@blueprintjs/core";
|
2019-09-18 10:19:50 +00:00
|
|
|
|
|
|
|
|
class InputTextControl extends BaseControl<InputControlProps> {
|
|
|
|
|
render() {
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
return (
|
|
|
|
|
<ControlWrapper>
|
|
|
|
|
<label>{this.props.label}</label>
|
|
|
|
|
<StyledInputGroup
|
2019-11-19 12:44:58 +00:00
|
|
|
intent={this.props.isValid ? Intent.NONE : Intent.DANGER}
|
|
|
|
|
type={this.isNumberType() ? "number" : "text"}
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
onChange={this.onTextChange}
|
2019-10-31 05:28:11 +00:00
|
|
|
placeholder={this.props.placeholderText}
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
defaultValue={this.props.propertyValue}
|
|
|
|
|
/>
|
|
|
|
|
</ControlWrapper>
|
|
|
|
|
);
|
2019-09-18 10:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-19 12:44:58 +00:00
|
|
|
isNumberType(): boolean {
|
|
|
|
|
const { inputType } = this.props;
|
2019-10-31 05:28:11 +00:00
|
|
|
switch (inputType) {
|
|
|
|
|
case "CURRENCY":
|
|
|
|
|
case "INTEGER":
|
|
|
|
|
case "NUMBER":
|
|
|
|
|
case "PHONE_NUMBER":
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
onTextChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
2019-11-22 13:12:39 +00:00
|
|
|
const value: string = event.target.value;
|
2019-11-14 14:26:23 +00:00
|
|
|
this.updateProperty(this.props.propertyName, value);
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
};
|
2019-09-18 10:19:50 +00:00
|
|
|
|
|
|
|
|
getControlType(): ControlType {
|
|
|
|
|
return "INPUT_TEXT";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface InputControlProps extends ControlProps {
|
|
|
|
|
placeholderText: string;
|
2019-11-19 12:44:58 +00:00
|
|
|
inputType: InputType;
|
2019-09-19 11:29:24 +00:00
|
|
|
isDisabled?: boolean;
|
2019-09-18 10:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default InputTextControl;
|