ToolJet/frontend/src/Editor/Components/TextArea.jsx

41 lines
1,007 B
React
Raw Normal View History

import React, { useEffect } from 'react';
export const TextArea = function TextArea({
height,
properties,
exposedVariables,
styles,
setExposedVariable,
registerAction,
}) {
2021-04-30 06:31:32 +00:00
useEffect(() => {
setExposedVariable('value', properties.value);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [properties.value]);
2021-04-14 11:32:03 +00:00
registerAction('setText', async function (text) {
setExposedVariable('value', text);
});
registerAction('clear', async function () {
setExposedVariable('value', '');
});
2021-04-30 06:31:32 +00:00
return (
<textarea
disabled={styles.disabledState}
2021-04-30 06:31:32 +00:00
onChange={(e) => {
setExposedVariable('value', e.target.value);
2021-04-30 06:31:32 +00:00
}}
type="text"
className="form-control textarea"
placeholder={properties.placeholder}
style={{
height,
resize: 'none',
display: styles.visibility ? '' : 'none',
borderRadius: `${styles.borderRadius}px`,
}}
value={exposedVariables.value}
2021-04-30 06:31:32 +00:00
></textarea>
);
2021-04-10 04:51:19 +00:00
};