ToolJet/frontend/src/Editor/Components/TextArea.jsx
Sherfin Shamsudeen 9a8ca9d754
Feature/refactor widget property resolution (#995)
* Make widget properties available as a prop to component

This commit also make the front-end app resolve widget properties
based on current state and definition, before passing in the final
resolved properties to the component

* Resolve unnecessary console.log and comments

* Provide styles as prop to component

* Give existing values precedence over definition values

* Serve properties and variables as separate props to components

* Remove the usage of separate directory for Box.jsx

* Remove unnecessary lint change

* Introduce fireEvent method to fire events

* Introduce validate function to validate a widgets value

* Rename "variables" to "exposedVariables"

* Add documentation for props and functions being passed to widgets

* Delete "id" from set of exposed variables presented to the widget

* Do not resolve exposed variables before passing to widget
2021-10-20 07:50:45 +05:30

22 lines
700 B
JavaScript

import React, { useEffect } from 'react';
export const TextArea = function TextArea({ width, height, properties, exposedVariables, styles, setExposedVariable }) {
useEffect(() => {
setExposedVariable('value', properties.value);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [properties.value]);
return (
<textarea
disabled={styles.disabledState}
onChange={(e) => {
setExposedVariable('value', e.target.value);
}}
type="text"
className="form-control"
placeholder={properties.placeholder}
style={{ width, height, display: styles.visibility ? '' : 'none' }}
value={exposedVariables.value}
></textarea>
);
};