2017-05-03 09:04:16 +09:00
|
|
|
import React from 'react';
|
2017-04-22 03:05:35 +09:00
|
|
|
import PropTypes from 'prop-types';
|
2021-06-01 21:35:49 +09:00
|
|
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
2017-10-02 14:22:24 +09:00
|
|
|
import { EmojiPicker as EmojiPickerAsync } from '../../ui/util/async-components';
|
2023-01-12 05:58:46 +09:00
|
|
|
import Overlay from 'react-overlays/Overlay';
|
2017-09-23 08:41:00 +09:00
|
|
|
import classNames from 'classnames';
|
2017-09-23 12:40:28 +09:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2020-11-05 02:21:05 +09:00
|
|
|
import { supportsPassiveEvents } from 'detect-passive-events';
|
2019-06-28 22:54:10 +09:00
|
|
|
import { buildCustomEmojis, categoriesFromEmojis } from '../../emoji/emoji';
|
2020-10-13 08:19:35 +09:00
|
|
|
import { assetHost } from 'mastodon/utils/config';
|
2017-03-02 08:57:55 +09:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
2017-04-22 10:36:33 +09:00
|
|
|
emoji: { id: 'emoji_button.label', defaultMessage: 'Insert emoji' },
|
2017-04-23 00:28:36 +09:00
|
|
|
emoji_search: { id: 'emoji_button.search', defaultMessage: 'Search...' },
|
2017-09-23 08:41:00 +09:00
|
|
|
custom: { id: 'emoji_button.custom', defaultMessage: 'Custom' },
|
|
|
|
recent: { id: 'emoji_button.recent', defaultMessage: 'Frequently used' },
|
|
|
|
search_results: { id: 'emoji_button.search_results', defaultMessage: 'Search results' },
|
2017-04-23 00:28:36 +09:00
|
|
|
people: { id: 'emoji_button.people', defaultMessage: 'People' },
|
|
|
|
nature: { id: 'emoji_button.nature', defaultMessage: 'Nature' },
|
|
|
|
food: { id: 'emoji_button.food', defaultMessage: 'Food & Drink' },
|
|
|
|
activity: { id: 'emoji_button.activity', defaultMessage: 'Activity' },
|
|
|
|
travel: { id: 'emoji_button.travel', defaultMessage: 'Travel & Places' },
|
|
|
|
objects: { id: 'emoji_button.objects', defaultMessage: 'Objects' },
|
|
|
|
symbols: { id: 'emoji_button.symbols', defaultMessage: 'Symbols' },
|
2017-05-21 00:31:47 +09:00
|
|
|
flags: { id: 'emoji_button.flags', defaultMessage: 'Flags' },
|
2017-03-02 08:57:55 +09:00
|
|
|
});
|
|
|
|
|
2017-10-02 14:22:24 +09:00
|
|
|
let EmojiPicker, Emoji; // load asynchronously
|
|
|
|
|
2023-05-22 22:48:01 +09:00
|
|
|
const listenerOptions = supportsPassiveEvents ? { passive: true, capture: true } : true;
|
2017-09-23 08:41:00 +09:00
|
|
|
|
2021-06-01 21:35:49 +09:00
|
|
|
const backgroundImageFn = () => `${assetHost}/emoji/sheet_13.png`;
|
|
|
|
|
|
|
|
const notFoundFn = () => (
|
|
|
|
<div className='emoji-mart-no-results'>
|
|
|
|
<Emoji
|
|
|
|
emoji='sleuth_or_spy'
|
|
|
|
set='twitter'
|
|
|
|
size={32}
|
|
|
|
sheetSize={32}
|
|
|
|
backgroundImageFn={backgroundImageFn}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div className='emoji-mart-no-results-label'>
|
|
|
|
<FormattedMessage id='emoji_button.not_found' defaultMessage='No matching emojis found' />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2017-09-23 08:41:00 +09:00
|
|
|
class ModifierPickerMenu extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
active: PropTypes.bool,
|
|
|
|
onSelect: PropTypes.func.isRequired,
|
|
|
|
onClose: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
2017-10-03 08:56:50 +09:00
|
|
|
handleClick = e => {
|
|
|
|
this.props.onSelect(e.currentTarget.getAttribute('data-index') * 1);
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
2023-05-10 16:05:32 +09:00
|
|
|
UNSAFE_componentWillReceiveProps (nextProps) {
|
2017-09-23 08:41:00 +09:00
|
|
|
if (nextProps.active) {
|
|
|
|
this.attachListeners();
|
|
|
|
} else {
|
|
|
|
this.removeListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount () {
|
|
|
|
this.removeListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
handleDocumentClick = e => {
|
|
|
|
if (this.node && !this.node.contains(e.target)) {
|
|
|
|
this.props.onClose();
|
|
|
|
}
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
attachListeners () {
|
2023-05-22 22:48:01 +09:00
|
|
|
document.addEventListener('click', this.handleDocumentClick, { capture: true });
|
2017-09-24 07:40:10 +09:00
|
|
|
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
|
2017-09-23 08:41:00 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
removeListeners () {
|
2023-05-22 22:48:01 +09:00
|
|
|
document.removeEventListener('click', this.handleDocumentClick, { capture: true });
|
2017-09-24 07:40:10 +09:00
|
|
|
document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
|
2017-09-23 08:41:00 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
setRef = c => {
|
|
|
|
this.node = c;
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
render () {
|
2019-03-30 09:41:35 +09:00
|
|
|
const { active } = this.props;
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
return (
|
2019-03-30 09:41:35 +09:00
|
|
|
<div className='emoji-picker-dropdown__modifiers__menu' style={{ display: active ? 'block' : 'none' }} ref={this.setRef}>
|
2022-11-05 21:43:37 +09:00
|
|
|
<button type='button' onClick={this.handleClick} data-index={1}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={1} backgroundImageFn={backgroundImageFn} /></button>
|
|
|
|
<button type='button' onClick={this.handleClick} data-index={2}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={2} backgroundImageFn={backgroundImageFn} /></button>
|
|
|
|
<button type='button' onClick={this.handleClick} data-index={3}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={3} backgroundImageFn={backgroundImageFn} /></button>
|
|
|
|
<button type='button' onClick={this.handleClick} data-index={4}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={4} backgroundImageFn={backgroundImageFn} /></button>
|
|
|
|
<button type='button' onClick={this.handleClick} data-index={5}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={5} backgroundImageFn={backgroundImageFn} /></button>
|
|
|
|
<button type='button' onClick={this.handleClick} data-index={6}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={6} backgroundImageFn={backgroundImageFn} /></button>
|
2019-03-30 09:41:35 +09:00
|
|
|
</div>
|
2017-09-23 08:41:00 +09:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class ModifierPicker extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
active: PropTypes.bool,
|
|
|
|
modifier: PropTypes.number,
|
|
|
|
onChange: PropTypes.func,
|
|
|
|
onClose: PropTypes.func,
|
|
|
|
onOpen: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = () => {
|
|
|
|
if (this.props.active) {
|
|
|
|
this.props.onClose();
|
|
|
|
} else {
|
|
|
|
this.props.onOpen();
|
|
|
|
}
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
handleSelect = modifier => {
|
|
|
|
this.props.onChange(modifier);
|
|
|
|
this.props.onClose();
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
render () {
|
|
|
|
const { active, modifier } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='emoji-picker-dropdown__modifiers'>
|
2019-03-30 09:41:35 +09:00
|
|
|
<Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={modifier} onClick={this.handleClick} backgroundImageFn={backgroundImageFn} />
|
|
|
|
<ModifierPickerMenu active={active} onSelect={this.handleSelect} onClose={this.props.onClose} />
|
2017-09-23 08:41:00 +09:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-03-24 11:17:53 +09:00
|
|
|
class EmojiPickerMenuImpl extends React.PureComponent {
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
static propTypes = {
|
2017-09-23 12:40:28 +09:00
|
|
|
custom_emojis: ImmutablePropTypes.list,
|
2017-10-09 04:47:15 +09:00
|
|
|
frequentlyUsedEmojis: PropTypes.arrayOf(PropTypes.string),
|
2017-10-02 14:22:24 +09:00
|
|
|
loading: PropTypes.bool,
|
2017-09-23 08:41:00 +09:00
|
|
|
onClose: PropTypes.func.isRequired,
|
|
|
|
onPick: PropTypes.func.isRequired,
|
|
|
|
style: PropTypes.object,
|
|
|
|
intl: PropTypes.object.isRequired,
|
2017-10-08 02:02:30 +09:00
|
|
|
skinTone: PropTypes.number.isRequired,
|
|
|
|
onSkinTone: PropTypes.func.isRequired,
|
2017-09-23 08:41:00 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
style: {},
|
2017-10-02 14:22:24 +09:00
|
|
|
loading: true,
|
2017-10-09 04:47:15 +09:00
|
|
|
frequentlyUsedEmojis: [],
|
2017-09-23 08:41:00 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
state = {
|
|
|
|
modifierOpen: false,
|
2022-02-17 05:44:47 +09:00
|
|
|
readyToFocus: false,
|
2017-09-23 08:41:00 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
handleDocumentClick = e => {
|
|
|
|
if (this.node && !this.node.contains(e.target)) {
|
|
|
|
this.props.onClose();
|
|
|
|
}
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
componentDidMount () {
|
2023-05-22 22:48:01 +09:00
|
|
|
document.addEventListener('click', this.handleDocumentClick, { capture: true });
|
2017-09-24 07:40:10 +09:00
|
|
|
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
|
2022-02-17 05:44:47 +09:00
|
|
|
|
|
|
|
// Because of https://github.com/react-bootstrap/react-bootstrap/issues/2614 we need
|
|
|
|
// to wait for a frame before focusing
|
|
|
|
requestAnimationFrame(() => {
|
|
|
|
this.setState({ readyToFocus: true });
|
|
|
|
if (this.node) {
|
|
|
|
const element = this.node.querySelector('input[type="search"]');
|
|
|
|
if (element) element.focus();
|
|
|
|
}
|
|
|
|
});
|
2017-09-23 08:41:00 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount () {
|
2023-05-22 22:48:01 +09:00
|
|
|
document.removeEventListener('click', this.handleDocumentClick, { capture: true });
|
2017-09-24 07:40:10 +09:00
|
|
|
document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
|
2017-09-23 08:41:00 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
setRef = c => {
|
|
|
|
this.node = c;
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
getI18n = () => {
|
|
|
|
const { intl } = this.props;
|
|
|
|
|
|
|
|
return {
|
|
|
|
search: intl.formatMessage(messages.emoji_search),
|
|
|
|
categories: {
|
|
|
|
search: intl.formatMessage(messages.search_results),
|
|
|
|
recent: intl.formatMessage(messages.recent),
|
|
|
|
people: intl.formatMessage(messages.people),
|
|
|
|
nature: intl.formatMessage(messages.nature),
|
|
|
|
foods: intl.formatMessage(messages.food),
|
|
|
|
activity: intl.formatMessage(messages.activity),
|
|
|
|
places: intl.formatMessage(messages.travel),
|
|
|
|
objects: intl.formatMessage(messages.objects),
|
|
|
|
symbols: intl.formatMessage(messages.symbols),
|
|
|
|
flags: intl.formatMessage(messages.flags),
|
|
|
|
custom: intl.formatMessage(messages.custom),
|
|
|
|
},
|
|
|
|
};
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
2020-06-01 03:34:34 +09:00
|
|
|
handleClick = (emoji, event) => {
|
2017-09-23 12:40:28 +09:00
|
|
|
if (!emoji.native) {
|
|
|
|
emoji.native = emoji.colons;
|
|
|
|
}
|
2020-06-20 20:30:40 +09:00
|
|
|
if (!(event.ctrlKey || event.metaKey)) {
|
2020-06-01 03:34:34 +09:00
|
|
|
this.props.onClose();
|
|
|
|
}
|
2017-09-23 08:41:00 +09:00
|
|
|
this.props.onPick(emoji);
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
handleModifierOpen = () => {
|
|
|
|
this.setState({ modifierOpen: true });
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
handleModifierClose = () => {
|
|
|
|
this.setState({ modifierOpen: false });
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
handleModifierChange = modifier => {
|
2017-10-08 02:02:30 +09:00
|
|
|
this.props.onSkinTone(modifier);
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-09-23 08:41:00 +09:00
|
|
|
|
|
|
|
render () {
|
2017-11-01 06:58:07 +09:00
|
|
|
const { loading, style, intl, custom_emojis, skinTone, frequentlyUsedEmojis } = this.props;
|
2017-10-02 14:22:24 +09:00
|
|
|
|
|
|
|
if (loading) {
|
|
|
|
return <div style={{ width: 299 }} />;
|
|
|
|
}
|
|
|
|
|
2017-09-23 08:41:00 +09:00
|
|
|
const title = intl.formatMessage(messages.emoji);
|
2019-06-28 22:54:10 +09:00
|
|
|
|
2017-10-08 02:02:30 +09:00
|
|
|
const { modifierOpen } = this.state;
|
2017-09-23 08:41:00 +09:00
|
|
|
|
2019-06-28 22:54:10 +09:00
|
|
|
const categoriesSort = [
|
|
|
|
'recent',
|
|
|
|
'people',
|
|
|
|
'nature',
|
|
|
|
'foods',
|
|
|
|
'activity',
|
|
|
|
'places',
|
|
|
|
'objects',
|
|
|
|
'symbols',
|
|
|
|
'flags',
|
|
|
|
];
|
|
|
|
|
|
|
|
categoriesSort.splice(1, 0, ...Array.from(categoriesFromEmojis(custom_emojis)).sort());
|
|
|
|
|
2017-09-23 08:41:00 +09:00
|
|
|
return (
|
|
|
|
<div className={classNames('emoji-picker-dropdown__menu', { selecting: modifierOpen })} style={style} ref={this.setRef}>
|
2017-10-02 14:22:24 +09:00
|
|
|
<EmojiPicker
|
2017-09-23 08:41:00 +09:00
|
|
|
perLine={8}
|
|
|
|
emojiSize={22}
|
|
|
|
sheetSize={32}
|
2017-11-01 06:58:07 +09:00
|
|
|
custom={buildCustomEmojis(custom_emojis)}
|
2017-09-23 08:41:00 +09:00
|
|
|
color=''
|
|
|
|
emoji=''
|
|
|
|
set='twitter'
|
|
|
|
title={title}
|
|
|
|
i18n={this.getI18n()}
|
|
|
|
onClick={this.handleClick}
|
2017-10-08 02:02:30 +09:00
|
|
|
include={categoriesSort}
|
2017-10-09 04:47:15 +09:00
|
|
|
recent={frequentlyUsedEmojis}
|
2017-10-08 02:02:30 +09:00
|
|
|
skin={skinTone}
|
2017-10-03 08:56:50 +09:00
|
|
|
showPreview={false}
|
2021-06-01 21:35:49 +09:00
|
|
|
showSkinTones={false}
|
2017-09-23 08:41:00 +09:00
|
|
|
backgroundImageFn={backgroundImageFn}
|
2021-06-01 21:35:49 +09:00
|
|
|
notFound={notFoundFn}
|
2022-02-17 05:44:47 +09:00
|
|
|
autoFocus={this.state.readyToFocus}
|
2017-10-09 04:47:15 +09:00
|
|
|
emojiTooltip
|
2017-09-23 08:41:00 +09:00
|
|
|
/>
|
|
|
|
|
|
|
|
<ModifierPicker
|
|
|
|
active={modifierOpen}
|
2017-10-08 02:02:30 +09:00
|
|
|
modifier={skinTone}
|
2017-09-23 08:41:00 +09:00
|
|
|
onOpen={this.handleModifierOpen}
|
|
|
|
onClose={this.handleModifierClose}
|
|
|
|
onChange={this.handleModifierChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2017-05-07 09:42:38 +09:00
|
|
|
|
2023-03-24 11:17:53 +09:00
|
|
|
const EmojiPickerMenu = injectIntl(EmojiPickerMenuImpl);
|
|
|
|
|
2018-09-15 00:59:48 +09:00
|
|
|
class EmojiPickerDropdown extends React.PureComponent {
|
2017-03-02 08:57:55 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
static propTypes = {
|
2017-09-23 12:40:28 +09:00
|
|
|
custom_emojis: ImmutablePropTypes.list,
|
2017-10-09 04:47:15 +09:00
|
|
|
frequentlyUsedEmojis: PropTypes.arrayOf(PropTypes.string),
|
2017-05-12 21:44:10 +09:00
|
|
|
intl: PropTypes.object.isRequired,
|
2017-05-21 00:31:47 +09:00
|
|
|
onPickEmoji: PropTypes.func.isRequired,
|
2017-10-08 02:02:30 +09:00
|
|
|
onSkinTone: PropTypes.func.isRequired,
|
|
|
|
skinTone: PropTypes.number.isRequired,
|
2020-01-24 06:00:13 +09:00
|
|
|
button: PropTypes.node,
|
2022-12-01 01:25:36 +09:00
|
|
|
disabled: PropTypes.bool,
|
2017-05-12 21:44:10 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
state = {
|
|
|
|
active: false,
|
2017-10-02 14:22:24 +09:00
|
|
|
loading: false,
|
2017-05-12 21:44:10 +09:00
|
|
|
};
|
2017-03-02 08:57:55 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
setRef = (c) => {
|
2017-03-02 08:57:55 +09:00
|
|
|
this.dropdown = c;
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-03-02 08:57:55 +09:00
|
|
|
|
2023-01-12 05:58:46 +09:00
|
|
|
onShowDropdown = () => {
|
2017-06-02 00:25:10 +09:00
|
|
|
this.setState({ active: true });
|
2017-10-02 14:22:24 +09:00
|
|
|
|
|
|
|
if (!EmojiPicker) {
|
|
|
|
this.setState({ loading: true });
|
|
|
|
|
|
|
|
EmojiPickerAsync().then(EmojiMart => {
|
|
|
|
EmojiPicker = EmojiMart.Picker;
|
2017-10-08 02:02:30 +09:00
|
|
|
Emoji = EmojiMart.Emoji;
|
|
|
|
|
2017-10-02 14:22:24 +09:00
|
|
|
this.setState({ loading: false });
|
|
|
|
}).catch(() => {
|
2020-08-09 00:57:56 +09:00
|
|
|
this.setState({ loading: false, active: false });
|
2017-10-02 14:22:24 +09:00
|
|
|
});
|
|
|
|
}
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-05-07 09:42:38 +09:00
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
onHideDropdown = () => {
|
2017-06-02 00:25:10 +09:00
|
|
|
this.setState({ active: false });
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-05-07 09:42:38 +09:00
|
|
|
|
2017-07-28 11:37:30 +09:00
|
|
|
onToggle = (e) => {
|
2022-12-01 01:25:36 +09:00
|
|
|
if (!this.state.disabled && !this.state.loading && (!e.key || e.key === 'Enter')) {
|
2017-07-28 11:37:30 +09:00
|
|
|
if (this.state.active) {
|
|
|
|
this.onHideDropdown();
|
|
|
|
} else {
|
2018-05-03 17:42:18 +09:00
|
|
|
this.onShowDropdown(e);
|
2017-07-28 11:37:30 +09:00
|
|
|
}
|
|
|
|
}
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-07-28 11:37:30 +09:00
|
|
|
|
2017-09-23 08:41:00 +09:00
|
|
|
handleKeyDown = e => {
|
2017-07-28 11:37:30 +09:00
|
|
|
if (e.key === 'Escape') {
|
|
|
|
this.onHideDropdown();
|
|
|
|
}
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-07-28 11:37:30 +09:00
|
|
|
|
2017-09-23 08:41:00 +09:00
|
|
|
setTargetRef = c => {
|
|
|
|
this.target = c;
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-03-02 08:57:55 +09:00
|
|
|
|
2017-09-23 08:41:00 +09:00
|
|
|
findTarget = () => {
|
|
|
|
return this.target;
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-04-23 00:28:36 +09:00
|
|
|
|
2017-09-23 08:41:00 +09:00
|
|
|
render () {
|
2020-01-24 06:00:13 +09:00
|
|
|
const { intl, onPickEmoji, onSkinTone, skinTone, frequentlyUsedEmojis, button } = this.props;
|
2017-07-28 11:37:30 +09:00
|
|
|
const title = intl.formatMessage(messages.emoji);
|
2023-01-12 05:58:46 +09:00
|
|
|
const { active, loading } = this.state;
|
2017-05-07 09:42:38 +09:00
|
|
|
|
2017-03-02 08:57:55 +09:00
|
|
|
return (
|
2017-09-23 08:41:00 +09:00
|
|
|
<div className='emoji-picker-dropdown' onKeyDown={this.handleKeyDown}>
|
|
|
|
<div ref={this.setTargetRef} className='emoji-button' title={title} aria-label={title} aria-expanded={active} role='button' onClick={this.onToggle} onKeyDown={this.onToggle} tabIndex={0}>
|
2020-01-24 06:00:13 +09:00
|
|
|
{button || <img
|
2017-10-02 14:22:24 +09:00
|
|
|
className={classNames('emojione', { 'pulse-loading': active && loading })}
|
2017-07-15 02:47:53 +09:00
|
|
|
alt='🙂'
|
2017-09-23 08:41:00 +09:00
|
|
|
src={`${assetHost}/emoji/1f602.svg`}
|
2020-01-24 06:00:13 +09:00
|
|
|
/>}
|
2017-09-23 08:41:00 +09:00
|
|
|
</div>
|
|
|
|
|
2023-01-12 05:58:46 +09:00
|
|
|
<Overlay show={active} placement={'bottom'} target={this.findTarget} popperConfig={{ strategy: 'fixed' }}>
|
|
|
|
{({ props, placement })=> (
|
|
|
|
<div {...props} style={{ ...props.style, width: 299 }}>
|
|
|
|
<div className={`dropdown-animation ${placement}`}>
|
|
|
|
<EmojiPickerMenu
|
|
|
|
custom_emojis={this.props.custom_emojis}
|
|
|
|
loading={loading}
|
|
|
|
onClose={this.onHideDropdown}
|
|
|
|
onPick={onPickEmoji}
|
|
|
|
onSkinTone={onSkinTone}
|
|
|
|
skinTone={skinTone}
|
|
|
|
frequentlyUsedEmojis={frequentlyUsedEmojis}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
2017-09-23 08:41:00 +09:00
|
|
|
</Overlay>
|
|
|
|
</div>
|
2017-03-02 08:57:55 +09:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|
2023-03-24 11:17:53 +09:00
|
|
|
|
|
|
|
export default injectIntl(EmojiPickerDropdown);
|