Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation fix and additionalTextareaProps prop support #184

Merged
merged 3 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/AutoCompleteTextarea/Textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ class ReactTextareaAutocomplete extends React.Component {
'handleSubmit',
'replaceWord',
'grow',
'additionalTextareaProps',
];

// eslint-disable-next-line
Expand Down Expand Up @@ -774,6 +775,7 @@ class ReactTextareaAutocomplete extends React.Component {
onFocus={this.props.onFocus}
value={value}
style={style}
{...this.props.additionalTextareaProps}
/>
</div>
);
Expand Down
5 changes: 5 additions & 0 deletions src/components/ChatAutoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export class ChatAutoComplete extends PureComponent {
commands: PropTypes.array,
/** Listener for onfocus event on textarea */
onFocus: PropTypes.object,
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
*/
additionalTextareaProps: PropTypes.object,
};

static defaultProps = {
Expand Down Expand Up @@ -175,6 +179,7 @@ export class ChatAutoComplete extends PureComponent {
value={this.props.value}
grow={this.props.grow}
disabled={this.props.disabled}
additionalTextareaProps={this.props.additionalTextareaProps}
/>
);
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import deepequal from 'deep-equal';
import { MessageSimple } from './MessageSimple';
import { Attachment } from './Attachment';
import { MESSAGE_ACTIONS } from '../utils';
import { withTranslationContext } from '../context';

/**
* Message - A high level component which implements all the logic required for a message.
Expand All @@ -13,7 +14,7 @@ import { MESSAGE_ACTIONS } from '../utils';
* @example ./docs/Message.md
* @extends Component
*/
export class Message extends Component {
class Message extends Component {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -499,3 +500,7 @@ export class Message extends Component {
);
}
}

Message = withTranslationContext(Message);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes #181


export { Message };
11 changes: 11 additions & 0 deletions src/components/MessageInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ class MessageInput extends PureComponent {
* Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react/#sendbutton)
* */
SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
* e.g.
* <MessageInput
* additionalTextareaProps={{
* maxLength: 10,
* }}
* />
*/
additionalTextareaProps: PropTypes.object,
};

static defaultProps = {
Expand All @@ -139,6 +149,7 @@ class MessageInput extends PureComponent {
maxRows: 10,
Input: MessageInputLarge,
SendButton,
additionalTextareaProps: {},
};

componentDidMount() {
Expand Down
5 changes: 5 additions & 0 deletions src/components/MessageInputFlat.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class MessageInputFlat extends PureComponent {
* Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react/#sendbutton)
* */
SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
*/
additionalTextareaProps: PropTypes.object,
};

static defaultProps = {
Expand Down Expand Up @@ -175,6 +179,7 @@ class MessageInputFlat extends PureComponent {
grow={this.props.grow}
onFocus={this.props.onFocus}
disabled={this.props.disabled}
additionalTextareaProps={this.props.additionalTextareaProps}
/>

<span
Expand Down
5 changes: 5 additions & 0 deletions src/components/MessageInputLarge.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class MessageInputLarge extends PureComponent {
* Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react/#sendbutton)
* */
SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
*/
additionalTextareaProps: PropTypes.object,
};

renderUploads = () => (
Expand Down Expand Up @@ -203,6 +207,7 @@ class MessageInputLarge extends PureComponent {
onPaste={this.props.onPaste}
grow={this.props.grow}
disabled={this.props.disabled}
additionalTextareaProps={this.props.additionalTextareaProps}
/>

<span
Expand Down
5 changes: 5 additions & 0 deletions src/components/MessageInputSmall.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class MessageInputSmall extends PureComponent {
* Defaults to and accepts same props as: [SendButton](https://getstream.github.io/stream-chat-react/#sendbutton)
* */
SendButton: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
*/
additionalTextareaProps: PropTypes.object,
};

renderUploads = () => (
Expand Down Expand Up @@ -176,6 +180,7 @@ class MessageInputSmall extends PureComponent {
onPaste={this.props.onPaste}
grow={this.props.grow}
disabled={this.props.disabled}
additionalTextareaProps={this.props.additionalTextareaProps}
/>

<span
Expand Down
11 changes: 11 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,16 @@ export interface MessageInputProps {

/** Completely override the submit handler (advanced usage only) */
overrideSubmitHandler?(message: object, channelCid: string): void;
/**
* Any additional attrubutes that you may want to add for underlying HTML textarea element.
* e.g.
* <MessageInput
* additionalTextareaProps={{
* maxLength: 10,
* }}
* />
*/
additionalTextareaProps: object;
}

export type ImageUpload = {
Expand Down Expand Up @@ -655,6 +665,7 @@ export interface ChatAutoCompleteProps {
commands: Client.CommandResponse[];
onFocus?: React.FocusEventHandler;
onPaste?: React.ClipboardEventHandler;
additionalTextareaProps: object;
}

export interface ChatDownProps extends TranslationContextValue {
Expand Down