UNPKG

@udecode/plate-emoji

Version:

Emoji plugin for Plate

180 lines (167 loc) 7.76 kB
import * as _udecode_plate_combobox from '@udecode/plate-combobox'; import * as _udecode_slate from '@udecode/slate'; import * as _emoji_mart_data from '@emoji-mart/data'; import { Emoji } from '@emoji-mart/data'; import * as _udecode_plate_core_react from '@udecode/plate-core/react'; import * as _udecode_plate_core from '@udecode/plate-core'; import React from 'react'; import { k as IGrid, E as EmojiCategoryList, G as Grid, n as AGridSection, I as IEmojiLibrary, F as FrequentEmojis, g as GridElements, a as EmojiSettingsType, d as EmojiInlineLibrary, e as EmojiLibrary, A as AIndexSearch, i as i18nProps, c as EmojiIconList } from '../IndexSearch-CHpcU-x-.js'; declare const EmojiInputPlugin: _udecode_plate_core_react.PlatePlugin<_udecode_plate_core.PluginConfig<"emoji_input", {}, {}, {}, {}>>; declare const EmojiPlugin: _udecode_plate_core_react.PlatePlugin<_udecode_plate_core.PluginConfig<"emoji", { data?: _emoji_mart_data.EmojiMartData; createEmojiNode?: (emoji: _emoji_mart_data.Emoji) => _udecode_slate.Descendant; } & _udecode_plate_combobox.TriggerComboboxPluginOptions, {}, {}, {}>>; type EmojiFloatingGridType = IGrid<React.RefObject<HTMLDivElement | null>, EmojiCategoryList>; declare class EmojiFloatingGrid extends Grid<React.RefObject<HTMLDivElement | null>, EmojiCategoryList> { createRootRef(): React.RefObject<HTMLDivElement | null>; } declare class EmojiGridSectionWithRoot extends AGridSection<React.RefObject<HTMLDivElement | null>, EmojiCategoryList> { protected createRootRef(): void; } type FrequentEmojiStorageProps = { key?: string; limit?: number; prefix?: string; }; interface IEmojiFloatingLibrary extends IEmojiLibrary { getGrid: () => EmojiFloatingGridType; indexOf: (focusedCategory: EmojiCategoryList) => number; updateFrequentCategory: (emojiId: string) => void; } interface IFrequentEmojiStorage { get: () => FrequentEmojis; getList: () => string[]; set: (value: any) => void; update: (emojiId: string) => any; } declare class EmojiFloatingGridBuilder { protected localStorage: IFrequentEmojiStorage; protected sections: EmojiCategoryList[]; protected elements: GridElements; protected settings: EmojiSettingsType; protected grid: EmojiFloatingGrid; constructor(localStorage: IFrequentEmojiStorage, sections: EmojiCategoryList[], elements: GridElements, settings: EmojiSettingsType); private addFrequent; build(): EmojiFloatingGrid; } declare class EmojiFloatingLibrary extends EmojiInlineLibrary implements IEmojiFloatingLibrary { protected settings: EmojiSettingsType; protected localStorage: IFrequentEmojiStorage; protected library: EmojiLibrary; private static instance?; private categories; private emojis; private grid; private constructor(); static getInstance(settings: EmojiSettingsType, localStorage: IFrequentEmojiStorage, library?: _emoji_mart_data.EmojiMartData): EmojiFloatingLibrary; private initEmojis; getGrid(): EmojiFloatingGridType; indexOf(focusedCategory: EmojiCategoryList): number; updateFrequentCategory(emojiId: string): void; } type EmojiPickerStateDispatch = { type: string; payload?: Partial<EmojiPickerStateProps>; }; type EmojiPickerStateProps = { hasFound: boolean; isOpen: boolean; isSearching: boolean; searchResult: Emoji[]; searchValue: string; visibleCategories: MapEmojiCategoryList; emoji?: Emoji; focusedCategory?: EmojiCategoryList; frequentEmoji?: string; }; type MapEmojiCategoryList = Map<EmojiCategoryList, boolean>; declare const EmojiPickerState: () => [EmojiPickerStateProps, React.Dispatch<EmojiPickerStateDispatch>]; type ObserverCategoriesType = { ancestorRef: React.MutableRefObject<HTMLDivElement | null>; emojiLibrary: IEmojiFloatingLibrary; setFocusedAndVisibleSections: SetFocusedAndVisibleSectionsType; }; type SetFocusedAndVisibleSectionsType = (visibleSections: MapEmojiCategoryList, categoryId?: EmojiCategoryList) => void; declare const observeCategories: ({ ancestorRef, emojiLibrary, setFocusedAndVisibleSections, }: ObserverCategoriesType) => IntersectionObserver; type MutableRefs = React.MutableRefObject<{ content: React.RefObject<HTMLDivElement | null> | undefined; contentRoot: React.RefObject<HTMLDivElement | null> | undefined; }>; type UseEmojiPickerProps = { closeOnSelect: boolean; emojiLibrary: IEmojiFloatingLibrary; indexSearch: AIndexSearch; }; type UseEmojiPickerType<T extends React.ReactElement<any> = React.ReactElement<any>> = { emojiLibrary: IEmojiFloatingLibrary; hasFound: boolean; i18n: i18nProps; icons: EmojiIconList<T>; isOpen: boolean; isSearching: boolean; refs: MutableRefs; searchResult: Emoji[]; searchValue: string; visibleCategories: MapEmojiCategoryList; clearSearch: () => void; setIsOpen: (isOpen: boolean) => void; setSearch: (value: string) => void; handleCategoryClick: (id: EmojiCategoryList) => void; onMouseOver: (emoji?: Emoji) => void; onSelectEmoji: (emoji: Emoji) => void; emoji?: Emoji; focusedCategory?: EmojiCategoryList; settings?: EmojiSettingsType; styles?: any; }; declare const useEmojiPicker: ({ closeOnSelect, emojiLibrary, indexSearch, }: UseEmojiPickerProps) => Omit<UseEmojiPickerType, "icons" | "settings">; type EmojiDropdownMenuOptions = { closeOnSelect?: boolean; settings?: EmojiSettingsType; }; declare function useEmojiDropdownMenuState({ closeOnSelect, settings, }?: EmojiDropdownMenuOptions): { emojiPickerState: { emoji?: _emoji_mart_data.Emoji | undefined; hasFound: boolean; isSearching: boolean; searchResult: _emoji_mart_data.Emoji[]; searchValue: string; visibleCategories: MapEmojiCategoryList; focusedCategory?: EmojiCategoryList | undefined; emojiLibrary: IEmojiFloatingLibrary; i18n: i18nProps; refs: MutableRefs; clearSearch: () => void; setSearch: (value: string) => void; handleCategoryClick: (id: EmojiCategoryList) => void; onMouseOver: (emoji?: _emoji_mart_data.Emoji) => void; onSelectEmoji: (emoji: _emoji_mart_data.Emoji) => void; styles?: any; }; isOpen: boolean; setIsOpen: (isOpen: boolean) => void; }; interface ILocalStorage<T> { get: () => T; set: (value: T) => void; } declare class LocalStorage<T> implements ILocalStorage<T> { protected key: string; protected defaultValue: T; constructor(key: string, defaultValue: T); get(): T; set(value: any): void; } declare class FrequentEmojiStorage implements IFrequentEmojiStorage { protected defaultValue: FrequentEmojis; protected key: "frequent"; protected limit: number; protected localStorage: LocalStorage<FrequentEmojis>; protected prefix: string; constructor(props: FrequentEmojiStorageProps, defaultValue?: FrequentEmojis); get(): FrequentEmojis; getList(): string[]; set(value: any): void; update(emojiId: string): FrequentEmojis; } export { type EmojiDropdownMenuOptions, EmojiFloatingGrid, EmojiFloatingGridBuilder, type EmojiFloatingGridType, EmojiFloatingLibrary, EmojiGridSectionWithRoot, EmojiInputPlugin, EmojiPickerState, type EmojiPickerStateDispatch, type EmojiPickerStateProps, EmojiPlugin, FrequentEmojiStorage, type FrequentEmojiStorageProps, type IEmojiFloatingLibrary, type IFrequentEmojiStorage, type ILocalStorage, LocalStorage, type MapEmojiCategoryList, type MutableRefs, type ObserverCategoriesType, type SetFocusedAndVisibleSectionsType, type UseEmojiPickerProps, type UseEmojiPickerType, observeCategories, useEmojiDropdownMenuState, useEmojiPicker };