Skip to content

Commit

Permalink
feat(CODE): ADDON-57044 Added new support for Textarea field (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbalar-splunk committed Dec 1, 2022
1 parent 79a7952 commit 69a62b5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
42 changes: 42 additions & 0 deletions ui/src/main/webapp/components/TextAreaComponent.jsx
@@ -0,0 +1,42 @@
import React from 'react';
import PropTypes from 'prop-types';
import TextArea from '@splunk/react-ui/TextArea';
import styled from 'styled-components';

const TextWrapper = styled(TextArea)`
width: 320px !important;
`;

function TextAreaComponent(props) {

const handleChange = (e, { value }) => {
props.handleChange(props.field, value);
};

return (
<TextWrapper
inline
canClear
error={props.error}
placeholder={props?.controlOptions?.placeholder}
className={props.field}
disabled={props.disabled}
value={props.value?.toString() || ''}
onChange={handleChange}
rowsMax={props?.controlOptions?.rowsMax ? props?.controlOptions?.rowsMax : 12}
rowsMin={props?.controlOptions?.rowsMin ? props?.controlOptions?.rowsMin : 8}
/>
);

}

TextAreaComponent.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
handleChange: PropTypes.func.isRequired,
field: PropTypes.string,
error: PropTypes.bool,
controlOptions: PropTypes.object,
disabled: PropTypes.bool,
};

export default TextAreaComponent;
2 changes: 2 additions & 0 deletions ui/src/main/webapp/constants/ControlTypeMap.js
@@ -1,5 +1,6 @@
import HelpLinkComponent from '../components/HelpLinkComponent';
import TextComponent from '../components/TextComponent';
import TextAreaComponent from '../components/TextAreaComponent';
import SingleInputComponent from '../components/SingleInputComponent';
import MultiInputComponent from '../components/MultiInputComponent';
import CheckBoxComponent from '../components/CheckBoxComponent';
Expand All @@ -9,6 +10,7 @@ import CustomControl from '../components/CustomControl';

export default {
text: TextComponent,
textarea: TextAreaComponent,
singleSelect: SingleInputComponent,
helpLink: HelpLinkComponent,
multipleSelect: MultiInputComponent,
Expand Down
14 changes: 14 additions & 0 deletions ui/src/main/webapp/schema/schema.json
Expand Up @@ -170,6 +170,7 @@
"enum": [
"custom",
"text",
"textarea",
"singleSelect",
"checkbox",
"multipleSelect",
Expand Down Expand Up @@ -339,6 +340,12 @@
},
"link": {
"type": "string"
},
"rowsMin": {
"type": "number"
},
"rowsMax": {
"type": "number"
}
}
},
Expand Down Expand Up @@ -546,6 +553,7 @@
"enum": [
"custom",
"text",
"textarea",
"singleSelect",
"checkbox",
"multipleSelect",
Expand Down Expand Up @@ -712,6 +720,12 @@
},
"link": {
"type": "string"
},
"rowsMin": {
"type": "number"
},
"rowsMax": {
"type": "number"
}
}
},
Expand Down

0 comments on commit 69a62b5

Please sign in to comment.