1 import { Component, linkEvent } from "inferno";
2 import { I18NextService } from "../../services";
3 import { EmojiMart } from "./emoji-mart";
4 import { Icon } from "./icon";
6 interface EmojiPickerProps {
7 onEmojiClick?(val: any): any;
11 interface EmojiPickerState {
15 export class EmojiPicker extends Component<EmojiPickerProps, EmojiPickerState> {
16 private emptyState: EmojiPickerState = {
20 state: EmojiPickerState;
21 constructor(props: EmojiPickerProps, context: any) {
22 super(props, context);
23 this.state = this.emptyState;
24 this.handleEmojiClick = this.handleEmojiClick.bind(this);
27 closeEmojiMartOnEsc(i, event) {
28 event.key === "Escape" && i.setState({ showPicker: false });
33 <span className="emoji-picker">
35 className="btn btn-sm text-muted"
36 data-tippy-content={I18NextService.i18n.t("emoji")}
37 aria-label={I18NextService.i18n.t("emoji")}
38 disabled={this.props.disabled}
39 onClick={linkEvent(this, this.togglePicker)}
41 <Icon icon="smile" classes="icon-inline" />
44 {this.state.showPicker && (
46 <div className="position-relative" role="dialog">
47 <div className="emoji-picker-container z-3">
49 onEmojiClick={this.handleEmojiClick}
54 onClick={linkEvent(this, this.togglePicker)}
55 className="click-away-container"
64 togglePicker(i: EmojiPicker, e: any) {
66 i.setState({ showPicker: !i.state.showPicker });
69 ? document.addEventListener("keyup", e => i.closeEmojiMartOnEsc(i, e))
70 : document.removeEventListener("keyup", e => i.closeEmojiMartOnEsc(i, e));
73 handleEmojiClick(e: any) {
74 this.props.onEmojiClick?.(e);