2021-02-11 12:54:00 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import BaseControl, { ControlProps } from "./BaseControl";
|
|
|
|
|
import { ControlType } from "constants/PropertyControlConstants";
|
|
|
|
|
import NumberField from "components/editorComponents/form/fields/NumberField";
|
|
|
|
|
import Text, { TextType } from "components/ads/Text";
|
|
|
|
|
import { Classes } from "components/ads/common";
|
|
|
|
|
import styled from "styled-components";
|
|
|
|
|
|
|
|
|
|
const FormGroup = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
.${Classes.TEXT} {
|
|
|
|
|
color: ${(props) => props.theme.colors.apiPane.settings.textColor};
|
|
|
|
|
margin-right: ${(props) => props.theme.spaces[12]}px;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
export function InputText(props: {
|
|
|
|
|
label: string;
|
|
|
|
|
value: string;
|
|
|
|
|
placeholder?: string;
|
|
|
|
|
dataType?: string;
|
|
|
|
|
name: string;
|
|
|
|
|
}) {
|
|
|
|
|
const { name, placeholder, dataType, label } = props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<FormGroup data-cy={name}>
|
|
|
|
|
<Text type={TextType.P1}>{label}</Text>
|
2021-04-28 10:28:39 +00:00
|
|
|
<NumberField dataType={dataType} name={name} placeholder={placeholder} />
|
2021-02-11 12:54:00 +00:00
|
|
|
</FormGroup>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class InputNumberControl extends BaseControl<InputControlProps> {
|
|
|
|
|
render() {
|
|
|
|
|
const {
|
|
|
|
|
propertyValue,
|
|
|
|
|
label,
|
|
|
|
|
placeholderText,
|
|
|
|
|
configProperty,
|
|
|
|
|
dataType,
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<InputText
|
2021-04-28 10:28:39 +00:00
|
|
|
dataType={dataType}
|
2021-02-11 12:54:00 +00:00
|
|
|
label={label}
|
2021-04-28 10:28:39 +00:00
|
|
|
name={configProperty}
|
2021-02-11 12:54:00 +00:00
|
|
|
placeholder={placeholderText}
|
2021-04-28 10:28:39 +00:00
|
|
|
value={propertyValue}
|
2021-02-11 12:54:00 +00:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getControlType(): ControlType {
|
|
|
|
|
return "NUMBER_INPUT";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface InputControlProps extends ControlProps {
|
|
|
|
|
placeholderText: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default InputNumberControl;
|