xeroemoji 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMMERCIAL-LICENSE.md +10 -4
- package/LICENSE +17 -29
- package/LICENSING.md +34 -0
- package/README.md +2 -2
- package/index.js +5 -5
- package/package.json +4 -4
- package/xero-emoji-picker.js +91 -0
- package/xero-emoji.js +1 -1
package/COMMERCIAL-LICENSE.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
# Commercial
|
|
1
|
+
# Commercial license
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
The emoji artwork (`svg/`, `png/`, the release zips, the CDN images) and the npm/PyPI packages are under **CC BY 4.0** and can be used commercially with credit. No commercial license is needed for them. See [`LICENSING.md`](LICENSING.md).
|
|
4
|
+
|
|
5
|
+
A separate commercial license from the author is needed for:
|
|
6
|
+
|
|
7
|
+
- **The Xero Emoji color font** (`fonts/`): free for non-commercial use under CC BY-NC 4.0 (`fonts/LICENSE`); any commercial use of the font files (bundling them in a product or app, selling them, using them in paid products or advertising) needs a commercial license.
|
|
8
|
+
- **The book**, *Xero Emoji Specimen Guide*: all rights reserved.
|
|
9
|
+
- **Merchandise and stickers** (physical goods, sticker packs, prints): all rights reserved.
|
|
10
|
+
|
|
11
|
+
Contact: maxinfeld@gmail.com
|
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Attribution
|
|
1
|
+
Attribution 4.0 International
|
|
2
2
|
|
|
3
3
|
=======================================================================
|
|
4
4
|
|
|
@@ -54,18 +54,16 @@ exhaustive, and do not form part of our licenses.
|
|
|
54
54
|
|
|
55
55
|
=======================================================================
|
|
56
56
|
|
|
57
|
-
Creative Commons Attribution
|
|
58
|
-
License
|
|
57
|
+
Creative Commons Attribution 4.0 International Public License
|
|
59
58
|
|
|
60
59
|
By exercising the Licensed Rights (defined below), You accept and agree
|
|
61
60
|
to be bound by the terms and conditions of this Creative Commons
|
|
62
|
-
Attribution
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
conditions.
|
|
61
|
+
Attribution 4.0 International Public License ("Public License"). To the
|
|
62
|
+
extent this Public License may be interpreted as a contract, You are
|
|
63
|
+
granted the Licensed Rights in consideration of Your acceptance of
|
|
64
|
+
these terms and conditions, and the Licensor grants You such rights in
|
|
65
|
+
consideration of benefits the Licensor receives from making the
|
|
66
|
+
Licensed Material available under these terms and conditions.
|
|
69
67
|
|
|
70
68
|
|
|
71
69
|
Section 1 -- Definitions.
|
|
@@ -91,6 +89,7 @@ Section 1 -- Definitions.
|
|
|
91
89
|
categorized. For purposes of this Public License, the rights
|
|
92
90
|
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
|
93
91
|
Rights.
|
|
92
|
+
|
|
94
93
|
d. Effective Technological Measures means those measures that, in the
|
|
95
94
|
absence of proper authority, may not be circumvented under laws
|
|
96
95
|
fulfilling obligations under Article 11 of the WIPO Copyright
|
|
@@ -113,15 +112,7 @@ Section 1 -- Definitions.
|
|
|
113
112
|
h. Licensor means the individual(s) or entity(ies) granting rights
|
|
114
113
|
under this Public License.
|
|
115
114
|
|
|
116
|
-
i.
|
|
117
|
-
commercial advantage or monetary compensation. For purposes of
|
|
118
|
-
this Public License, the exchange of the Licensed Material for
|
|
119
|
-
other material subject to Copyright and Similar Rights by digital
|
|
120
|
-
file-sharing or similar means is NonCommercial provided there is
|
|
121
|
-
no payment of monetary compensation in connection with the
|
|
122
|
-
exchange.
|
|
123
|
-
|
|
124
|
-
j. Share means to provide material to the public by any means or
|
|
115
|
+
i. Share means to provide material to the public by any means or
|
|
125
116
|
process that requires permission under the Licensed Rights, such
|
|
126
117
|
as reproduction, public display, public performance, distribution,
|
|
127
118
|
dissemination, communication, or importation, and to make material
|
|
@@ -129,13 +120,13 @@ Section 1 -- Definitions.
|
|
|
129
120
|
public may access the material from a place and at a time
|
|
130
121
|
individually chosen by them.
|
|
131
122
|
|
|
132
|
-
|
|
123
|
+
j. Sui Generis Database Rights means rights other than copyright
|
|
133
124
|
resulting from Directive 96/9/EC of the European Parliament and of
|
|
134
125
|
the Council of 11 March 1996 on the legal protection of databases,
|
|
135
126
|
as amended and/or succeeded, as well as other essentially
|
|
136
127
|
equivalent rights anywhere in the world.
|
|
137
128
|
|
|
138
|
-
|
|
129
|
+
k. You means the individual or entity exercising the Licensed Rights
|
|
139
130
|
under this Public License. Your has a corresponding meaning.
|
|
140
131
|
|
|
141
132
|
|
|
@@ -149,10 +140,9 @@ Section 2 -- Scope.
|
|
|
149
140
|
exercise the Licensed Rights in the Licensed Material to:
|
|
150
141
|
|
|
151
142
|
a. reproduce and Share the Licensed Material, in whole or
|
|
152
|
-
in part
|
|
143
|
+
in part; and
|
|
153
144
|
|
|
154
|
-
b. produce, reproduce, and Share Adapted Material
|
|
155
|
-
NonCommercial purposes only.
|
|
145
|
+
b. produce, reproduce, and Share Adapted Material.
|
|
156
146
|
|
|
157
147
|
2. Exceptions and Limitations. For the avoidance of doubt, where
|
|
158
148
|
Exceptions and Limitations apply to Your use, this Public
|
|
@@ -214,9 +204,7 @@ Section 2 -- Scope.
|
|
|
214
204
|
Rights, whether directly or through a collecting society
|
|
215
205
|
under any voluntary or waivable statutory or compulsory
|
|
216
206
|
licensing scheme. In all other cases the Licensor expressly
|
|
217
|
-
reserves any right to collect such royalties
|
|
218
|
-
the Licensed Material is used other than for NonCommercial
|
|
219
|
-
purposes.
|
|
207
|
+
reserves any right to collect such royalties.
|
|
220
208
|
|
|
221
209
|
|
|
222
210
|
Section 3 -- License Conditions.
|
|
@@ -278,8 +266,7 @@ apply to Your use of the Licensed Material:
|
|
|
278
266
|
|
|
279
267
|
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
|
280
268
|
to extract, reuse, reproduce, and Share all or a substantial
|
|
281
|
-
portion of the contents of the database
|
|
282
|
-
only;
|
|
269
|
+
portion of the contents of the database;
|
|
283
270
|
|
|
284
271
|
b. if You include all or a substantial portion of the database
|
|
285
272
|
contents in a database in which You have Sui Generis Database
|
|
@@ -385,6 +372,7 @@ Section 8 -- Interpretation.
|
|
|
385
372
|
that apply to the Licensor or You, including from the legal
|
|
386
373
|
processes of any jurisdiction or authority.
|
|
387
374
|
|
|
375
|
+
|
|
388
376
|
=======================================================================
|
|
389
377
|
|
|
390
378
|
Creative Commons is not a party to its public
|
package/LICENSING.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Licensing: what you can use, and how
|
|
2
|
+
|
|
3
|
+
Xero Emoji is by Max Infeld. Different parts of this repository are under different licenses.
|
|
4
|
+
|
|
5
|
+
## 1. The emoji artwork: CC BY 4.0 (free for any use, including commercial)
|
|
6
|
+
|
|
7
|
+
These are licensed under the [Creative Commons Attribution 4.0 International license](https://creativecommons.org/licenses/by/4.0/) (SPDX `CC-BY-4.0`); full text in [`LICENSE`](LICENSE):
|
|
8
|
+
|
|
9
|
+
- every emoji image in `svg/` and `png/`, and the same images in the release zips (`xeroemoji-svg.zip`, `xeroemoji-png-512.zip`, `xeroemoji-png-128.zip`, `xeroemoji-png-72.zip`) and on the jsDelivr CDN
|
|
10
|
+
- the emoji data and lookup code: `demos/emoji-map.json`, `demos/xero-emoji.js`, and the `xeroemoji` npm and PyPI packages (`packages/`)
|
|
11
|
+
- the gallery and demo pages in `demos/` and the MCP server in `mcp/`
|
|
12
|
+
|
|
13
|
+
You may copy, redistribute, modify and use these for any purpose, including in commercial apps, products and open-source projects under any license, as long as you give credit.
|
|
14
|
+
|
|
15
|
+
**Suggested attribution line:**
|
|
16
|
+
|
|
17
|
+
> Xero Emoji by Max Infeld, CC BY 4.0
|
|
18
|
+
|
|
19
|
+
Ideally link "Xero Emoji" to https://github.com/maximusmaximus/xeroemoji and "CC BY 4.0" to https://creativecommons.org/licenses/by/4.0/. If you changed the images, add "modified". A credit in your About page, docs, NOTICE or credits file is fine.
|
|
20
|
+
|
|
21
|
+
## 2. Not covered by CC BY 4.0: commercial license
|
|
22
|
+
|
|
23
|
+
These are **not** under CC BY 4.0. They stay under Max Infeld's separate commercial license (see [`COMMERCIAL-LICENSE.md`](COMMERCIAL-LICENSE.md)):
|
|
24
|
+
|
|
25
|
+
- **The Xero Emoji color font** (`fonts/XeroEmoji-COLRv1.ttf`, `fonts/XeroEmoji-COLRv1.woff2`, and any other font build). Free for non-commercial use under CC BY-NC 4.0 (see [`fonts/LICENSE`](fonts/LICENSE)); any commercial use of the font file needs a commercial license. Building your own font from the CC BY 4.0 SVGs is allowed; the font files published here are what stay commercial.
|
|
26
|
+
- **The book**, *Xero Emoji Specimen Guide* (https://xeroemoji.grok.me/book): all rights reserved.
|
|
27
|
+
- **Merchandise and stickers** sold by or for Max Infeld (physical goods, sticker packs, prints, and their product listings): all rights reserved.
|
|
28
|
+
- **The names "Xero Emoji" and "Xerographer"** and the author's name: CC licenses do not grant trademark rights. You may say your project uses Xero Emoji, but not imply it is made or endorsed by Max Infeld.
|
|
29
|
+
|
|
30
|
+
Commercial licensing: maxinfeld@gmail.com
|
|
31
|
+
|
|
32
|
+
## 3. Earlier releases
|
|
33
|
+
|
|
34
|
+
Releases up to and including v1.0.0 (and the npm/PyPI package builds made from them) were published under CC BY-NC 4.0. The emoji images in those releases are the same artwork, and that artwork is now also available under CC BY 4.0, so you may use the images from earlier tags and releases (for example the `@v1.0.0` jsDelivr URLs) under CC BY 4.0 as well.
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ npm install xeroemoji
|
|
|
8
8
|
|
|
9
9
|
```js
|
|
10
10
|
const xe = require('xeroemoji');
|
|
11
|
-
xe.get('👍🏿').svgUrl; // https://cdn.jsdelivr.net/gh/maximusmaximus/xeroemoji@v1.0.
|
|
11
|
+
xe.get('👍🏿').svgUrl; // https://cdn.jsdelivr.net/gh/maximusmaximus/xeroemoji@v1.0.2/svg/1f44d-1f3ff.svg
|
|
12
12
|
xe.search('cat', { limit: 5 });
|
|
13
13
|
xe.variants('👋'); // the default + 5 skin tones
|
|
14
14
|
xe.setBase('/static/xeroemoji/'); // serve the images yourself
|
|
@@ -20,4 +20,4 @@ The full image sets (SVG, PNG 512/128/72) are zips on the [latest GitHub release
|
|
|
20
20
|
|
|
21
21
|
## License
|
|
22
22
|
|
|
23
|
-
CC BY
|
|
23
|
+
CC BY 4.0 (SPDX `CC-BY-4.0`). Free for any use, including commercial, with credit: "Xero Emoji by Max Infeld, CC BY 4.0" and a link to https://github.com/maximusmaximus/xeroemoji. The Xero Emoji color font, the book and merch are not covered and need a commercial license; see [LICENSING.md](https://github.com/maximusmaximus/xeroemoji/blob/main/LICENSING.md) (also included in this package). Versions up to 1.0.0 were CC BY-NC 4.0.
|
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
/* xeroemoji - Xero Emoji lookup for Node and bundlers. Artwork CC BY
|
|
2
|
+
/* xeroemoji - Xero Emoji lookup for Node and bundlers. Artwork CC BY 4.0 (credit "Xero Emoji by Max Infeld, CC BY 4.0"); see LICENSING.md.
|
|
3
3
|
* const xe = require('xeroemoji');
|
|
4
|
-
* xe.get('👍🏿').svgUrl // https://cdn.jsdelivr.net/gh/maximusmaximus/xeroemoji@v1.0.
|
|
4
|
+
* xe.get('👍🏿').svgUrl // https://cdn.jsdelivr.net/gh/maximusmaximus/xeroemoji@v1.0.2/svg/1f44d-1f3ff.svg
|
|
5
5
|
*/
|
|
6
|
-
const VERSION = '1.0.
|
|
7
|
-
const ART_TAG = 'v1.0.
|
|
6
|
+
const VERSION = '1.0.2';
|
|
7
|
+
const ART_TAG = 'v1.0.2'; // the GitHub tag the images are served from (first CC BY 4.0 release; art unchanged since v1.0.0)
|
|
8
8
|
let MAP = null;
|
|
9
9
|
function map() {
|
|
10
10
|
if (!MAP) MAP = require('./emoji-map.json'); // bundled by `npm pack` (prepack copies ../../demos/emoji-map.json)
|
|
@@ -70,5 +70,5 @@ function categories() {
|
|
|
70
70
|
function url(q, format = 'svg') { const e = get(q); return e ? (format === 'png' ? e.pngUrl : e.svgUrl) : null; }
|
|
71
71
|
/** Point URLs at your own host (e.g. '/static/xeroemoji/') after copying svg/ and png/ there. */
|
|
72
72
|
function setBase(b) { BASE = b.endsWith('/') ? b : b + '/'; }
|
|
73
|
-
const LICENSE = 'Artwork CC BY
|
|
73
|
+
const LICENSE = 'Artwork CC BY 4.0, free for any use including commercial (credit "Xero Emoji by Max Infeld, CC BY 4.0", link https://github.com/maximusmaximus/xeroemoji). Details: https://github.com/maximusmaximus/xeroemoji/blob/main/LICENSING.md';
|
|
74
74
|
module.exports = { VERSION, LICENSE, key, get, search, variants, categories, url, setBase, map };
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xeroemoji",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Xero Emoji lookup: 3,963 Unicode Emoji 18.0 emoji -> SVG/PNG URLs (jsDelivr), names, groups, skin tones, plus the browser replacer.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"bin": {"xeroemoji": "cli.js"},
|
|
8
|
-
"files": ["index.js", "index.d.ts", "cli.js", "xero-emoji.js", "emoji-map.json", "README.md", "LICENSE", "COMMERCIAL-LICENSE.md"],
|
|
8
|
+
"files": ["index.js", "index.d.ts", "cli.js", "xero-emoji.js", "xero-emoji-picker.js", "emoji-map.json", "README.md", "LICENSE", "LICENSING.md", "COMMERCIAL-LICENSE.md"],
|
|
9
9
|
"keywords": ["emoji", "svg", "unicode", "emoji-font", "xeroemoji"],
|
|
10
10
|
"homepage": "https://maximusmaximus.github.io/xeroemoji/",
|
|
11
11
|
"bugs": {"url": "https://github.com/maximusmaximus/xeroemoji/issues"},
|
|
12
12
|
"repository": {"type": "git", "url": "git+https://github.com/maximusmaximus/xeroemoji.git", "directory": "packages/npm"},
|
|
13
13
|
"author": {"name": "Max Infeld", "url": "https://github.com/maximusmaximus"},
|
|
14
|
-
"license": "CC-BY-
|
|
14
|
+
"license": "CC-BY-4.0",
|
|
15
15
|
"engines": {"node": ">=18"},
|
|
16
|
-
"scripts": {"prepack": "node -e \"const fs=require('fs');fs.copyFileSync('../../demos/emoji-map.json','emoji-map.json');fs.copyFileSync('../../demos/xero-emoji.js','xero-emoji.js');fs.copyFileSync('../../LICENSE','LICENSE');fs.copyFileSync('../../COMMERCIAL-LICENSE.md','COMMERCIAL-LICENSE.md')\"", "test": "node test.js"}
|
|
16
|
+
"scripts": {"prepack": "node -e \"const fs=require('fs');fs.copyFileSync('../../demos/emoji-map.json','emoji-map.json');fs.copyFileSync('../../demos/xero-emoji.js','xero-emoji.js');fs.copyFileSync('../../LICENSE','LICENSE');fs.copyFileSync('../../LICENSING.md','LICENSING.md');fs.copyFileSync('../../COMMERCIAL-LICENSE.md','COMMERCIAL-LICENSE.md')\"", "test": "node test.js"}
|
|
17
17
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*! xero-emoji-picker.js - tiny dependency-free emoji picker for Xero Emoji (artwork and code CC BY 4.0: "Xero Emoji by Max Infeld, CC BY 4.0")
|
|
2
|
+
* Usage:
|
|
3
|
+
* <script src="https://cdn.jsdelivr.net/gh/maximusmaximus/xeroemoji@main/packages/npm/xero-emoji-picker.js"></script>
|
|
4
|
+
* const picker = XeroEmojiPicker.attach(buttonEl, { onSelect: e => input.value += e.emoji });
|
|
5
|
+
* // or XeroEmojiPicker.create({ container: el, onSelect }) for an inline picker
|
|
6
|
+
* Options: base (where svg/ lives; default jsDelivr v1.0.2), map (URL of emoji-map.json), onSelect({emoji,name,file,url}),
|
|
7
|
+
* tone ('' | '1f3fb'..'1f3ff'), perRow (default 8), size (px, default 32)
|
|
8
|
+
*/
|
|
9
|
+
(function (root) {
|
|
10
|
+
'use strict';
|
|
11
|
+
var CDN = 'https://cdn.jsdelivr.net/gh/maximusmaximus/xeroemoji@v1.0.2/';
|
|
12
|
+
var TONE = /-1f3f[b-f]/g, cache = {};
|
|
13
|
+
var CSS = '.xep{font:14px system-ui,sans-serif;background:#fff;color:#1d1b18;border:1px solid #e6e2da;border-radius:14px;box-shadow:0 10px 32px rgba(0,0,0,.15);width:var(--w);padding:8px;box-sizing:border-box}' +
|
|
14
|
+
'.xep input{width:100%;box-sizing:border-box;font:inherit;padding:7px 10px;border:1px solid #e6e2da;border-radius:9px;margin-bottom:6px}' +
|
|
15
|
+
'.xep .xep-bar{display:flex;gap:2px;overflow-x:auto;margin-bottom:6px}.xep .xep-bar button{flex:none;border:0;background:none;cursor:pointer;padding:3px 5px;border-radius:7px;opacity:.55}' +
|
|
16
|
+
'.xep .xep-bar button.on{opacity:1;background:#f3f0ea}.xep .xep-bar img{width:20px;height:20px;display:block}' +
|
|
17
|
+
'.xep .xep-grid{display:grid;grid-template-columns:repeat(var(--n),minmax(0,1fr));gap:2px;height:260px;overflow-y:auto;overflow-x:hidden}' +
|
|
18
|
+
'.xep .xep-grid button{border:0;background:none;padding:3px;border-radius:8px;cursor:pointer}.xep .xep-grid button:hover,.xep .xep-grid button:focus{background:#f3f0ea;outline:none}' +
|
|
19
|
+
'.xep .xep-grid img{width:var(--s);height:var(--s);display:block}.xep .xep-h{grid-column:1/-1;font-size:11px;text-transform:uppercase;color:#6b665e;margin:6px 2px 2px}' +
|
|
20
|
+
'.xep .xep-tones{display:flex;gap:2px;margin-top:6px}.xep .xep-tones button{border:1px solid transparent;background:none;border-radius:7px;cursor:pointer;width:24px;height:24px;padding:0}' +
|
|
21
|
+
'.xep .xep-tones button.on{border-color:#1d1b18}';
|
|
22
|
+
var TONES = ['', '1f3fb', '1f3fc', '1f3fd', '1f3fe', '1f3ff'], SW = ['#ffc83d', '#f7dece', '#f3d2a2', '#d5ab88', '#af7e57', '#7c533e'];
|
|
23
|
+
function el(tag, cls, html) { var e = document.createElement(tag); if (cls) e.className = cls; if (html != null) e.innerHTML = html; return e; }
|
|
24
|
+
function css() { if (document.getElementById('xep-css')) return; var s = el('style'); s.id = 'xep-css'; s.textContent = CSS; document.head.appendChild(s); }
|
|
25
|
+
function load(url) {
|
|
26
|
+
return cache[url] || (cache[url] = fetch(url).then(function (r) { return r.json(); }).then(function (m) {
|
|
27
|
+
var all = Object.keys(m).map(function (k) { var e = m[k], t = k.match(TONE);
|
|
28
|
+
return { k: k, f: e[0], e: e[1], n: e[2], g: e[3], sg: e[4], o: e[5], tn: t ? t.map(function (x) { return x.slice(1); }) : null,
|
|
29
|
+
base: t ? k.replace(TONE, '') : k, s: (e[2] + ' ' + e[4] + ' ' + k).toLowerCase() }; }).sort(function (a, b) { return a.o - b.o; });
|
|
30
|
+
var toned = {}; all.forEach(function (x) { if (x.tn) toned[x.base + '|' + x.tn.join(',')] = x; });
|
|
31
|
+
return { all: all, toned: toned };
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
function create(opt) {
|
|
35
|
+
opt = opt || {}; css();
|
|
36
|
+
var base = opt.base || CDN, mapUrl = opt.map || base + 'demos/emoji-map.json', tone = opt.tone || '', group = null, q = '';
|
|
37
|
+
var box = el('div', 'xep'); box.style.setProperty('--n', opt.perRow || 8); box.style.setProperty('--s', (opt.size || 32) + 'px');
|
|
38
|
+
box.style.setProperty('--w', ((opt.perRow || 8) * ((opt.size || 32) + 8) + 24) + 'px');
|
|
39
|
+
box.setAttribute('role', 'dialog'); box.setAttribute('aria-label', 'Emoji picker');
|
|
40
|
+
var input = el('input'); input.type = 'search'; input.placeholder = 'Search emoji'; input.setAttribute('aria-label', 'Search emoji');
|
|
41
|
+
var bar = el('div', 'xep-bar'), grid = el('div', 'xep-grid'), tones = el('div', 'xep-tones');
|
|
42
|
+
box.appendChild(input); box.appendChild(bar); box.appendChild(grid); box.appendChild(tones);
|
|
43
|
+
TONES.forEach(function (t, i) { var b = el('button'); b.style.background = SW[i]; b.title = t ? 'skin tone ' + i : 'default skin tone';
|
|
44
|
+
b.className = t === tone ? 'on' : ''; b.onclick = function () { tone = t; [].forEach.call(tones.children, function (c) { c.className = c === b ? 'on' : ''; }); draw(); };
|
|
45
|
+
tones.appendChild(b); });
|
|
46
|
+
if (opt.container) opt.container.appendChild(box);
|
|
47
|
+
var data = null, timer = 0;
|
|
48
|
+
function src(x) { return base + 'svg/' + x.f + '.svg'; }
|
|
49
|
+
function shown(x) {
|
|
50
|
+
if (x.tn) return false; // base list only; tone applied on render
|
|
51
|
+
if (group && x.g !== group) return false;
|
|
52
|
+
if (!q) return true; return q.split(/\s+/).every(function (w) { return x.s.indexOf(w) >= 0; }) || x.e === q;
|
|
53
|
+
}
|
|
54
|
+
function toned(x) { if (!tone) return x; var n = (x.k.match(/1f9d1|1f468|1f469|1f9d2/g) || []).length || 1, keys = [];
|
|
55
|
+
for (var i = 0; i < Math.max(1, n); i++) keys.push(tone); return data.toned[x.k + '|' + keys.join(',')] || data.toned[x.k + '|' + tone] || x; }
|
|
56
|
+
function draw() {
|
|
57
|
+
if (!data) return; var html = '', sg = '', list = data.all.filter(shown);
|
|
58
|
+
list.forEach(function (x) { var y = toned(x); if (!q && x.sg !== sg) { sg = x.sg; html += '<div class="xep-h">' + sg + '</div>'; }
|
|
59
|
+
html += '<button type="button" data-k="' + y.k + '" title="' + y.n + '"><img loading="lazy" src="' + src(y) + '" alt="' + y.e + '"></button>'; });
|
|
60
|
+
grid.innerHTML = html || '<div class="xep-h">No match</div>';
|
|
61
|
+
}
|
|
62
|
+
grid.onclick = function (ev) { var b = ev.target.closest('button[data-k]'); if (!b) return;
|
|
63
|
+
var x = data.all.filter(function (y) { return y.k === b.dataset.k; })[0];
|
|
64
|
+
if (opt.onSelect) opt.onSelect({ emoji: x.e, name: x.n, file: x.f, url: src(x) });
|
|
65
|
+
if (api.onPick) api.onPick(x); };
|
|
66
|
+
input.oninput = function () { clearTimeout(timer); timer = setTimeout(function () { q = input.value.trim().toLowerCase(); draw(); }, 80); };
|
|
67
|
+
load(mapUrl).then(function (d) { data = d; var seen = {};
|
|
68
|
+
var gs = d.all.filter(function (x) { if (seen[x.g]) return false; seen[x.g] = 1; return true; });
|
|
69
|
+
bar.innerHTML = '<button type="button" class="on" data-g="" title="All">★</button>' + gs.map(function (x) {
|
|
70
|
+
return '<button type="button" data-g="' + x.g + '" title="' + x.g + '"><img src="' + src(x) + '" alt=""></button>'; }).join('');
|
|
71
|
+
bar.onclick = function (ev) { var b = ev.target.closest('button'); if (!b) return; group = b.dataset.g || null;
|
|
72
|
+
[].forEach.call(bar.children, function (c) { c.className = c === b ? 'on' : ''; }); grid.scrollTop = 0; draw(); };
|
|
73
|
+
draw(); });
|
|
74
|
+
var api = { element: box, focus: function () { input.focus(); }, destroy: function () { box.remove(); } };
|
|
75
|
+
return api;
|
|
76
|
+
}
|
|
77
|
+
function attach(button, opt) {
|
|
78
|
+
opt = opt || {}; var p = create(opt), b = p.element; b.style.position = 'absolute'; b.style.zIndex = 9999; b.hidden = true;
|
|
79
|
+
document.body.appendChild(b);
|
|
80
|
+
function close() { b.hidden = true; document.removeEventListener('mousedown', out); }
|
|
81
|
+
function out(ev) { if (!b.contains(ev.target) && ev.target !== button) close(); }
|
|
82
|
+
button.addEventListener('click', function () { if (!b.hidden) return close(); var r = button.getBoundingClientRect();
|
|
83
|
+
b.style.left = Math.max(4, r.left + scrollX) + 'px'; b.style.top = (r.bottom + scrollY + 6) + 'px'; b.hidden = false; p.focus();
|
|
84
|
+
document.addEventListener('mousedown', out); });
|
|
85
|
+
b.addEventListener('keydown', function (ev) { if (ev.key === 'Escape') { close(); button.focus(); } });
|
|
86
|
+
if (opt.closeOnSelect !== false) p.onPick = close;
|
|
87
|
+
p.open = function () { if (b.hidden) button.click(); }; p.close = close; return p;
|
|
88
|
+
}
|
|
89
|
+
var X = { create: create, attach: attach, version: '1.1.0' };
|
|
90
|
+
if (typeof module === 'object' && module.exports) module.exports = X; else root.XeroEmojiPicker = X;
|
|
91
|
+
})(typeof self !== 'undefined' ? self : this);
|
package/xero-emoji.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! xero-emoji.js - swap Unicode emoji in text for Xero Emoji images. No dependencies.
|
|
2
|
-
* Xero Emoji (c) Max Infeld - artwork CC BY
|
|
2
|
+
* Xero Emoji (c) Max Infeld - artwork CC BY 4.0 ("Xero Emoji by Max Infeld, CC BY 4.0"), see LICENSE / LICENSING.md.
|
|
3
3
|
*
|
|
4
4
|
* await XeroEmoji.load({ base: '../', map: 'emoji-map.json', format: 'svg' });
|
|
5
5
|
* XeroEmoji.parse(element); // replace emoji in all text nodes under element
|