solid-intlayer
Version:
Easily internationalize i18n your Solid applications with type-safe multilingual content management.
58 lines (57 loc) • 1.98 kB
JavaScript
import { d as p, t as T, s as k, i as L, u as y } from "../../web-mv0y5CK4.mjs";
import { createSignal as m, createEffect as C, onCleanup as P, mergeProps as w } from "solid-js";
var D = /* @__PURE__ */ T("<span role=button tabindex=0>");
const O = 250, x = (t) => {
let n;
const [f, l] = m(!1), [a, r] = m(t.isSelecting);
let s = null;
const h = typeof t.children == "string", v = () => {
r(!0), t.onPress();
}, $ = () => {
s = setTimeout(() => {
v();
}, t.pressDuration ?? O);
}, i = () => {
s && (clearTimeout(s), s = null);
}, u = () => {
i(), $();
}, g = () => {
l(!0), t.onHover?.();
}, o = () => {
l(!1), i();
}, c = (e) => {
n && !n.contains(e.target) && (r(!1), t.onClickOutside?.());
};
C(() => {
document.addEventListener("mousedown", c), P(() => {
document.removeEventListener("mousedown", c), i();
});
});
const E = (e) => {
a() && (e.preventDefault(), e.stopPropagation());
}, S = () => {
r(!1);
};
return (() => {
var e = D(), d = n;
return typeof d == "function" ? y(d, e) : n = e, e.addEventListener("mouseenter", g), e.addEventListener("blur", S), e.addEventListener("touchcancel", o), e.$$touchend = o, e.$$touchstart = u, e.addEventListener("mouseleave", o), e.$$mouseup = o, e.$$mousedown = u, e.$$click = E, e.$$keyup = () => null, k(e, w({
get style() {
return {
display: h ? "inline" : "inline-block",
cursor: "pointer",
"user-select": "none",
"border-radius": "0.375rem",
"outline-width": "2px",
"outline-offset": "4px",
"outline-style": "solid",
"outline-color": t.isSelecting || a() || f() ? "inherit" : "transparent",
transition: "all 100ms 50ms ease-in-out"
};
}
}, t), !1, !0), L(e, () => t.children), e;
})();
};
p(["keyup", "click", "mousedown", "mouseup", "touchstart", "touchend"]);
export {
x as ContentSelector
};