@dialpad/dialtone-vue
Version:
Vue component library for Dialpad's design system Dialtone
138 lines (137 loc) • 3.28 kB
JavaScript
import { emojiPattern as j } from "regex-combined-emojis";
import g from "emoji-toolkit/emoji_strategy.json";
const h = new RegExp(j, "g"), E = "8.0", f = "https://cdn.jsdelivr.net/joypixels/assets/" + E + "/png/unicode/32/";
let S = null, y = f, p = ".png", P = f, C = ".png";
const c = g, A = new RegExp("(^| |(?<=:))(:\\w+:)", "g");
function U() {
return c;
}
function w(t, e = ".png") {
t.endsWith("/") || (t = t + "/"), y = t, p = e;
}
function T(t, e = ".svg") {
t.endsWith("/") || (t = t + "/"), P = t, C = e;
}
function W(t) {
S = t;
}
function q(t) {
_(t);
}
function _(t) {
const e = [
"custom",
"date_added",
"image"
], n = [
"date_added",
"image",
"unicode_output",
"shortname",
"shortname_alternates",
"custom",
"name"
], o = (s, i, r) => {
if (s[i] === void 0) {
if (!e.includes(i))
return;
s[i] = r;
} else
Array.isArray(s[i]) ? s[i] = s[i].concat(r) : s[i] = r;
};
Object.entries(t).forEach((s) => {
const [i, r] = s;
if (i in c) {
const m = c[i];
for (const u in r) {
const d = r[u];
o(m, u, d);
}
} else
n.every((u) => r[u] !== void 0) ? c[i] = r : console.error(
"The following custom emoji doesn't contain the required properties:",
r
);
});
}
function l(t) {
function e(o, s) {
if (!(!o || typeof o != "object")) {
if ("shortname" in o && (o.shortname === t || o.shortname_alternates.includes(t)))
return o.key = s, n = o, !0;
Object.keys(o).some(function(i) {
return e(o[i], i);
});
}
}
let n;
return e(U(), null), n;
}
function J(t) {
var n;
if (t.startsWith(":")) return t;
const e = a(t);
return (n = c[e]) == null ? void 0 : n.shortname;
}
function a(t) {
let e = "";
for (const n of t) {
const o = n.codePointAt(0).toString(16).padStart(4, "0");
["200d", "fe0f"].includes(o) || (e !== "" && (e = e + "-"), e = e + o);
}
return e;
}
function L(t) {
const e = t.split("-");
let n = "";
return e.forEach((o) => {
n = n + String.fromCodePoint(parseInt(o, 16));
}), n;
}
function b(t) {
if (t = t == null ? void 0 : t.trim(), t.startsWith(":") && t.endsWith(":"))
return l(t);
{
const e = a(t), n = c[e];
return n && (n.key = e), n;
}
}
function k(t) {
const e = (t.match(A) || []).map((n) => n.trim());
return v(e);
}
function v(t) {
const e = t ? t.filter((n) => l(n)) : [];
return new Set(e);
}
function I(t) {
const e = [...t.matchAll(h)], n = e.length ? e.map((o) => o[0]) : [];
return new Set(n);
}
export {
b as codeToEmojiData,
S as customEmojiAssetUrl,
f as defaultEmojiAssetUrl,
C as emojiFileExtensionLarge,
p as emojiFileExtensionSmall,
P as emojiImageUrlLarge,
y as emojiImageUrlSmall,
c as emojiJson,
h as emojiRegex,
A as emojiShortCodeRegex,
E as emojiVersion,
v as filterValidShortCodes,
I as findEmojis,
k as findShortCodes,
U as getEmojiData,
J as getEmojiShortCode,
q as setCustomEmojiJson,
W as setCustomEmojiUrl,
T as setEmojiAssetUrlLarge,
w as setEmojiAssetUrlSmall,
l as shortcodeToEmojiData,
L as stringToUnicode,
a as unicodeToString,
_ as validateCustomEmojiJson
};
//# sourceMappingURL=index.js.map