2019-09-18 10:19:50 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import BaseControl, { ControlProps } from "./BaseControl";
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
import { ControlWrapper, StyledInputGroup } from "./StyledControls";
|
2019-11-05 05:09:50 +00:00
|
|
|
import { InputType } from "zlib";
|
|
|
|
|
import { ControlType } from "../../constants/PropertyControlConstants";
|
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-10-31 05:28:11 +00:00
|
|
|
type={this.isNumberType(this.props.inputType) ? "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-10-31 05:28:11 +00:00
|
|
|
isNumberType(inputType: InputType): boolean {
|
|
|
|
|
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-09-18 10:19:50 +00:00
|
|
|
this.updateProperty(this.props.propertyName, event.target.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-09-19 11:29:24 +00:00
|
|
|
inputType: InputType;
|
|
|
|
|
isDisabled?: boolean;
|
2019-09-18 10:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default InputTextControl;
|