@alegendstale/holly-components
Version:
Reusable UI components created using lit
62 lines (61 loc) • 1.56 kB
JavaScript
function c(e) {
return e == null ? [] : Array.isArray(e) ? e : typeof e != "string" && typeof e[Symbol.iterator] == "function" ? Array.from(e) : [e];
}
function h(e) {
return e ? new Promise((t) => setTimeout(t, e)) : new Promise((t) => requestAnimationFrame(t));
}
let o;
function m(e) {
o ??= document.createElement("div");
let t = o.style;
t[e] = "inherit";
let n = [...t];
return n.length === 0 && (n = [e]), t.cssText = "", n;
}
function u(e) {
let t = e.matchAll(/(?:^|\s)([+-]?(?:\d+|\d*\.\d+))\s*(ms|s)?(?=\s|$)/g), n = [];
for (let r of t) {
let [, i, l] = r;
i = parseFloat(i), l === "s" && (i *= 1e3), n.push(i);
}
return n;
}
function d(e, t) {
t = a(t);
let n;
if (e === "all")
n = /\b\w+\b/g;
else {
let f = [.../* @__PURE__ */ new Set([...m(e), e, "all"])];
n = RegExp(`(?:^|\\s)(${f.join("|")})\\b`);
}
let r = t.findLast((f) => n.test(f)), i = r ? u(r) : [0, 0];
i.length === 0 ? i = [0, 0] : i.length === 1 && i.push(0);
let [l, s] = i;
return { duration: l, delay: s };
}
function a(e) {
let t = [], n = 0, r = [];
for (let i of e.matchAll(/[,()]/g)) {
let l = i[0];
if (l === ",") {
if (r.length === 0) {
let s = e.slice(n, i.index);
t.push(s.trim()), n = i.index + 1;
}
} else l === "(" ? r.push("(") : l === ")" && r.pop();
}
if (n < e.length) {
let i = e.slice(n);
t.push(i.trim());
}
return t;
}
export {
m as getLonghands,
d as getTimesFor,
u as parseTimes,
a as splitCommas,
c as toArray,
h as wait
};