@anoki/fse-ui
Version:
FSE UI components library
188 lines (187 loc) • 5.86 kB
JavaScript
import { a } from "./index.es470.js";
function g(t) {
return t === void 0 && (t = ""), t.trim().split(" ").filter((e) => !!e.trim());
}
function x(t) {
const e = t;
Object.keys(e).forEach((r) => {
try {
e[r] = null;
} catch {
}
try {
delete e[r];
} catch {
}
});
}
function b(t, e) {
return e === void 0 && (e = 0), setTimeout(t, e);
}
function v() {
return Date.now();
}
function S(t) {
const e = a();
let r;
return e.getComputedStyle && (r = e.getComputedStyle(t, null)), !r && t.currentStyle && (r = t.currentStyle), r || (r = t.style), r;
}
function C(t, e) {
e === void 0 && (e = "x");
const r = a();
let n, o, s;
const l = S(t);
return r.WebKitCSSMatrix ? (o = l.transform || l.webkitTransform, o.split(",").length > 6 && (o = o.split(", ").map((i) => i.replace(",", ".")).join(", ")), s = new r.WebKitCSSMatrix(o === "none" ? "" : o)) : (s = l.MozTransform || l.OTransform || l.MsTransform || l.msTransform || l.transform || l.getPropertyValue("transform").replace("translate(", "matrix(1, 0, 0, 1,"), n = s.toString().split(",")), e === "x" && (r.WebKitCSSMatrix ? o = s.m41 : n.length === 16 ? o = parseFloat(n[12]) : o = parseFloat(n[4])), e === "y" && (r.WebKitCSSMatrix ? o = s.m42 : n.length === 16 ? o = parseFloat(n[13]) : o = parseFloat(n[5])), o || 0;
}
function d(t) {
return typeof t == "object" && t !== null && t.constructor && Object.prototype.toString.call(t).slice(8, -1) === "Object";
}
function T(t) {
return typeof window < "u" && typeof window.HTMLElement < "u" ? t instanceof HTMLElement : t && (t.nodeType === 1 || t.nodeType === 11);
}
function y() {
const t = Object(arguments.length <= 0 ? void 0 : arguments[0]), e = ["__proto__", "constructor", "prototype"];
for (let r = 1; r < arguments.length; r += 1) {
const n = r < 0 || arguments.length <= r ? void 0 : arguments[r];
if (n != null && !T(n)) {
const o = Object.keys(Object(n)).filter((s) => e.indexOf(s) < 0);
for (let s = 0, l = o.length; s < l; s += 1) {
const i = o[s], u = Object.getOwnPropertyDescriptor(n, i);
u !== void 0 && u.enumerable && (d(t[i]) && d(n[i]) ? n[i].__swiper__ ? t[i] = n[i] : y(t[i], n[i]) : !d(t[i]) && d(n[i]) ? (t[i] = {}, n[i].__swiper__ ? t[i] = n[i] : y(t[i], n[i])) : t[i] = n[i]);
}
}
}
return t;
}
function O(t, e, r) {
t.style.setProperty(e, r);
}
function P(t) {
let {
swiper: e,
targetPosition: r,
side: n
} = t;
const o = a(), s = -e.translate;
let l = null, i;
const u = e.params.speed;
e.wrapperEl.style.scrollSnapType = "none", o.cancelAnimationFrame(e.cssModeFrameID);
const p = r > s ? "next" : "prev", h = (f, m) => p === "next" && f >= m || p === "prev" && f <= m, w = () => {
i = (/* @__PURE__ */ new Date()).getTime(), l === null && (l = i);
const f = Math.max(Math.min((i - l) / u, 1), 0), m = 0.5 - Math.cos(f * Math.PI) / 2;
let c = s + m * (r - s);
if (h(c, r) && (c = r), e.wrapperEl.scrollTo({
[n]: c
}), h(c, r)) {
e.wrapperEl.style.overflow = "hidden", e.wrapperEl.style.scrollSnapType = "", setTimeout(() => {
e.wrapperEl.style.overflow = "", e.wrapperEl.scrollTo({
[n]: c
});
}), o.cancelAnimationFrame(e.cssModeFrameID);
return;
}
e.cssModeFrameID = o.requestAnimationFrame(w);
};
w();
}
function j(t, e) {
e === void 0 && (e = "");
const r = a(), n = [...t.children];
return r.HTMLSlotElement && t instanceof HTMLSlotElement && n.push(...t.assignedElements()), e ? n.filter((o) => o.matches(e)) : n;
}
function E(t, e) {
const r = [e];
for (; r.length > 0; ) {
const n = r.shift();
if (t === n)
return !0;
r.push(...n.children, ...n.shadowRoot ? n.shadowRoot.children : [], ...n.assignedElements ? n.assignedElements() : []);
}
}
function F(t, e) {
const r = a();
let n = e.contains(t);
return !n && r.HTMLSlotElement && e instanceof HTMLSlotElement && (n = [...e.assignedElements()].includes(t), n || (n = E(t, e))), n;
}
function H(t) {
try {
console.warn(t);
return;
} catch {
}
}
function L(t, e) {
e === void 0 && (e = []);
const r = document.createElement(t);
return r.classList.add(...Array.isArray(e) ? e : g(e)), r;
}
function _(t, e) {
const r = [];
for (; t.previousElementSibling; ) {
const n = t.previousElementSibling;
e ? n.matches(e) && r.push(n) : r.push(n), t = n;
}
return r;
}
function A(t, e) {
const r = [];
for (; t.nextElementSibling; ) {
const n = t.nextElementSibling;
e ? n.matches(e) && r.push(n) : r.push(n), t = n;
}
return r;
}
function I(t, e) {
return a().getComputedStyle(t, null).getPropertyValue(e);
}
function k(t) {
let e = t, r;
if (e) {
for (r = 0; (e = e.previousSibling) !== null; )
e.nodeType === 1 && (r += 1);
return r;
}
}
function W(t, e) {
const r = [];
let n = t.parentElement;
for (; n; )
e ? n.matches(e) && r.push(n) : r.push(n), n = n.parentElement;
return r;
}
function D(t, e, r) {
const n = a();
return t[e === "width" ? "offsetWidth" : "offsetHeight"] + parseFloat(n.getComputedStyle(t, null).getPropertyValue(e === "width" ? "margin-right" : "margin-top")) + parseFloat(n.getComputedStyle(t, null).getPropertyValue(e === "width" ? "margin-left" : "margin-bottom"));
}
function K(t) {
return (Array.isArray(t) ? t : [t]).filter((e) => !!e);
}
function V(t, e) {
e === void 0 && (e = ""), typeof trustedTypes < "u" ? t.innerHTML = trustedTypes.createPolicy("html", {
createHTML: (r) => r
}).createHTML(e) : t.innerHTML = e;
}
export {
O as a,
W as b,
L as c,
j as e,
v as f,
D as h,
k as i,
g as j,
C as k,
K as m,
b as n,
d as o,
I as q,
A as r,
V as s,
_ as t,
P as u,
H as v,
F as w,
y as x,
x as y
};
//# sourceMappingURL=index.es468.js.map