How to use the emoji-mart.emojiIndex.emojis function in emoji-mart

To help you get started, weโ€™ve selected a few emoji-mart examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / emoji-mart / emoji-mart-tests.tsx View on Github external
const AutoCompleteExample: React.FC = () => {
    const [search, setSearch] = useState('');
    const changed = (e: React.ChangeEvent) => {
        const target = e.target as { value: any };
        setSearch(target.value);
    };

    const match = search.match(/:([a-z_]+)(:)?/);
    let suggestions: ReturnType = [];
    if (match && match[2]) {
        // smiley is closed
        let emoji = emojiIndex.emojis[match[1]];
        const isSingleEmoji = (e: EmojiEntry): e is EmojiData => {
            return 'name' in e;
        };
        const isNativeEmoji = (e: EmojiData): e is BaseEmoji => {
            return 'native' in e;
        };
        if (!isSingleEmoji(emoji)) {
            emoji = emoji[1];
        }
        const native = (isNativeEmoji(emoji) && emoji.native) || '';
        setSearch(search.replace(match[0], native));
    } else if (match && match[1].length > 2) {
        suggestions = emojiIndex.search(match[1]) || [];
    }
    return (
        <div></div>
github keybase / client / shared / chat / conversation / messages / react-button / emoji-picker / data.tsx View on Github external
'Activities',
  'Travel &amp; Places',
  'Objects',
  'Symbols',
  'Flags',
]
const categories: Array&lt;{
  category: string
  emojis: Array
}&gt; = categoryOrder.map(category =&gt; ({
  category,
  emojis: sorted[category],
}))

// Map from EmojiMart's `id` to EmojiDatasource's object
const emojiNameMap = Object.values(emojiIndex.emojis).reduce(
  (res: {[K in string]: EmojiData}, emoji: any) =&gt; {
    const shortName = emoji.id
    const emojiFromEmojiData = emojidata.find(e =&gt; e.short_name === shortName)
    if (emojiFromEmojiData) {
      res[shortName] = emojiFromEmojiData
    }
    return res
  },
  {}
)

export {categories, categoryOrder, emojiIndex, emojiNameMap}