2022-08-31 02:35:06 -07:00
|
|
|
// import classNames from 'clsx';
|
2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
2021-07-21 04:58:22 -07:00
|
|
|
import { HotKeys } from 'react-hotkeys';
|
2023-01-19 11:23:54 -08:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2020-12-24 16:17:53 -08:00
|
|
|
import { connect } from 'react-redux';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2020-12-24 16:17:53 -08:00
|
|
|
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
2022-03-31 19:17:29 -07:00
|
|
|
import { EmojiSelector as RealEmojiSelector } from 'soapbox/components/ui';
|
2020-05-21 19:14:15 -07:00
|
|
|
|
2022-03-31 17:01:20 -07:00
|
|
|
import type { List as ImmutableList } from 'immutable';
|
|
|
|
import type { RootState } from 'soapbox/store';
|
|
|
|
|
|
|
|
const mapStateToProps = (state: RootState) => ({
|
|
|
|
allowedEmoji: getSoapboxConfig(state).allowedEmoji,
|
2020-12-24 16:17:53 -08:00
|
|
|
});
|
|
|
|
|
2022-03-31 17:01:20 -07:00
|
|
|
interface IEmojiSelector {
|
|
|
|
allowedEmoji: ImmutableList<string>,
|
2022-03-31 18:47:28 -07:00
|
|
|
onReact: (emoji: string) => void,
|
2022-03-31 17:01:20 -07:00
|
|
|
onUnfocus: () => void,
|
|
|
|
visible: boolean,
|
|
|
|
focused?: boolean,
|
|
|
|
}
|
2020-05-21 19:14:15 -07:00
|
|
|
|
2023-01-19 11:23:54 -08:00
|
|
|
class EmojiSelector extends ImmutablePureComponent<IEmojiSelector> {
|
2020-05-21 19:14:15 -07:00
|
|
|
|
2022-03-31 17:01:20 -07:00
|
|
|
static defaultProps: Partial<IEmojiSelector> = {
|
2022-07-22 10:30:16 -07:00
|
|
|
onReact: () => { },
|
|
|
|
onUnfocus: () => { },
|
2020-05-23 15:02:14 -07:00
|
|
|
visible: false,
|
2023-01-05 09:55:08 -08:00
|
|
|
};
|
2020-05-21 22:08:55 -07:00
|
|
|
|
2021-07-21 04:58:22 -07:00
|
|
|
handlers = {
|
2022-07-22 10:30:16 -07:00
|
|
|
open: () => { },
|
2021-07-21 04:58:22 -07:00
|
|
|
};
|
|
|
|
|
2020-05-21 19:14:15 -07:00
|
|
|
render() {
|
2023-02-06 09:18:49 -08:00
|
|
|
const { visible, focused, allowedEmoji, onReact, onUnfocus } = this.props;
|
2020-05-21 19:14:15 -07:00
|
|
|
|
|
|
|
return (
|
2022-03-31 18:32:53 -07:00
|
|
|
<HotKeys handlers={this.handlers}>
|
2022-03-31 19:17:29 -07:00
|
|
|
<RealEmojiSelector
|
|
|
|
emojis={allowedEmoji.toArray()}
|
|
|
|
onReact={onReact}
|
|
|
|
visible={visible}
|
|
|
|
focused={focused}
|
2023-02-06 09:18:49 -08:00
|
|
|
onUnfocus={onUnfocus}
|
2022-03-31 19:17:29 -07:00
|
|
|
/>
|
2021-07-21 04:58:22 -07:00
|
|
|
</HotKeys>
|
2020-05-21 19:14:15 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-03-31 17:01:20 -07:00
|
|
|
|
|
|
|
export default connect(mapStateToProps)(EmojiSelector);
|