From f707d3d524d8d16e2bb780764f029d85fc57ecc0 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 26 Jul 2019 13:22:00 +0300 Subject: prop-types -> jsdoc --- vnext/src/ui/MessageInput.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'vnext/src/ui/MessageInput.js') diff --git a/vnext/src/ui/MessageInput.js b/vnext/src/ui/MessageInput.js index 63c2ee79..bc9ddd54 100644 --- a/vnext/src/ui/MessageInput.js +++ b/vnext/src/ui/MessageInput.js @@ -1,7 +1,4 @@ import React, { useState, useEffect, useRef } from 'react'; -import PropTypes from 'prop-types'; - -import { MessageType } from './Types'; import Icon from './Icon'; import Button from './Button'; @@ -9,7 +6,10 @@ import Button from './Button'; import UploadButton from './UploadButton'; -// StackOverflow-driven development: https://stackoverflow.com/a/10158364/1097384 +/** + * StackOverflow-driven development: https://stackoverflow.com/a/10158364/1097384 + * @param {HTMLTextAreaElement} el + */ function moveCaretToEnd(el) { if (typeof el.selectionStart == 'number') { el.selectionStart = el.selectionEnd = el.value.length; @@ -21,8 +21,25 @@ function moveCaretToEnd(el) { } } +/** + * @typedef {Object} MessageInputProps + * @property {string} text + * @property {import('../api').Message} data + * @property {function} onSend + */ + +/** + * MessageInput + * @param {HTMLTextAreaElement & MessageInputProps} props + */ export default function MessageInput({ text, data, rows, children, onSend }) { + /** + * @type {React.MutableRefObject} + */ let textareaRef = useRef(); + /** + * @type {React.MutableRefObject} + */ let fileinput = useRef(); let updateFocus = () => { @@ -114,11 +131,3 @@ const textInputStyle = { outline: 'none', padding: '4px' }; - -MessageInput.propTypes = { - children: PropTypes.node, - data: MessageType.isRequired, - onSend: PropTypes.func.isRequired, - rows: PropTypes.string, - text: PropTypes.string -}; -- cgit v1.2.3