2022-11-27 18:02:32 +00:00
|
|
|
import { Component, linkEvent } from "inferno";
|
2023-06-22 00:54:35 +00:00
|
|
|
import { I18NextService } from "../../services";
|
2022-11-27 18:02:32 +00:00
|
|
|
import { EmojiMart } from "./emoji-mart";
|
|
|
|
import { Icon } from "./icon";
|
|
|
|
|
|
|
|
interface EmojiPickerProps {
|
2023-03-27 16:49:46 +00:00
|
|
|
onEmojiClick?(val: any): any;
|
2023-04-04 12:40:00 +00:00
|
|
|
disabled?: boolean;
|
2022-11-27 18:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface EmojiPickerState {
|
2023-03-27 16:49:46 +00:00
|
|
|
showPicker: boolean;
|
2022-11-27 18:02:32 +00:00
|
|
|
}
|
|
|
|
|
2023-03-27 16:49:46 +00:00
|
|
|
export class EmojiPicker extends Component<EmojiPickerProps, EmojiPickerState> {
|
|
|
|
private emptyState: EmojiPickerState = {
|
|
|
|
showPicker: false,
|
|
|
|
};
|
2023-04-04 12:40:00 +00:00
|
|
|
|
2023-03-27 16:49:46 +00:00
|
|
|
state: EmojiPickerState;
|
2023-04-04 12:40:00 +00:00
|
|
|
constructor(props: EmojiPickerProps, context: any) {
|
2023-03-27 16:49:46 +00:00
|
|
|
super(props, context);
|
|
|
|
this.state = this.emptyState;
|
|
|
|
this.handleEmojiClick = this.handleEmojiClick.bind(this);
|
|
|
|
}
|
|
|
|
render() {
|
|
|
|
return (
|
2023-06-20 18:46:16 +00:00
|
|
|
<span className="emoji-picker">
|
2023-03-27 16:49:46 +00:00
|
|
|
<button
|
|
|
|
className="btn btn-sm text-muted"
|
2023-06-22 00:54:35 +00:00
|
|
|
data-tippy-content={I18NextService.i18n.t("emoji")}
|
|
|
|
aria-label={I18NextService.i18n.t("emoji")}
|
2023-04-04 12:40:00 +00:00
|
|
|
disabled={this.props.disabled}
|
2023-03-27 16:49:46 +00:00
|
|
|
onClick={linkEvent(this, this.togglePicker)}
|
|
|
|
>
|
|
|
|
<Icon icon="smile" classes="icon-inline" />
|
|
|
|
</button>
|
2022-11-27 18:02:32 +00:00
|
|
|
|
2023-03-27 16:49:46 +00:00
|
|
|
{this.state.showPicker && (
|
|
|
|
<>
|
2023-06-21 18:44:37 +00:00
|
|
|
<div className="position-relative">
|
|
|
|
<div className="emoji-picker-container position-absolute w-100">
|
|
|
|
<EmojiMart
|
|
|
|
onEmojiClick={this.handleEmojiClick}
|
|
|
|
pickerOptions={{}}
|
|
|
|
></EmojiMart>
|
|
|
|
</div>
|
2023-06-24 23:24:09 +00:00
|
|
|
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}
|
2023-06-21 18:44:37 +00:00
|
|
|
<div
|
|
|
|
onClick={linkEvent(this, this.togglePicker)}
|
|
|
|
className="click-away-container"
|
|
|
|
/>
|
2023-03-27 16:49:46 +00:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
2022-11-27 18:02:32 +00:00
|
|
|
|
2023-03-27 16:49:46 +00:00
|
|
|
togglePicker(i: EmojiPicker, e: any) {
|
|
|
|
e.preventDefault();
|
|
|
|
i.setState({ showPicker: !i.state.showPicker });
|
|
|
|
}
|
2022-11-27 18:02:32 +00:00
|
|
|
|
2023-03-27 16:49:46 +00:00
|
|
|
handleEmojiClick(e: any) {
|
|
|
|
this.props.onEmojiClick?.(e);
|
|
|
|
}
|
|
|
|
}
|