UNPKG

@udecode/plate-emoji

Version:

Emoji plugin for Plate

162 lines (153 loc) 5.21 kB
import { Emoji, EmojiMartData } from '@emoji-mart/data'; type EmojiSettingsType = { buttonSize: { value: number; }; categories: { value?: EmojiCategoryList[]; }; perLine: { value: number; }; showFrequent: { value: boolean; key?: string; limit?: number; prefix?: string; }; }; type ReverseMap<T> = T[keyof T]; declare const EmojiCategory: { readonly Activity: "activity"; readonly Custom: "custom"; readonly Flags: "flags"; readonly Foods: "foods"; readonly Frequent: "frequent"; readonly Nature: "nature"; readonly Objects: "objects"; readonly People: "people"; readonly Places: "places"; readonly Symbols: "symbols"; }; type EmojiCategoryList = ReverseMap<typeof EmojiCategory>; type EmojiIconList<T = string> = { categories: Record<EmojiCategoryList, { outline: T; solid: T; }>; search: { delete: T; loupe: T; }; }; type FrequentEmojis = Record<string, number>; type i18nProps = { categories: Record<EmojiCategoryList, string>; clear: string; pick: string; search: string; searchNoResultsSubtitle: string; searchNoResultsTitle: string; searchResult: string; skins: Record<'1' | '2' | '3' | '4' | '5' | '6' | 'choose', string>; }; /** * Emoji: type Emoji = { id: string; name: string; keywords: string[]; skins: [ * { unified: '1f389'; native: '🎉'; shortcodes: ':tada:'; } ]; version: 1; }; */ type EmojiLibrary = EmojiMartData; type Emojis = Record<string, Emoji>; interface IEmojiLibrary { keys: string[]; getEmoji: (key: string) => Emoji; getEmojiId: (key: string) => string; } type THash = Record<string, string>; declare class EmojiInlineLibrary implements IEmojiLibrary { protected _emojis: Emojis; protected _hash: THash; protected _keys: string[]; constructor(library?: EmojiLibrary); private createSearchableString; private getName; private init; getEmoji(id: string): Emoji; getEmojiId(key: string): string; get keys(): string[]; } type GridElements<S extends SectionId = SectionId> = Record<S, string[]>; type GridRow = { id: number; elements: string[]; }; type GridRows = GridRow[]; interface IGrid<R, T extends SectionId> { size: number; addSection: (sectionId: T, section: IGridSection<R, T>, elements: GridElements) => this; indexOf: (sectionId: T) => number; section: (sectionId: T) => IGridSection<R, T>; sections: () => IGridSection<R, T>[]; updateSection: (sectionId: T, elements: SectionElements) => this; } interface IGridSection<R, T> { id: T; root: R; rowsNum: number; addElements: (elements: SectionElements) => this; getRows: () => GridRows; setIndexRowStart: (start: number) => this; updateElements: (elements: SectionElements) => this; } type SectionElements = string[]; type SectionId = string; type Unknown = unknown; declare class Grid<R, T extends SectionId = SectionId> implements IGrid<R, T> { protected grid: Map<T, IGridSection<R, T>>; protected rowsCount: number; protected sectionsIds: T[]; addSection(sectionId: T, section: IGridSection<R, T>, elements: GridElements): this; indexOf(sectionId: T): number; section(sectionId: T): IGridSection<R, T>; sections(): IGridSection<R, T>[]; updateSection(sectionId: T, elements: SectionElements): this; get size(): number; } declare abstract class AGridSection<R extends Unknown, T = SectionId> implements IGridSection<R, T> { protected _id: T; protected perLine: number; protected _indexRowStart: number; protected _root: R; protected _rowsNum: number; protected rows: GridRows; constructor(_id: T, perLine?: number); private addRow; private initRows; protected abstract createRootRef(): void; addElements(elements: SectionElements): this; getRows(): GridRows; setIndexRowStart(start: number): this; updateElements(elements: SectionElements): this; get id(): T; get root(): R; get rowsNum(): number; } interface IIndexSearch { get: () => Emoji[]; hasFound: () => boolean; search: (input: string) => void; } declare abstract class AIndexSearch implements IIndexSearch { protected library: IEmojiLibrary; protected input: string | undefined; protected maxResult: number; protected result: string[]; protected scores: {}; protected constructor(library: IEmojiLibrary); private createSearchResult; private sortResultByScores; get(): Emoji[]; getEmoji(): Emoji | undefined; hasFound(exact?: boolean): boolean; search(input: string): this; } export { AIndexSearch as A, type EmojiCategoryList as E, type FrequentEmojis as F, Grid as G, type IEmojiLibrary as I, type SectionElements as S, type THash as T, type Unknown as U, type EmojiSettingsType as a, EmojiCategory as b, type EmojiIconList as c, EmojiInlineLibrary as d, type EmojiLibrary as e, type Emojis as f, type GridElements as g, type GridRow as h, type i18nProps as i, type GridRows as j, type IGrid as k, type IGridSection as l, type SectionId as m, AGridSection as n };