parent
ad7c660f04
commit
8c7bbc7a89
|
@ -119,14 +119,10 @@ dist
|
|||
/database.js.map
|
||||
/picker.js
|
||||
/picker.js.map
|
||||
/picker.d.ts
|
||||
/database.d.ts
|
||||
/shared.d.ts
|
||||
/trimEmojiData.js
|
||||
/trimEmojiData.js.map
|
||||
/trimEmojiData.cjs
|
||||
/trimEmojiData.cjs.map
|
||||
/trimEmojiData.d.ts
|
||||
/svelte.js
|
||||
/svelte.js.map
|
||||
|
||||
|
|
|
@ -69,12 +69,6 @@ So for now: it's one big component.
|
|||
|
||||
Since it's one big component, it's more readable if we split up the HTML/CSS/JS. Plus, we can lint the JS more easily that way. Plus, I like SCSS.
|
||||
|
||||
### Why are TypeScript files separate?
|
||||
|
||||
I don't really like writing TypeScript, but I appreciate the documentation and autocompletion it provides for consumers. I could just author the `.d.ts` files, but 1) I don't really know how to do that, and 2) `typedoc` seems to require TypeScript as input, not `.d.ts`.
|
||||
|
||||
So, I just have a `types/` directory with some fake TypeScript files to generate the types and docs. Happy to revisit later if there's a better solution.
|
||||
|
||||
### Why are the built JS files at the root of the project?
|
||||
|
||||
When publishing to npm, we want people to be able to do e.g. `import Picker from 'emoji-picker-element/picker'`. The only way to get that is to put `picker.js` at the top level.
|
||||
|
|
|
@ -246,8 +246,6 @@ document.body.appendChild(picker);
|
|||
|
||||
The `new Picker(options)` constructor supports several options:
|
||||
|
||||
<!-- picker API start -->
|
||||
|
||||
Name | Type | Default | Description |
|
||||
------ | ------ | ------ | ------ |
|
||||
`customCategorySorting` | function | - | Function to sort custom category strings (sorted alphabetically by default) |
|
||||
|
@ -259,8 +257,6 @@ Name | Type | Default | Description |
|
|||
|
||||
|
||||
|
||||
<!-- picker API end -->
|
||||
|
||||
For instance:
|
||||
|
||||
```js
|
||||
|
@ -369,8 +365,6 @@ Also note that, unlike the picker, the database does not filter emoji based on w
|
|||
|
||||
Full API:
|
||||
|
||||
<!-- database API start -->
|
||||
|
||||
#### Constructors
|
||||
|
||||
##### constructor
|
||||
|
@ -596,8 +590,6 @@ Name | Type | Description |
|
|||
**Returns:** *Promise‹void›*
|
||||
|
||||
|
||||
<!-- database API end -->
|
||||
|
||||
### Events
|
||||
|
||||
#### `emoji-click`
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
import { replaceInReadme } from './replaceInReadme.js'
|
||||
import { readFile } from './fs.js'
|
||||
import replaceAll from 'string.prototype.replaceall'
|
||||
replaceAll.shim()
|
||||
|
||||
const DB_START_MARKER = '<!-- database API start -->'
|
||||
const DB_END_MARKER = '<!-- database API end -->'
|
||||
|
||||
const PICKER_START_MARKER = '<!-- picker API start -->'
|
||||
const PICKER_END_MARKER = '<!-- picker API end -->'
|
||||
|
||||
// Given the typedoc output and generated into docs-tmp, inject these into the README
|
||||
function removeLinks (str) {
|
||||
return str.replaceAll(/\[([^\]]+?)]\([^)]+?\)/sg, (_, p1) => p1)
|
||||
}
|
||||
|
||||
function incrementHeadings (str) {
|
||||
return str.replaceAll(/#+/g, _ => `##${_}`) // increase indent of headings by two
|
||||
}
|
||||
|
||||
async function injectDatabaseDocs () {
|
||||
let docs = await readFile('./docs-tmp/classes/_database_.database.md', 'utf8')
|
||||
docs = docs.substring(docs.lastIndexOf('## Constructors'))
|
||||
docs = removeLinks(docs)
|
||||
docs = incrementHeadings(docs)
|
||||
|
||||
await replaceInReadme(DB_START_MARKER, DB_END_MARKER, docs)
|
||||
}
|
||||
|
||||
async function injectPickerDocs () {
|
||||
let docs = await readFile('./docs-tmp/classes/_picker_.picker.md', 'utf8')
|
||||
docs = docs.substring(docs.indexOf('Name | Type'), docs.indexOf('**Returns:**'))
|
||||
docs = removeLinks(docs)
|
||||
|
||||
await replaceInReadme(PICKER_START_MARKER, PICKER_END_MARKER, docs)
|
||||
}
|
||||
|
||||
async function main () {
|
||||
await injectDatabaseDocs()
|
||||
await injectPickerDocs()
|
||||
}
|
||||
|
||||
main().catch(err => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
|
@ -0,0 +1,108 @@
|
|||
import { Emoji, DatabaseConstructorOptions, SkinTone, CustomEmoji, NativeEmoji } from "./shared";
|
||||
export default class Database {
|
||||
/**
|
||||
* Create a new Database.
|
||||
*
|
||||
* Note that multiple Databases pointing to the same locale will share the
|
||||
* same underlying IndexedDB connection and database.
|
||||
*
|
||||
* @param dataSource - URL to fetch the emoji data from
|
||||
* @param locale - Locale string
|
||||
* @param customEmoji - Array of custom emoji
|
||||
*/
|
||||
constructor({ dataSource, locale, customEmoji }?: DatabaseConstructorOptions);
|
||||
/**
|
||||
* Resolves when the Database is ready, or throws an error if
|
||||
* the Database could not initialize.
|
||||
*
|
||||
* Note that you don't need to do this before calling other APIs – they will
|
||||
* all wait for this promise to resolve before doing anything.
|
||||
*/
|
||||
ready(): Promise<void>;
|
||||
/**
|
||||
* Returns all emoji belonging to a group, ordered by `order`. Only returns native emoji;
|
||||
* custom emoji don't belong to a group.
|
||||
*
|
||||
* Non-numbers throw an error.
|
||||
* @param group - the group number
|
||||
*/
|
||||
getEmojiByGroup(group: number): Promise<NativeEmoji[]>;
|
||||
/**
|
||||
* Returns all emoji matching the given search query, ordered by `order`.
|
||||
*
|
||||
* Empty/null strings throw an error.
|
||||
*
|
||||
* @param query - search query string
|
||||
*/
|
||||
getEmojiBySearchQuery(query: string): Promise<Emoji[]>;
|
||||
/**
|
||||
* Return a single emoji matching the shortcode, or null if not found.
|
||||
*
|
||||
* The colons around the shortcode should not be included when querying, e.g.
|
||||
* use "slight_smile", not ":slight_smile:". Uppercase versus lowercase
|
||||
* does not matter. Empty/null strings throw an error.
|
||||
* @param shortcode
|
||||
*/
|
||||
getEmojiByShortcode(shortcode: string): Promise<Emoji | null>;
|
||||
/**
|
||||
* Return a single native emoji matching the unicode string, or
|
||||
* a custom emoji matching the name, or null if not found.
|
||||
*
|
||||
* In the case of native emoji, the unicode string can be either the
|
||||
* main unicode string, or the unicode of one of the skin tone variants.
|
||||
*
|
||||
* Empty/null strings throw an error.
|
||||
* @param unicodeOrName - unicode (native emoji) or name (custom emoji)
|
||||
*/
|
||||
getEmojiByUnicodeOrName(unicodeOrName: string): Promise<Emoji | null>;
|
||||
/**
|
||||
* Get the user's preferred skin tone. Returns 0 if not found.
|
||||
*/
|
||||
getPreferredSkinTone(): Promise<SkinTone>;
|
||||
/**
|
||||
* Set the user's preferred skin tone. Non-numbers throw an error.
|
||||
*
|
||||
* @param skinTone - preferred skin tone
|
||||
*/
|
||||
setPreferredSkinTone(skinTone: SkinTone): Promise<void>;
|
||||
/**
|
||||
* Increment the favorite count for an emoji by one. The unicode string must be non-empty. It should
|
||||
* correspond to the base (non-skin-tone) unicode string from the emoji object, or in the case of
|
||||
* custom emoji, it should be the name.
|
||||
*
|
||||
* @param unicodeOrName - unicode of a native emoji, or name of a custom emoji
|
||||
*/
|
||||
incrementFavoriteEmojiCount(unicodeOrName: string): Promise<void>;
|
||||
/**
|
||||
* Get the top favorite emoji in descending order. If there are no favorite emoji yet, returns an empty array.
|
||||
* @param limit - maximum number of results to return
|
||||
*/
|
||||
getTopFavoriteEmoji(limit: number): Promise<Emoji[]>;
|
||||
/**
|
||||
* Set the custom emoji for this database. Throws an error if custom emoji are not in the correct format.
|
||||
*
|
||||
*
|
||||
* @param customEmoji
|
||||
*/
|
||||
set customEmoji(customEmoji: CustomEmoji[]);
|
||||
/**
|
||||
* Return the custom emoji associated with this Database, or the empty array if none.
|
||||
*/
|
||||
get customEmoji(): CustomEmoji[];
|
||||
/**
|
||||
* Closes the underlying IndexedDB connection. The Database is not usable after that (or any other Databases
|
||||
* with the same locale).
|
||||
*
|
||||
* Note that as soon as any other non-close/delete method is called, the database will automatically reopen.
|
||||
*
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
/**
|
||||
* Deletes the underlying IndexedDB database. The Database is not usable after that (or any other Databases
|
||||
* with the same locale).
|
||||
*
|
||||
* Note that as soon as any other non-close/delete method is called, the database will be recreated.
|
||||
*
|
||||
*/
|
||||
delete(): Promise<void>;
|
||||
}
|
13
package.json
13
package.json
|
@ -18,12 +18,10 @@
|
|||
],
|
||||
"scripts": {
|
||||
"prepare": "run-s build",
|
||||
"build": "run-s build:rollup build:css-docs build:i18n-docs build:types build:typedoc build:toc",
|
||||
"build": "run-s build:rollup build:css-docs build:i18n-docs build:toc",
|
||||
"build:rollup": "cross-env NODE_ENV=production rollup -c",
|
||||
"build:css-docs": "node ./bin/generateCssDocs",
|
||||
"build:i18n-docs": "node ./bin/generateI18nDocs",
|
||||
"build:typedoc": "typedoc --target ES5 --out docs-tmp --theme markdown --excludePrivate --excludeNotExported --hideSources --hideBreadcrumbs ./src/types && node ./bin/generateTypeDocs && shx rm -fr docs-tmp",
|
||||
"build:types": "tsc --target ES5 -d --outDir ./ts-tmp --project ./src/types && shx mv ./ts-tmp/*.d.ts ./ && shx rm -fr ts-tmp",
|
||||
"build:toc": "node ./bin/generateTOC",
|
||||
"benchmark:runtime": "cross-env PERF=1 run-s build:rollup && ./bin/run-benchmark.sh",
|
||||
"benchmark:bundlesize": "run-s build:rollup benchmark:bundle benchmark:run-bundlesize",
|
||||
|
@ -125,14 +123,7 @@
|
|||
"svelte-jester": "nolanlawson/svelte-jester#auto-preprocess",
|
||||
"svelte-preprocess": "^4.7.3",
|
||||
"svgo": "^2.3.1",
|
||||
"tachometer": "^0.5.9",
|
||||
"typedoc": "^0.19.2",
|
||||
"typedoc-plugin-markdown": "^2.4.2",
|
||||
"typescript": "~4.0.0"
|
||||
},
|
||||
"// Old versions of typedoc depend on a vulnerable version of marked, 2.0.0+ works fine": true,
|
||||
"resolutions": {
|
||||
"marked": "^2.1.3"
|
||||
"tachometer": "^0.5.9"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import { I18n, PickerConstructorOptions, EmojiPickerEventMap, CustomEmoji } from "./shared";
|
||||
export default class Picker extends HTMLElement {
|
||||
dataSource: string;
|
||||
locale: string;
|
||||
i18n: I18n;
|
||||
skinToneEmoji: string;
|
||||
customEmoji?: CustomEmoji[];
|
||||
customCategorySorting?: (a: string, b: string) => number;
|
||||
/**
|
||||
*
|
||||
* @param dataSource - URL to fetch the emoji data from (`data-source` when used as an attribute)
|
||||
* @param locale - Locale string
|
||||
* @param i18n - i18n object (see below for details)
|
||||
* @param skinToneEmoji - The emoji to use for the skin tone picker (`skin-tone-emoji` when used as an attribute)
|
||||
* @param customEmoji - Array of custom emoji
|
||||
* @param customCategorySorting - Function to sort custom category strings (sorted alphabetically by default)
|
||||
*/
|
||||
constructor({ dataSource, locale, i18n, skinToneEmoji, customEmoji, customCategorySorting }?: PickerConstructorOptions);
|
||||
|
||||
addEventListener<K extends keyof EmojiPickerEventMap>(type: K, listener: (this: Picker, ev: EmojiPickerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
||||
removeEventListener<K extends keyof EmojiPickerEventMap>(type: K, listener: (this: Picker, ev: EmojiPickerEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
||||
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
||||
}
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"emoji-picker": Picker;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
export declare enum SkinTone {
|
||||
Default = 0,
|
||||
Light = 1,
|
||||
MediumLight = 2,
|
||||
Medium = 3,
|
||||
MediumDark = 4,
|
||||
Dark = 5
|
||||
}
|
||||
export interface NativeEmoji {
|
||||
annotation: string;
|
||||
emoticon?: string;
|
||||
group: number;
|
||||
name: string;
|
||||
order: number;
|
||||
shortcodes?: string[];
|
||||
tags?: string[];
|
||||
version: number;
|
||||
unicode: string;
|
||||
skins?: EmojiSkin[];
|
||||
}
|
||||
export interface EmojiSkin {
|
||||
tone: SkinTone;
|
||||
unicode: string;
|
||||
version: number;
|
||||
}
|
||||
export interface DatabaseConstructorOptions {
|
||||
dataSource?: string;
|
||||
locale?: string;
|
||||
customEmoji?: CustomEmoji[];
|
||||
}
|
||||
export interface PickerConstructorOptions {
|
||||
dataSource?: string;
|
||||
locale?: string;
|
||||
i18n?: I18n;
|
||||
skinToneEmoji?: string;
|
||||
customEmoji?: CustomEmoji[];
|
||||
customCategorySorting?: (a: string, b: string) => number;
|
||||
}
|
||||
export interface I18n {
|
||||
emojiUnsupportedMessage: string;
|
||||
loadingMessage: string;
|
||||
networkErrorMessage: string;
|
||||
regionLabel: string;
|
||||
searchLabel: string;
|
||||
skinToneLabel: string;
|
||||
searchResultsLabel: string;
|
||||
categoriesLabel: string;
|
||||
categories: I18nCategories;
|
||||
skinTonesLabel: string;
|
||||
skinTones: string[];
|
||||
searchDescription: string;
|
||||
skinToneDescription: string;
|
||||
favoritesLabel: string;
|
||||
}
|
||||
export interface I18nCategories {
|
||||
custom: string;
|
||||
'smileys-emotion': string;
|
||||
'people-body': string;
|
||||
'animals-nature': string;
|
||||
'food-drink': string;
|
||||
'travel-places': string;
|
||||
activities: string;
|
||||
objects: string;
|
||||
symbols: string;
|
||||
flags: string;
|
||||
}
|
||||
export interface EmojiClickEventDetail {
|
||||
emoji: Emoji;
|
||||
skinTone: SkinTone;
|
||||
unicode?: string;
|
||||
name?: string;
|
||||
}
|
||||
export interface SkinToneChangeEventDetail {
|
||||
skinTone: SkinTone;
|
||||
}
|
||||
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
||||
export declare type EmojiClickEvent = Modify<UIEvent, {
|
||||
detail: EmojiClickEventDetail;
|
||||
}>;
|
||||
export declare type SkinToneChangeEvent = Modify<UIEvent, {
|
||||
detail: SkinToneChangeEventDetail;
|
||||
}>;
|
||||
export interface EmojiPickerEventMap {
|
||||
"emoji-click": EmojiClickEvent;
|
||||
"skin-tone-change": SkinToneChangeEvent;
|
||||
}
|
||||
export interface CustomEmoji {
|
||||
name: string;
|
||||
shortcodes?: string[];
|
||||
url: string;
|
||||
category?: string;
|
||||
}
|
||||
export declare type Emoji = NativeEmoji | CustomEmoji;
|
||||
export {};
|
|
@ -1,153 +0,0 @@
|
|||
import {Emoji, DatabaseConstructorOptions, SkinTone, CustomEmoji, NativeEmoji} from "./shared";
|
||||
|
||||
export default class Database {
|
||||
|
||||
/**
|
||||
* Create a new Database.
|
||||
*
|
||||
* Note that multiple Databases pointing to the same locale will share the
|
||||
* same underlying IndexedDB connection and database.
|
||||
*
|
||||
* @param dataSource - URL to fetch the emoji data from
|
||||
* @param locale - Locale string
|
||||
* @param customEmoji - Array of custom emoji
|
||||
*/
|
||||
constructor({
|
||||
dataSource = 'https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json',
|
||||
locale = 'en',
|
||||
customEmoji = []
|
||||
}: DatabaseConstructorOptions = {}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves when the Database is ready, or throws an error if
|
||||
* the Database could not initialize.
|
||||
*
|
||||
* Note that you don't need to do this before calling other APIs – they will
|
||||
* all wait for this promise to resolve before doing anything.
|
||||
*/
|
||||
ready(): Promise<void> {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all emoji belonging to a group, ordered by `order`. Only returns native emoji;
|
||||
* custom emoji don't belong to a group.
|
||||
*
|
||||
* Non-numbers throw an error.
|
||||
* @param group - the group number
|
||||
*/
|
||||
getEmojiByGroup(group: number): Promise<NativeEmoji[]> {
|
||||
return Promise.resolve([])
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all emoji matching the given search query, ordered by `order`.
|
||||
*
|
||||
* Empty/null strings throw an error.
|
||||
*
|
||||
* @param query - search query string
|
||||
*/
|
||||
getEmojiBySearchQuery(query: string): Promise<Emoji[]> {
|
||||
return Promise.resolve([])
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a single emoji matching the shortcode, or null if not found.
|
||||
*
|
||||
* The colons around the shortcode should not be included when querying, e.g.
|
||||
* use "slight_smile", not ":slight_smile:". Uppercase versus lowercase
|
||||
* does not matter. Empty/null strings throw an error.
|
||||
* @param shortcode
|
||||
*/
|
||||
getEmojiByShortcode(shortcode: string): Promise<Emoji | null> {
|
||||
return Promise.resolve(null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a single native emoji matching the unicode string, or
|
||||
* a custom emoji matching the name, or null if not found.
|
||||
*
|
||||
* In the case of native emoji, the unicode string can be either the
|
||||
* main unicode string, or the unicode of one of the skin tone variants.
|
||||
*
|
||||
* Empty/null strings throw an error.
|
||||
* @param unicodeOrName - unicode (native emoji) or name (custom emoji)
|
||||
*/
|
||||
getEmojiByUnicodeOrName(unicodeOrName: string): Promise<Emoji | null> {
|
||||
return Promise.resolve(null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's preferred skin tone. Returns 0 if not found.
|
||||
*/
|
||||
getPreferredSkinTone(): Promise<SkinTone> {
|
||||
return Promise.resolve(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user's preferred skin tone. Non-numbers throw an error.
|
||||
*
|
||||
* @param skinTone - preferred skin tone
|
||||
*/
|
||||
setPreferredSkinTone(skinTone: SkinTone): Promise<void> {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the favorite count for an emoji by one. The unicode string must be non-empty. It should
|
||||
* correspond to the base (non-skin-tone) unicode string from the emoji object, or in the case of
|
||||
* custom emoji, it should be the name.
|
||||
*
|
||||
* @param unicodeOrName - unicode of a native emoji, or name of a custom emoji
|
||||
*/
|
||||
incrementFavoriteEmojiCount (unicodeOrName: string): Promise<void> {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top favorite emoji in descending order. If there are no favorite emoji yet, returns an empty array.
|
||||
* @param limit - maximum number of results to return
|
||||
*/
|
||||
getTopFavoriteEmoji (limit: number): Promise<Emoji[]> {
|
||||
return Promise.resolve([])
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the custom emoji for this database. Throws an error if custom emoji are not in the correct format.
|
||||
*
|
||||
*
|
||||
* @param customEmoji
|
||||
*/
|
||||
set customEmoji(customEmoji: CustomEmoji[]) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the custom emoji associated with this Database, or the empty array if none.
|
||||
*/
|
||||
get customEmoji(): CustomEmoji[] {
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the underlying IndexedDB connection. The Database is not usable after that (or any other Databases
|
||||
* with the same locale).
|
||||
*
|
||||
* Note that as soon as any other non-close/delete method is called, the database will automatically reopen.
|
||||
*
|
||||
*/
|
||||
close(): Promise<void> {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the underlying IndexedDB database. The Database is not usable after that (or any other Databases
|
||||
* with the same locale).
|
||||
*
|
||||
* Note that as soon as any other non-close/delete method is called, the database will be recreated.
|
||||
*
|
||||
*/
|
||||
delete(): Promise<void> {
|
||||
return Promise.resolve()
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
import {I18n, PickerConstructorOptions, EmojiPickerEventMap, CustomEmoji} from "./shared";
|
||||
|
||||
export default class Picker extends HTMLElement {
|
||||
dataSource: string
|
||||
locale: string
|
||||
i18n: I18n
|
||||
skinToneEmoji: string
|
||||
customEmoji?: CustomEmoji[]
|
||||
customCategorySorting?: (a: string, b: string) => number
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataSource - URL to fetch the emoji data from (`data-source` when used as an attribute)
|
||||
* @param locale - Locale string
|
||||
* @param i18n - i18n object (see below for details)
|
||||
* @param skinToneEmoji - The emoji to use for the skin tone picker (`skin-tone-emoji` when used as an attribute)
|
||||
* @param customEmoji - Array of custom emoji
|
||||
* @param customCategorySorting - Function to sort custom category strings (sorted alphabetically by default)
|
||||
*/
|
||||
constructor({
|
||||
dataSource = 'https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json',
|
||||
locale = 'en',
|
||||
i18n,
|
||||
skinToneEmoji = '🖐️',
|
||||
customEmoji,
|
||||
customCategorySorting
|
||||
}: PickerConstructorOptions = {}) {
|
||||
super()
|
||||
}
|
||||
|
||||
addEventListener<K extends keyof EmojiPickerEventMap>(type: K, listener: (this: Picker, ev: EmojiPickerEventMap[K]) => any, options?: boolean | AddEventListenerOptions) {
|
||||
super.addEventListener(type, listener, options);
|
||||
}
|
||||
|
||||
removeEventListener<K extends keyof EmojiPickerEventMap>(type: K, listener: (this: Picker, ev: EmojiPickerEventMap[K]) => any, options?: boolean | EventListenerOptions) {
|
||||
super.removeEventListener(type, listener, options);
|
||||
}
|
||||
}
|
||||
|
||||
// see https://justinfagnani.com/2019/11/01/how-to-publish-web-components-to-npm/
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"emoji-picker": Picker,
|
||||
}
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
export enum SkinTone {
|
||||
Default = 0,
|
||||
Light = 1,
|
||||
MediumLight = 2,
|
||||
Medium = 3,
|
||||
MediumDark = 4,
|
||||
Dark = 5
|
||||
}
|
||||
|
||||
export interface NativeEmoji {
|
||||
annotation: string
|
||||
emoticon?: string
|
||||
group: number
|
||||
name: string
|
||||
order: number
|
||||
shortcodes?: string[]
|
||||
tags?: string[]
|
||||
version: number
|
||||
unicode: string
|
||||
skins?: EmojiSkin[]
|
||||
}
|
||||
|
||||
export interface EmojiSkin {
|
||||
tone: SkinTone
|
||||
unicode: string
|
||||
version: number
|
||||
}
|
||||
|
||||
export interface DatabaseConstructorOptions {
|
||||
dataSource?: string
|
||||
locale?: string
|
||||
customEmoji?: CustomEmoji[]
|
||||
}
|
||||
|
||||
export interface PickerConstructorOptions {
|
||||
dataSource?: string
|
||||
locale?: string
|
||||
i18n?: I18n
|
||||
skinToneEmoji?: string
|
||||
customEmoji?: CustomEmoji[]
|
||||
customCategorySorting?: (a: string, b: string) => number
|
||||
}
|
||||
|
||||
export interface I18n {
|
||||
emojiUnsupportedMessage: string
|
||||
loadingMessage: string
|
||||
networkErrorMessage: string
|
||||
regionLabel: string
|
||||
searchLabel: string
|
||||
skinToneLabel: string
|
||||
searchResultsLabel: string
|
||||
categoriesLabel: string
|
||||
categories: I18nCategories
|
||||
skinTonesLabel: string
|
||||
skinTones: string[]
|
||||
searchDescription: string
|
||||
skinToneDescription: string
|
||||
favoritesLabel: string
|
||||
}
|
||||
|
||||
export interface I18nCategories {
|
||||
custom: string,
|
||||
'smileys-emotion': string
|
||||
'people-body': string
|
||||
'animals-nature': string
|
||||
'food-drink': string
|
||||
'travel-places': string
|
||||
activities: string
|
||||
objects: string
|
||||
symbols: string
|
||||
flags: string
|
||||
}
|
||||
|
||||
export interface EmojiClickEventDetail {
|
||||
emoji: Emoji,
|
||||
skinTone: SkinTone
|
||||
unicode?: string
|
||||
name?: string
|
||||
}
|
||||
|
||||
export interface SkinToneChangeEventDetail {
|
||||
skinTone: SkinTone
|
||||
}
|
||||
|
||||
// via https://stackoverflow.com/a/55032655/680742
|
||||
type Modify<T, R> = Omit<T, keyof R> & R;
|
||||
|
||||
export type EmojiClickEvent = Modify<UIEvent, {
|
||||
detail: EmojiClickEventDetail
|
||||
}>
|
||||
|
||||
export type SkinToneChangeEvent = Modify<UIEvent, {
|
||||
detail: SkinToneChangeEventDetail
|
||||
}>
|
||||
|
||||
export interface EmojiPickerEventMap {
|
||||
"emoji-click": EmojiClickEvent
|
||||
"skin-tone-change": SkinToneChangeEvent
|
||||
}
|
||||
|
||||
export interface CustomEmoji {
|
||||
name: string
|
||||
shortcodes?: string[]
|
||||
url: string
|
||||
category?: string
|
||||
}
|
||||
|
||||
export type Emoji = NativeEmoji | CustomEmoji
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
// An empty tsconfig file makes this directory a "project" that `tsc` can recognize. It'll build
|
||||
// all files in this directory by default so we don't need to set any setting.
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
import {Emoji} from "./shared";
|
||||
|
||||
import { Emoji } from "./shared";
|
||||
/**
|
||||
* Given an array of emoji (e.g. emojibase-data/en/data.json), extract out only the data
|
||||
* needed for emoji-picker-element, resulting in a smaller object.
|
||||
* @param emojiData
|
||||
* @deprecated - Not required when using emoji-picker-element-data rather than emojibase-data
|
||||
*/
|
||||
export default function trimEmojiData(emojiData: Emoji[]): Emoji[] {
|
||||
return []
|
||||
}
|
||||
export default function trimEmojiData(emojiData: Emoji[]): Emoji[];
|
54
yarn.lock
54
yarn.lock
|
@ -4293,11 +4293,6 @@ has@^1.0.3:
|
|||
dependencies:
|
||||
function-bind "^1.1.1"
|
||||
|
||||
highlight.js@^10.2.0:
|
||||
version "10.7.3"
|
||||
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.7.3.tgz#697272e3991356e40c3cac566a74eef681756531"
|
||||
integrity sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==
|
||||
|
||||
hosted-git-info@^2.1.4:
|
||||
version "2.8.9"
|
||||
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
|
||||
|
@ -5886,7 +5881,7 @@ lodash.truncate@^4.4.2:
|
|||
resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193"
|
||||
integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=
|
||||
|
||||
lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.7.0:
|
||||
lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.7.0:
|
||||
version "4.17.21"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||
|
@ -5933,11 +5928,6 @@ lru-cache@^6.0.0:
|
|||
dependencies:
|
||||
yallist "^4.0.0"
|
||||
|
||||
lunr@^2.3.9:
|
||||
version "2.3.9"
|
||||
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1"
|
||||
integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==
|
||||
|
||||
lz-string@^1.4.4:
|
||||
version "1.4.4"
|
||||
resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.4.4.tgz#c0d8eaf36059f705796e1e344811cf4c498d3a26"
|
||||
|
@ -6004,11 +5994,6 @@ markdown-toc@^1.2.0:
|
|||
repeat-string "^1.6.1"
|
||||
strip-color "^0.1.0"
|
||||
|
||||
marked@^1.1.1, marked@^2.1.3:
|
||||
version "2.1.3"
|
||||
resolved "https://registry.yarnpkg.com/marked/-/marked-2.1.3.tgz#bd017cef6431724fd4b27e0657f5ceb14bff3753"
|
||||
integrity sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==
|
||||
|
||||
math-random@^1.0.1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.4.tgz#5dd6943c938548267016d4e34f057583080c514c"
|
||||
|
@ -6197,7 +6182,7 @@ min-indent@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869"
|
||||
integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==
|
||||
|
||||
minimatch@3.0.4, minimatch@^3.0.0, minimatch@^3.0.4:
|
||||
minimatch@3.0.4, minimatch@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
|
||||
|
@ -8700,41 +8685,6 @@ typedarray@^0.0.6:
|
|||
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
||||
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
|
||||
|
||||
typedoc-default-themes@^0.11.4:
|
||||
version "0.11.4"
|
||||
resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.11.4.tgz#1bc55b7c8d1132844616ff6f570e1e2cd0eb7343"
|
||||
integrity sha512-Y4Lf+qIb9NTydrexlazAM46SSLrmrQRqWiD52593g53SsmUFioAsMWt8m834J6qsp+7wHRjxCXSZeiiW5cMUdw==
|
||||
|
||||
typedoc-plugin-markdown@^2.4.2:
|
||||
version "2.4.2"
|
||||
resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-2.4.2.tgz#2d83fe4f279643436ebc44ca2f937855b0fd9f12"
|
||||
integrity sha512-BBH+9/Uq5XbsqfzCDl8Jq4iaLXRMXRuAHZRFarAZX7df8+F3vUjDx/WHWoWqbZ/XUFzduLC2Iuy2qwsJX8SQ7A==
|
||||
dependencies:
|
||||
fs-extra "^9.0.1"
|
||||
handlebars "^4.7.6"
|
||||
|
||||
typedoc@^0.19.2:
|
||||
version "0.19.2"
|
||||
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.19.2.tgz#842a63a581f4920f76b0346bb80eb2a49afc2c28"
|
||||
integrity sha512-oDEg1BLEzi1qvgdQXc658EYgJ5qJLVSeZ0hQ57Eq4JXy6Vj2VX4RVo18qYxRWz75ifAaYuYNBUCnbhjd37TfOg==
|
||||
dependencies:
|
||||
fs-extra "^9.0.1"
|
||||
handlebars "^4.7.6"
|
||||
highlight.js "^10.2.0"
|
||||
lodash "^4.17.20"
|
||||
lunr "^2.3.9"
|
||||
marked "^1.1.1"
|
||||
minimatch "^3.0.0"
|
||||
progress "^2.0.3"
|
||||
semver "^7.3.2"
|
||||
shelljs "^0.8.4"
|
||||
typedoc-default-themes "^0.11.4"
|
||||
|
||||
typescript@~4.0.0:
|
||||
version "4.0.8"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.8.tgz#5739105541db80a971fdbd0d56511d1a6f17d37f"
|
||||
integrity sha512-oz1765PN+imfz1MlZzSZPtC/tqcwsCyIYA8L47EkRnRW97ztRk83SzMiWLrnChC0vqoYxSU1fcFUDA5gV/ZiPg==
|
||||
|
||||
typeson-registry@^1.0.0-alpha.20:
|
||||
version "1.0.0-alpha.39"
|
||||
resolved "https://registry.yarnpkg.com/typeson-registry/-/typeson-registry-1.0.0-alpha.39.tgz#9e0f5aabd5eebfcffd65a796487541196f4b1211"
|
||||
|
|
Loading…
Reference in New Issue