django-vue3-admin-web/node_modules/e-icon-picker/components/eScrollbar/index.mjs
2025-10-20 21:21:14 +08:00

450 lines
13 KiB
JavaScript

/**
* e-icon-picker v2.1.1
* (c) 2019 - 2022 cnovel.club
* @license MIT
*/
import { getCurrentScope as G, onScopeDispose as q, unref as J, watch as U, defineComponent as k, ref as m, computed as H, inject as Z, onBeforeUnmount as ee, toRef as W, openBlock as C, createBlock as te, Transition as ne, withCtx as oe, withDirectives as re, createElementVNode as I, normalizeClass as ae, normalizeStyle as D, vShow as le, reactive as j, toRefs as se, resolveComponent as K, createElementBlock as V, Fragment as ie, createVNode as L, nextTick as z, onMounted as ue, onUpdated as ce, provide as fe, renderSlot as de } from "vue";
var A;
const w = typeof window < "u", me = (e) => typeof e == "string", ve = () => {
};
w && ((A = window == null ? void 0 : window.navigator) != null && A.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
function he(e) {
return typeof e == "function" ? e() : J(e);
}
function pe(e) {
return e;
}
function be(e) {
return G() ? (q(e), !0) : !1;
}
function ye(e) {
var t;
const n = he(e);
return (t = n == null ? void 0 : n.$el) != null ? t : n;
}
const ge = w ? window : void 0;
function R(...e) {
let t, n, o, a;
if (me(e[0]) || Array.isArray(e[0]) ? ([n, o, a] = e, t = ge) : [t, n, o, a] = e, !t)
return ve;
Array.isArray(n) || (n = [n]), Array.isArray(o) || (o = [o]);
const s = [], r = () => {
s.forEach((c) => c()), s.length = 0;
}, d = (c, v, h) => (c.addEventListener(v, h, a), () => c.removeEventListener(v, h, a)), u = U(() => ye(t), (c) => {
r(), c && s.push(...n.flatMap((v) => o.map((h) => d(c, v, h))));
}, { immediate: !0, flush: "post" }), b = () => {
u(), r();
};
return be(b), b;
}
const N = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, P = "__vueuse_ssr_handlers__";
N[P] = N[P] || {};
N[P];
var X;
(function(e) {
e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
})(X || (X = {}));
var we = Object.defineProperty, Y = Object.getOwnPropertySymbols, _e = Object.prototype.hasOwnProperty, Se = Object.prototype.propertyIsEnumerable, M = (e, t, n) => t in e ? we(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Ee = (e, t) => {
for (var n in t || (t = {}))
_e.call(t, n) && M(e, n, t[n]);
if (Y)
for (var n of Y(t))
Se.call(t, n) && M(e, n, t[n]);
return e;
};
const Oe = {
easeInSine: [0.12, 0, 0.39, 0],
easeOutSine: [0.61, 1, 0.88, 1],
easeInOutSine: [0.37, 0, 0.63, 1],
easeInQuad: [0.11, 0, 0.5, 0],
easeOutQuad: [0.5, 1, 0.89, 1],
easeInOutQuad: [0.45, 0, 0.55, 1],
easeInCubic: [0.32, 0, 0.67, 0],
easeOutCubic: [0.33, 1, 0.68, 1],
easeInOutCubic: [0.65, 0, 0.35, 1],
easeInQuart: [0.5, 0, 0.75, 0],
easeOutQuart: [0.25, 1, 0.5, 1],
easeInOutQuart: [0.76, 0, 0.24, 1],
easeInQuint: [0.64, 0, 0.78, 0],
easeOutQuint: [0.22, 1, 0.36, 1],
easeInOutQuint: [0.83, 0, 0.17, 1],
easeInExpo: [0.7, 0, 0.84, 0],
easeOutExpo: [0.16, 1, 0.3, 1],
easeInOutExpo: [0.87, 0, 0.13, 1],
easeInCirc: [0.55, 0, 1, 0.45],
easeOutCirc: [0, 0.55, 0.45, 1],
easeInOutCirc: [0.85, 0, 0.15, 1],
easeInBack: [0.36, 0, 0.66, -0.56],
easeOutBack: [0.34, 1.56, 0.64, 1],
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
};
Ee({
linear: pe
}, Oe);
(function() {
return w && document && document.addEventListener ? (e, t, n) => {
e && t && n && e.addEventListener(t, n, !1);
} : (e, t, n) => {
e && t && n && e.attachEvent("on" + t, n);
};
})();
(function() {
return w && document && document.removeEventListener ? function(e, t, n) {
e && t && e.removeEventListener(t, n, !1);
} : function(e, t, n) {
e && t && e.detachEvent("on" + t, n);
};
})();
const Te = (e) => typeof e == "string" && e.constructor === String, E = (e) => typeof e == "number" && e.constructor === Number, ze = (e) => typeof e == "object" && e.constructor === Object;
w && function(e, t, n) {
!e.composedPath && n && (e.composedPath = function() {
if (this.path)
return this.path;
let o = this.target;
for (this.path = []; o.parentNode !== null; )
this.path.push(o), o = o.parentNode;
return this.path.push(t, n), this.path;
}), String.prototype.startsWith || Object.defineProperty(String.prototype, "startsWith", {
value: function(o, a) {
return a = !a || a < 0 ? 0 : +a, this.substring(a, a + o.length) === o;
}
});
}(Event.prototype, document, window);
function Q(e, t = "px") {
if (!e)
return "";
if (Te(e))
return e;
if (E(e))
return `${e}${t}`;
console.warn("binding value must be a string or number");
}
const g = 4, F = Symbol("scrollbarContextKey"), He = {
vertical: {
offset: "offsetHeight",
scroll: "scrollTop",
scrollSize: "scrollHeight",
size: "height",
key: "vertical",
axis: "Y",
client: "clientY",
direction: "top"
},
horizontal: {
offset: "offsetWidth",
scroll: "scrollLeft",
scrollSize: "scrollWidth",
size: "width",
key: "horizontal",
axis: "X",
client: "clientX",
direction: "left"
}
}, $e = k({
name: "e-thumb",
props: {
always: {
type: Boolean,
default: !1
},
vertical: {
type: Boolean,
default: !1
},
size: {
type: Number,
default: 0
},
move: {
type: Number,
default: 0
},
ratio: {
type: Number,
default: 1
}
},
setup(e) {
const t = m(!1);
let n = !1, o = !1;
const a = m(), s = m(), r = H(() => He[e.vertical ? "vertical" : "horizontal"]);
let d = w ? document.onselectstart : null;
const u = Z(F);
if (!u)
return;
const b = (i) => {
if (!a.value || !s.value || !u.wrapElement)
return;
const f = Math.abs(i.target.getBoundingClientRect()[r.value.direction] - i[r.value.client]), y = a.value[r.value.offset] / 2, $ = (f - y) * 100 * v.value / s.value[r.value.offset];
u.wrapElement[r.value.scroll] = $ * u.wrapElement[r.value.scrollSize] / 100;
}, c = H(
() => {
let f = {
transform: `translate${e.vertical ? "Y" : "X"}(${e.move}%)`
};
return e.vertical ? f.height = `${e.size}px` : f.width = `${e.size}px`, f;
}
), v = H(
() => s.value[r.value.offset] ** 2 / u.wrapElement[r.value.scrollSize] / e.ratio / a.value[r.value.offset]
), h = (i) => {
if (!s.value || !a.value || !n)
return;
const f = (s.value.getBoundingClientRect()[r.value.direction] - i[r.value.client]) * -1, y = a.value[r.value.offset], $ = (f - y) * 100 * v.value / s.value[r.value.offset];
u.wrapElement[r.value.scroll] = $ * u.wrapElement[r.value.scrollSize] / 100;
}, O = () => {
document.onselectstart !== d && (document.onselectstart = d);
}, T = () => {
n = !1, document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", T), O(), o && (t.value = !1);
}, l = (i) => {
i.stopImmediatePropagation(), n = !0, document.addEventListener("mousemove", h), document.addEventListener("mouseup", T), d = document.onselectstart, document.onselectstart = () => !1;
}, p = (i) => {
var y;
i.stopPropagation(), i.ctrlKey || [1, 2].includes(i.button) || ((y = window == null ? void 0 : window.getSelection()) == null || y.removeAllRanges(), l(i), i.currentTarget);
};
ee(() => {
O(), document.removeEventListener("mouseup", T);
});
const _ = () => {
o = !1, t.value = !!e.size;
}, S = () => {
o = !0, t.value = n;
};
return R(
W(u, "scrollbarElement"),
"mousemove",
_
), R(
W(u, "scrollbarElement"),
"mouseleave",
S
), {
visible: t,
clickTrackHandler: b,
clickThumbHandler: p,
eThumb: a,
thumbStyle: c,
instance: s
};
}
});
const B = (e, t) => {
const n = e.__vccOpts || e;
for (const [o, a] of t)
n[o] = a;
return n;
};
function Ie(e, t, n, o, a, s) {
return C(), te(ne, { name: "fade" }, {
default: oe(() => [
re(I("div", {
ref: "instance",
class: ae(["e-thumb", e.vertical ? "is-vertical" : "is-horizontal"]),
onMousedown: t[1] || (t[1] = (...r) => e.clickTrackHandler && e.clickTrackHandler(...r))
}, [
I("div", {
ref: "eThumb",
class: "e-thumb-inner",
style: D(e.thumbStyle),
onMousedown: t[0] || (t[0] = (...r) => e.clickThumbHandler && e.clickThumbHandler(...r))
}, null, 36)
], 34), [
[le, e.always || e.visible]
])
]),
_: 1
});
}
const Le = /* @__PURE__ */ B($e, [["render", Ie], ["__scopeId", "data-v-30bd9195"]]), Ne = k({
name: "e-bar",
props: {
always: {
type: Boolean,
default: !0
},
ratioY: {
type: Number,
default: 1
},
ratioX: {
type: Number,
default: 1
},
width: {
type: Number,
default: 0
},
height: {
type: Number,
default: 0
}
},
components: {
eThumb: Le
},
setup(e) {
const t = j({
moveX: 0,
moveY: 0
}), n = (o) => {
if (o) {
const a = o.offsetHeight - g, s = o.offsetWidth - g;
t.moveY = o.scrollTop * 100 / a * e.ratioY, t.moveX = o.scrollLeft * 100 / s * e.ratioX;
}
};
return {
...se(t),
handleScroll: n
};
}
});
function Pe(e, t, n, o, a, s) {
const r = K("e-thumb");
return C(), V(ie, null, [
L(r, {
move: e.moveX,
ratio: e.ratioX,
size: e.width,
always: e.always
}, null, 8, ["move", "ratio", "size", "always"]),
L(r, {
move: e.moveY,
ratio: e.ratioY,
size: e.height,
vertical: "",
always: e.always
}, null, 8, ["move", "ratio", "size", "always"])
], 64);
}
const ke = /* @__PURE__ */ B(Ne, [["render", Pe], ["__scopeId", "data-v-80bd0648"]]), Ce = "scroll", Be = k({
name: "e-scrollbar",
props: {
height: {
type: [String, Number],
default: ""
},
maxHeight: {
type: [String, Number],
default: ""
},
wrapStyle: {
type: Object,
default: () => ({})
},
always: Boolean,
noresize: Boolean,
minSize: {
type: Number,
default: 20
}
},
components: {
eBar: ke
},
setup(e, { emit: t }) {
const n = m(), o = m();
let a = m(0), s = m(0), r = m(1), d = m(1);
const u = m(), b = H(() => {
const l = {};
return e.height && (l.height = Q(e.height)), e.maxHeight && (l.maxHeight = Q(e.maxHeight)), [e.wrapStyle, l];
}), c = () => {
if (!o.value)
return;
const l = o.value.offsetHeight - g, p = o.value.offsetWidth - g, _ = l ** 2 / o.value.scrollHeight, S = p ** 2 / o.value.scrollWidth, i = Math.max(_, e.minSize), f = Math.max(S, e.minSize);
r.value = _ / (l - _) / (i / (l - i)), d.value = S / (p - S) / (f / (p - f)), s.value = i + g < l ? i : 0, a.value = f + g < p ? f : 0;
};
U(
() => [e.maxHeight, e.height],
() => {
z(() => {
var l;
c(), o.value && ((l = u.value) == null || l.handleScroll(o.value));
});
}
);
const v = (l, p) => {
ze(l) ? o.value.scrollTo(l) : E(l) && E(p) && o.value.scrollTo(l, p);
}, h = (l) => {
if (!E(l)) {
console.warn("value must be a number");
return;
}
z(() => {
o.value.scrollTop = l;
});
}, O = (l) => {
if (!E(l)) {
console.warn("value must be a number");
return;
}
z(() => {
o.value.scrollLeft = l;
});
};
return ue(() => {
z(() => c());
}), ce(() => c()), fe(
F,
j({
scrollbarElement: n,
wrapElement: o
})
), {
eScrollbar: n,
wrap: o,
style: b,
sizeWidth: a,
sizeHeight: s,
ratioX: d,
ratioY: r,
update: c,
barRef: u,
handleScroll: () => {
var l;
o.value && ((l = u.value) == null || l.handleScroll(o.value), t(Ce, {
scrollTop: o.value.scrollTop,
scrollLeft: o.value.scrollLeft
}));
},
setScrollTop: h,
setScrollLeft: O,
scrollTo: v
};
}
});
const We = {
class: "e-scrollbar",
ref: "eScrollbar"
};
function Ae(e, t, n, o, a, s) {
const r = K("e-bar");
return C(), V("div", We, [
I("div", {
ref: "wrap",
style: D(e.style),
onScroll: t[0] || (t[0] = (...d) => e.handleScroll && e.handleScroll(...d)),
class: "e-scrollbar-wrap"
}, [
de(e.$slots, "default", {}, void 0, !0)
], 36),
L(r, {
ref: "barRef",
height: e.sizeHeight,
width: e.sizeWidth,
"ratio-x": e.ratioX,
"ratio-y": e.ratioY,
always: e.always
}, null, 8, ["height", "width", "ratio-x", "ratio-y", "always"])
], 512);
}
const x = /* @__PURE__ */ B(Be, [["render", Ae], ["__scopeId", "data-v-1bb2aa3b"]]), Xe = {
install(e) {
e.component(x.name, x);
}
};
export {
Xe as default,
ke as eBar,
x as eScrollbar,
Le as eThumb
};